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 这个格式的包

 

posted @ 2017-07-12 22:05  琴影  阅读(38140)  评论(0编辑  收藏  举报