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


問題一

ImportError: No module named torchvision

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

解決方案

安裝torchvision,參照官網


問題二

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

沒有olefile

解決方案

安裝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 這個格式的包

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM