After installing PyTorch, the introduction of torchvision reported an error: Failed to load image Python extension: warn(f“Failed to load image Python

1. Problem analysis:

The error is as follows:

Failed to load image Python extension:  warn(f"Failed to load image Python extension: {e}")

Generally, there may be two reasons for the above error report for reference:

1. The installed pytorch and torchvision versions do not match

2. The cuda version used is inappropriate

After installing PyTorch, import torch did not report an error, but import torchvision reported an error, so it is mostly because the versions of pytorch and torchvision are not correct.

2. Solution:

1. Find the version correspondence between pytorch and torchvision

The latest version correspondence query address: https://github.com/pytorch/vision#installation

 2. Specify the torchvision installation version

The following are the installation parameters I specified

Look up the table, pytorch version 1.12.0 corresponds to torchvision version 0.12, just specify torchvision version 0.12.

Original installation command:

conda install pytorch torchvision torchaudio cpuonly -c pytorch

Modify the installation command:

conda install pytorch torchvision==0.12 torchaudio cpuonly -c pytorch

Test again and successfully import:

Guess you like

Origin blog.csdn.net/qq_45397526/article/details/125834669