Modules missing after installing Pytorch 1.7.1

I just updated from pytorch 1.7.0 to 1.7.1 using anaconda and I seem to no longer be able to see

torchvision.models.detection

or torchvision.ops

How do I access these modules? Maybe my install was bad?

How can I revert back to Pytorch 1.7.0

I cannot reproduce this issue and am able to import the mentioned modules:

>>> import torch
>>> import torchvision
>>> torch.__version__
'1.7.1'
>>> torchvision.__version__
'0.8.2'
>>> import torchvision.models as models
>>> models.detection
<module 'torchvision.models.detection' from '.../anaconda3/envs/pytorch_171/lib/python3.8/site-packages/torchvision/models/detection/__init__.py'>
>>> torchvision.ops
<module 'torchvision.ops' from '.../anaconda3/envs/pytorch_171/lib/python3.8/site-packages/torchvision/ops/__init__.py'>

Are you sure you’ve installed the latest PyTorch and torchvision releases?

Here is my revision history in Anaconda. Rev 10 is for 1.7, and Rev 11 is for 1.7.1

2020-12-01 15:15:19 (rev 10)
cudatoolkit {11.0.221 (defaults/win-64) → 11.0.3 (conda-forge/win-64)}
pytorch {1.8.0.dev20201021 (pytorch-nightly/win-64) → 1.7.0 (pytorch/win-64)}
torchvision {0.8.0.dev20201021 (pytorch-nightly/win-64) → 0.8.1 (pytorch/win-64)}
+torchaudio-0.7.0 (pytorch/win-64)

2020-12-10 22:57:52 (rev 11)
ca-certificates {2020.11.8 (conda-forge/win-64) → 2020.12.5 (conda-forge/win-64)}
certifi {2020.11.8 (conda-forge/win-64) → 2020.12.5 (conda-forge/win-64)}
pytorch {1.7.0 (pytorch/win-64) → 1.7.1 (pytorch/win-64)}
torchaudio {0.7.0 (pytorch/win-64) → 0.7.2 (pytorch/win-64)}
torchvision {0.8.1 (pytorch/win-64) → 0.2.2 (pytorch/noarch)}
+six-1.15.0 (conda-forge/noarch)

For whatever reason I see “noarch” in regards to torchvision. I used the command:
conda install pytorch torchvision torchaudio cudatoolkit=11.0 -c pytorch

It’s worth mentioning I’ve been modifying the code a little bit in these modules mentioned in the original question, incase that has something to do with it.

As a followup, since I have an RTX 3080 GPU and am using 16 bit precision with torch.cuda.amp.autocast(), is it worth it to upgrade to 1.7.1. I read something about it being faster. Anyway thanks for the help

Based on the output it seems your torchvision version was downgraded to 0.2.2:

torchvision {0.8.1 (pytorch/win-64) -> 0.2.2 (pytorch/noarch)}

and I’m unsure why this would happen. Could you create a new virtual environment and reinstall the latest lib versions?

I would generally recommend to update to the latest release for the best support.
Also, the 1.7.1 binaries ship with cudnn 8.0.5, which should improve the performance compared to 8.0.3.

1 Like

Made a new conda environment and everything worked. I suspect it’s because I modified code from those modules but maybe it’s another reason. Oh well.