Pytorch 0.4.0 on Google colab

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.

1 Like

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.

12 Likes

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

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.

2 Likes

Yeah, changing the notebook worked …thanks!

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

Thanks man, that’s work for me.

In my case, I uninstalled previous pytorch(torch) following your guide. But, I got “0.3.0.post4” by command “print(torch.version)” even can’t find torch in “pip list”! There is some problem about caching python module in using notebook. Best solution is make new notebook and install lasted pytorch version. Another solution is deleting cache. Click “Restart Runtime” below “Tool” in colab menu. Then you can see message “ModuleNotFoundError: No module named ‘torch’”.

Thanks worked for me (I just skipped right ahead to a new notebook; the old one didn’t have too much work)

Hello,
I’m running code from solution post and get this kind of error:
tcmalloc: large alloc 1073750016 bytes == 0x5c44e000 @

Do you get this error while installing PyTorch?
Could you post the stack trace after the @ symbol?

The error is thrown by gperftools as far as I know, so apparently the notebook doesn’t like some allocations.

I’ve been running same code today, but notebook crashes and restarts, so I can’t get stack trace after. I’ll update later if I get it running.
It dies on torch import line
image

tcmalloc: large alloc 1073750016 bytes == 0x5bf26000 @  0x7faaad0171c4 0x46d6a4 0x5fcbcc 0x4c494d 0x54f3c4 0x553aaf 0x54e4c8 0x54f4f6 0x553aaf 0x54efc1 0x54f24d 0x553aaf 0x54efc1 0x54f24d 0x553aaf 0x54efc1 0x54f24d 0x551ee0 0x54e4c8 0x54f4f6 0x553aaf 0x54efc1 0x54f24d 0x551ee0 0x54efc1 0x54f24d 0x551ee0 0x54e4c8 0x54f4f6 0x553aaf 0x54e4c8

Hope it helps. What kind of info can you extract from this?

Unfortunately nothing. When searching for this error, someone mentioned that the stack trace was put after the @, but apparently that’s not the case.

I tried to run the script in a new notebook and got the same “error”.
Apparently it’s just a warning, as after a few seconds, PyTorch is successfully installed.

Could you try it again and wait a few more seconds?

I’m running new notebook from another laptop, and now, after several days it returns this:

tcmalloc: large alloc 1073750016 bytes == 0x5b56e000 @  0x7fea13c7d1c4 0x46d6a4 0x5fcbcc 0x4c494d 0x54f3c4 0x553aaf 0x54e4c8 0x54f4f6 0x553aaf 0x54efc1 0x54f24d 0x553aaf 0x54efc1 0x54f24d 0x553aaf 0x54efc1 0x54f24d 0x551ee0 0x54e4c8 0x54f4f6 0x553aaf 0x54efc1 0x54f24d 0x551ee0 0x54efc1 0x54f24d 0x551ee0 0x54e4c8 0x54f4f6 0x553aaf 0x54e4c8
0.4.0
True

Have no idea what is this alloc, but now it works. And it didn’t last time.

I want to install PyTorch 0.3.1 but when it is install
the colab " module not found "
What am I should doing?

It works for me. Thank you!