RuntimeError: cuDNN error: CUDNN_STATUS_NOT_INITIALIZED using pytorch
- test code
import torch
from torch import nn
m = nn.Conv1d(16, 33, 3, stride=2)
m=m.to('cuda')
input = torch.randn(20, 16, 50)
input=input.to('cuda')
output = m(input)
- test if cudnn is correctly installed or not
import torch
print(torch.backends.cudnn.is_acceptable(torch.cuda.FloatTensor(1)))
True
print(torch.backends.cudnn.version())
6021
解决方法1:
I guess this is not the best solution but by downgrading to torch-1.7.1 and torchvision-0.8.2 it works just fine.
pip install torch torchvision -i 镜像 依然很慢,此时利用wget来安装速度会加快很多
sudo wget http://download.pytorch.org/whl/cu102/torch-1.7.1-cp36-cp36m-linux_x86_64.whl
sudo wget http://download.pytorch.org/whl/cu102/torchvision-0.8.2-cp36-cp36m-linux_x86_64.whl
sudo pip3 install torch-1.7.1-cp36-cp36m-linux_x86_64.whl
sudo pip3 install torchvision-0.8.2-cp36-cp36m-linux_x86_64.whl
安装好之后再跑 test code, 问题完美解决。
希望对大家有所帮助。