pytorch使用過程當中遇到的一些問題

問題一html

ImportError: No module named torchvision
python

torchvison:圖片、視頻數據和深度學習模型git

解決方案github

安裝torchvision,參照官網學習


問題二測試

安裝torchvision過程當中遇到 Could not find a version that satisfies the requirement olefile (from pillow->torchvision==0.1.8) ui

沒有olefilespa

解決方案.net

安裝olfile,官網視頻


問題三

找不到nn.init模塊

具體錯誤內容 'module' object has no attribute 'init'

解決方案

找到如下目錄torch/nn, 此目錄下有init.py和__init__.py文件,打開__init__.py文件看到如下內容:

 
  1. from .modules import *  
  2. from .parameter import Parameter  
  3. from .parallel import DataParallel  

在代碼的最後加上如下語句

 
  1. from .init import *  


保存並退出,從新運行便可

 

問題四:torch not compiled with cuda enabled

解決方案

最好根據github上的教程,進行源安裝:網址:https://github.com/pytorch/pytorch

安裝好以後進行測試:a = torch.ones(1,1)

print a.cuda() 有結果,說明安裝成功,須要torchvision,那麼conda install torchvision -c soumith提示安裝pytorch(cuda)和torchvision,選擇yes的話,基本上失敗,下載pytorch太慢! 若是conda install torchvision選擇yes的話,以後再import torch是會報錯:Undefined symbol:THLongStorage_inferSizeN.(不知道什麼緣由,果斷選擇避坑)。

安裝torchvision:去官網下載離線包:.whl格式,以後在終端pip install 這個格式的包

相關文章
相關標籤/搜索