Skip to content

Instantly share code, notes, and snippets.

@flc
Created April 5, 2019 17:37
Show Gist options
  • Save flc/a16a23f85825c34d9fcc0665993753e2 to your computer and use it in GitHub Desktop.
Save flc/a16a23f85825c34d9fcc0665993753e2 to your computer and use it in GitHub Desktop.
pytorch install google colab
from os.path import exists
from wheel.pep425tags import get_abbr_impl, get_impl_ver, get_abi_tag
platform = '{}{}-{}'.format(get_abbr_impl(), get_impl_ver(), get_abi_tag())
cuda_output = !ldconfig -p|grep cudart.so|sed -e 's/.*\.\([0-9]*\)\.\([0-9]*\)$/cu\1\2/'
accelerator = cuda_output[0] if exists('/dev/nvidia0') else 'cpu'
!pip install -q http://download.pytorch.org/whl/{accelerator}/torch-0.4.1-{platform}-linux_x86_64.whl torchvision
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment