Pytorch 中 torchvision的錯誤

2021-09-25 01:49:43 字數 577 閱讀 6954

在學習pytorch的時候,使用 torchvision的時候發生了乙個小小的問題

安裝都成功了,並且import torch也沒問題,但是在import torchvision的時候,出現了如下所示的錯誤資訊:dll load failed:找不到指定模組。

首先,我們得知道torchvision在conda裡是裝不了的,安裝完後,我們發現torchvision其實是有環境依賴的,其中有一條就是pillow的版本,而此次出錯的問題主要就是這個pil的問題。因為根本沒有提供給win的資源,因此我們只能使用pip安裝

這裡要是提示的是雖然在conda list中可以找到這個模組 但是還是不能使用

我的解決辦法就是

開啟anaconda promp在conda 下 使用pip 解除安裝pillow

pip uninstall pillow
然後在當前環境下使用 pip安裝最新的 pillow在以前的4.x中好像不支援這個模組了

pip install pillow
最好使用國內源進行更換

我是通過這個方法解決的不知道是不是適用你們

Pytorch中建立DataLoader的幾種方法

簡介 這段 是mnist手寫體識別中的部分 此篇 為mnist手寫體識別中的 import torch import torchvision import torchvision.transforms as transforms from torch.utils.data import datalo...

pytorch中的乘法

總結 按元素相乘用torch.mul,二維矩陣乘法用torch.mm,batch二維矩陣用torch.bmm,batch 廣播用torch.matmul if name main a torch.tensor 1 2,3 b torch.arange 0,12 reshape 4 3 c torch...

pytorch中index select 的用法

a torch.linspace 1,12,steps 12 view 3,4 print a b torch.index select a,0,torch.tensor 0,2 print b print a.index select 0,torch.tensor 0,2 c torch.inde...