运行时错误:cuDNN错误:CUDNN_STATUS_NOT_使用pytorch初始化

2022-02-23 00:00:00 python pytorch gpu

问题描述

我正在尝试运行一个简单的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坞站中运行此代码,我的GPU是RTX 2070


解决方案

关于此here有一些讨论。我也有同样的问题,但是使用CUDA 11.1为我解决了这个问题。

这正是pip命令

pip install torch==1.8.0+cu111 torchvision==0.9.0+cu111 torchaudio==0.8.0 -f https://download.pytorch.org/whl/torch_stable.html

相关文章