PyTorch LSTM偶现CUDNN_STATUS_INTERNAL_ERROR错误解决

2021/1/31更新:

根据 PyTorch官方文档 ,在有的cuDNN和CUDA版本中LSTM是有问题的,修复方式如下:

There are known non-determinism issues for RNN functions on some versions of cuDNN and CUDA. You can enforce deterministic behavior by setting the following environment variables:
On CUDA 10.1, set environment variable CUDA_LAUNCH_BLOCKING=1. This may affect performance.
On CUDA 10.2 or later, set environment variable (note the leading colon symbol) CUBLAS_WORKSPACE_CONFIG=:16:8 or
CUBLAS_WORKSPACE_CONFIG=:4096:2.
See the cuDNN 8 Release Notes for more information.


2020/11/06更新:

禁用cudnn有可能可以解决这个问题,但是会减慢运行速度:

torch.backends.cudnn.enabled = False

cudnn经常有bug,无语。


2020/8/20更新:

降级cudatookkit只能降低发生率,不能彻底解决。这个问题无解,可能存在问题地方太多了,怀疑是cudnn有问题导致显存不够。


网上该问题的解决方案有清空.nv缓存、修改Windows注册表等,但是都没什么作用。
我发现网上出现该问题的人都用的是比较新的显卡和最新的cuda,推测是cudatoolkit版本过新所以不稳定,因此将10.2版本的cudatoolkit降级到10.1版本,该问题解决:

conda install pytorch torchvision cudatoolkit=10.1

你可能感兴趣的:(杂项,机器学习,pytorch)