python - 谷歌 Colab 运行时错误 : cuDNN error: CUDNN_STATUS_NOT_INITIALIZED

标签 python google-colaboratory

昨天和今天运行与过去几个月运行相同的 Python 笔记本,出现错误

/usr/local/lib/python3.6/dist-packages/torch/autograd/__init__.py in backward(tensors, grad_tensors, retain_graph, create_graph, grad_variables)
 97     Variable._execution_engine.run_backward(
 98         tensors, grad_tensors, retain_graph, create_graph,
 ---> 99         allow_unreachable=True)  # allow_unreachable flag
100 
101 

RuntimeError: cuDNN error: CUDNN_STATUS_NOT_INITIALIZED

代码中此错误似乎是随机的点,因为它从尝试更改。从我搜索的内容来看,它看起来是一个兼容性问题。

另外,如果我重新运行单元格,我可能会收到另一个错误,即
/usr/local/lib/python3.6/dist-packages/torch/utils/data/dataloader.py in __next__(self)
346         data = self._dataset_fetcher.fetch(index)  # may raise StopIteration
347         if self._pin_memory:
--> 348             data = _utils.pin_memory.pin_memory(data)
349         return data
350 

/usr/local/lib/python3.6/dist-packages/torch/utils/data/_utils/pin_memory.py in pin_memory(data)
 53         return type(data)(*(pin_memory(sample) for sample in data))
 54     elif isinstance(data, container_abcs.Sequence):
 ---> 55         return [pin_memory(sample) for sample in data]
 56     elif hasattr(data, "pin_memory"):
 57         return data.pin_memory()

 /usr/local/lib/python3.6/dist-packages/torch/utils/data/_utils/pin_memory.py in <listcomp>(.0)
 53         return type(data)(*(pin_memory(sample) for sample in data))
 54     elif isinstance(data, container_abcs.Sequence):
 ---> 55         return [pin_memory(sample) for sample in data]
 56     elif hasattr(data, "pin_memory"):
 57         return data.pin_memory()

 /usr/local/lib/python3.6/dist-packages/torch/utils/data/_utils /pin_memory.py in pin_memory(data)
 45 def pin_memory(data):
 46     if isinstance(data, torch.Tensor):
 ---> 47         return data.pin_memory()
 48     elif isinstance(data, string_classes):
 49         return data

 RuntimeError: cuda runtime error (700) : an illegal memory access was encountered at /pytorch/aten/src/THC/THCCachingHostAllocator.cpp:278

有没有其他人有同样的问题?有没有人解决,怎么解决?

最佳答案

最后,我解决了这个问题。

  • 在我的代码中的某个地方,我使用了 CrossEntropyLoss具有 ignore_index 参数的函数为 ignore_index = my_ignore_index .错误地,我有 my_ignore_index = -1作为值,它不是我的数据的有效值; -1 从未出现在我的数据值中。正确更新解决了问题。这解决了“...一个非法内存访问是encou...”错误。
  • 我所做并帮助解决问题的另一件事是使用较新版本的 anaconda3。这解决了CUDNN_STATUS_NOT_INITIALIZED错误。

  • 我希望这有帮助。

    关于python - 谷歌 Colab 运行时错误 : cuDNN error: CUDNN_STATUS_NOT_INITIALIZED,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59159441/

    相关文章:

    Python 位数组反向补码

    python - 在 Google Colab 上创建 SparkContext 给出 : `RuntimeError: Java gateway process exited before sending its port number`

    python - SQLAlchemy 与连接 (python)

    python - 在tensorflow中将一个2d张量动态划分为多个张量

    python - 如何从 curl 获取 session ID 并在下一个 GET 请求中再次使用它

    matplotlib - Google Colaboratory matplotlib 图表中的自定义字体

    google-colaboratory - Colab : Best way to create a copy/clone of notebook in Goolge Colaboratory

    python - 启动时启动 logme.py

    python - 如何将 tensorflow 模型保存到谷歌驱动器

    python - 在 Colab 中为 torch_sparse 构建轮子需要永远