Raymond Raymond

Torchvision error: Could not find module image.pyd

event 2021-12-30 visibility 7,542 comment 6 insights toc
more_vert
insights Stats

Error context

I installed PyTorch in Anaconda with CUDA 10.2 as compute platform via the following command line:

conda install pytorch torchvision torchaudio cudatoolkit=10.2 -c pytorch

The following error shows up:

 UserWarning: Failed to load image Python extension: Could not find module 'D:\conda\envs\py38\Lib\site-packages\torchvision\image.pyd' (or one of its dependencies). Try using the full path with constructor syntax.
  warn(f"Failed to load image Python extension: {e}")

Fix this issue

There are two approaches to fix these two issues based on my research:

Approach 1 - use CUDA 11.3

Use the following command to use CUDA 11.3 as compute platform:

conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch

20211230233408-image.png

Approach 2 - rename image.pyd to image.py

I have not verified this approach but found it from internet (Chinese).

*.pyd files are Python extension modules compiled from other languages like C.

This approach is to manually rename 'image.pyd' in torchvision package folder (for example, the path is  'D:\conda\envs\py38\Lib\site-packages\torchvision' in my computer) to 'image.py'.

Let me know if you can get it work.

More from Kontext
comment Comments
Raymond Raymond #1683 access_time 2 years ago more_vert
谢谢分享你的解决方案。
format_quote

person Liming access_time 2 years ago

原因就是版本不适配,直接pip3 uninstall torchvision 然后直接pip install torchvison .系统默认安装即可.


L Liming Yao #1682 access_time 2 years ago more_vert

原因就是版本不适配,直接pip3 uninstall torchvision 然后直接pip install torchvison .系统默认安装即可.


Raymond Raymond #1669 access_time 2 years ago more_vert

Thanks for the confirmation. 

format_quote

person xb access_time 2 years ago

Appproch 2 worded for me.

use the vs code. rename image.pyd to image.py.

X xb qiu #1668 access_time 2 years ago more_vert

Appproch 2 worded for me.

use the vs code. rename image.pyd to image.py.

Raymond Raymond #1638 access_time 2 years ago more_vert

What is the error message you got after installing with cuda 11.3

format_quote

person Nick access_time 2 years ago

neither of these approaches work for me, I'm on windows.   pytorch 1.10  does not recognise ny cuda11 and I cannot install pytorch 1.11 there are so many discordant dependencies.

Rename suggestion doesnt make sense, The error message comes from inside image.py  on the statement _load_library("image")

so I am totally stuck/

N Nick McElwaine #1637 access_time 2 years ago more_vert

neither of these approaches work for me, I'm on windows.   pytorch 1.10  does not recognise ny cuda11 and I cannot install pytorch 1.11 there are so many discordant dependencies.

Rename suggestion doesnt make sense, The error message comes from inside image.py  on the statement _load_library("image")

so I am totally stuck/

Please log in or register to comment.

account_circle Log in person_add Register

Log in with external accounts