Tag Archives: torchvision Error

[Solved] torchvision Error: UserWarning: Failed to load image Python extension: Could not find module

Tochvision error: userwarning: failed to load image Python extension: could not find module

One reason is that the version of torchvision is too high. It is suspected that the new version of torchvision has its own pot. At first, according to the official website

pip3 install torch==1.10.1+cu102 torchvision==0.11.2+cu102 torchaudio===0.10.1+cu102 -f https://download.pytorch.org/whl/cu102/torch_stable.html

After that, the error of image will be reported. You only need to reduce the version of torch vision. For example, you can enter it in your Anaconda prompt

conda activate ltorch # ltorch is the name of the virtual environment I created
pip install torchvision==0.10.1+cu102 -f https://download.pytorch.org/whl/cu102/torch_stable.html

It was 0.11.2, but I reduced it to 0.10.1. Import without error:

Of course, you can change the version according to the following link

https://download.pytorch.org/whl/cu102/torch_stable.html