UPDATE 8th Dec, 2018: Since now PyTorch stable is available, I have updated and released a new notebook with stable version. I am keeping this blog post as it is for historical reasons. You can you get the updated version from here — https://medium.com/@ml_kid/google-colab-notebook-with-pytorch-v1-0-stable-lesson-9-46433881da05
In Lesson 9 of Udacity’s Deep Learning with Python, we explore the latest features of PyTorch. We use beta/nightly version of PyTorch, which is not available on stable release channel. So, to get the appropriate version working on Google Colab, I made this handy notebook, which installs correct PyTorch version based on the GPU architecture of Google Colab.
Here are the brief steps:
- Download the modified Notebook from this link
- Visit Google Colab
- You will be prompted with a modal, select Upload
- If modal doesn’t appear and instead if it opens a new Notebook, then from menu File > Upload Notebook
- Upload the modified notebook
- That’s it!
If you are curious to know what I did, then I wrote this following script which downloads PyTorch v1 nightly:
from os.path import exists
from wheel.pep425tags import 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 torchvision_nightly
!pip install torch_nightly -f https://download.pytorch.org/whl/nightly/{accelerator}/torch_nightly.html
Hope this helps! If you have got any issues with running this notebook, then feel free to message me on Slack for any help. My slack username is avinash
All the best for the last lesson!