Pytorch 0.4.0 on Google colab


#1

It looks like I have installed the version 0.4.0 successfully as the attached screenshot.

Besides, I also ran !pip freeze to confirm torch==0.4.0

However, when I run the code below. The version still shows ‘0.3.0.post4’!

import torch
torch.__version__

Does colab forbid 0.4.0 or is there anything wrong with my installation? Thank you.


#2

Could you try to uninstall PyTorch and run the following command instead:

from os import path
from wheel.pep425tags import get_abbr_impl, get_impl_ver, get_abi_tag
platform = '{}{}-{}'.format(get_abbr_impl(), get_impl_ver(), get_abi_tag())

accelerator = 'cu80' if path.exists('/opt/bin/nvidia-smi') else 'cpu'

!pip install -q http://download.pytorch.org/whl/{accelerator}/torch-0.4.0-{platform}-linux_x86_64.whl torchvision
import torch
print(torch.__version__)
print(torch.cuda.is_available())

It’s working in my colab environment.


(Anshuk Uppal) #3

Does not work for me , still prints torch version 0.3.0.post4 , uninstalled torch and torchvision using pip3-


#4

There might be another PyTorch installation.
As you can see, you’ve uninstalled torch-0.4.0, then reinstalled it, but version 0.3.0.post4 is loaded.
Try to run the uninstall command several times until an error message occurs saying there are no torch installations.
Otherwise, could you try to create a new “clean” colab notebook?
I had similar issues with some package installations.


(Anshuk Uppal) #5

Yeah, changing the notebook worked …thanks!

Apparently torch can be imported even when it is not installed XD (cache ??)