pytorch安装
国内安装pytorch速度非常慢,建议离线实现离线下载好,保存起来
----------------------------------分割线----------------------------------
假定已经离线下载好目标版本whl文件
pip install torch.****.whl
conda install torchvision=0.2.1 cudatoolkit=8.0
其中第二部conda install 可以事先选择清华源
常见问题
RuntimeError:CUDNN_STATUS_INTERNAL_ERROR
sudo rm -rf ~/.nv
https://github.com/SeanNaren/deepspeech.pytorch/issues/32
TypeError: expected Tensor as element 0 in argument 0, but got tuple
有一个变量不是tensor类型
python使用scipy.misc import imread报错:ImportError: cannot import name imread,imresize
很有可能当前安装scipy版本为1.3.1,此版本已经移除这几个函数,需要安装1.2.1
pip install scipy==1.2.1
ImportError: bad magic number in 'xxx': b'\x03\xf3\r\n'
可能是由于文件夹内存在.pyc文件,删除后重新运行即可
RuntimeError: set_sizes_contiguous is not allowed on Tensor created from .data or .detach()
pytorch版本问题,删除.data 或者 .detach()即可
即 a.data.b.c改为a.b.c
TypeError: cannot assign 'torch.cuda.FloatTensor' as parameter 'T' (torch.nn.Parameter or None expected)
错误示例如下
import torch
from torch.nn.parameter import Parameter
class MyLayer(nn.Module):
def __init__(self, inplace=True):
super(MyLayer, self).__init__()
'''others'''
self.T= Parameter(torch.Tensor(1))
'''others'''
def forward(self, input):
'''others'''
self.T = xxx
'''others'''
return xxx
根据提示可知,错误原因应该是类型不匹配,不可以将torch.cuda.FloatTensor赋值给Parameter类型,应该是赋值给Parameter的data属性,即
self.T.data = xxx
RCAN在pytorch1.1.0中运行错误:ImportError: cannot import name '_update_worker_pids',ImportError: cannot import name '_worker_manager_loop' from 'torch.utils.data.dataloader'
版本问题,解决方案参见【这里】