【发布时间】:2021-06-09 19:27:34
【问题描述】:
我正在尝试运行一个简单的 pytorch 示例代码。使用 CPU 可以正常工作。但是在使用 GPU 时,我收到以下错误消息:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 889, in _call_impl
result = self.forward(*input, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/conv.py", line 263, in forward
return self._conv_forward(input, self.weight, self.bias)
File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/conv.py", line 260, in _conv_forward
self.padding, self.dilation, self.groups)
RuntimeError: cuDNN error: CUDNN_STATUS_NOT_INITIALIZED
我尝试运行的代码如下:
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)
我正在使用 CUDA 10.2 版的 NVIDIA docker 中运行此代码,我的 GPU 是 RTX 2070
【问题讨论】:
-
一个与您的问题无关的提示。请不要使用 python 关键字作为变量,因为这会导致一些非常丑陋和困难的问题。
-
import torch.cuda/torch.cuda.is_available()? -
我在 CUDA 10.2 上遇到了完全相同的问题。你解决了吗?
-
@GuojunZhang 我用nvidia docker的pytorch容器解决了。