win10 AssertionError: Torch not compiled with CUDA enabled

win10系统下CUDA已安装,运行训练程序时报错:

File "D:\anaconda\lib\site-packages\torch\backends\cudnn\__init__.py", line 78, in version
    if _libcudnn() is None:
  File "D:\anaconda\lib\site-packages\torch\backends\cudnn\__init__.py", line 54, in _libcudnn
    compile_version = torch._C._cudnn_version()
AttributeError: module 'torch._C' has no attribute '_cudnn_version'

运行测试程序时报错:

 File "D:\anaconda\lib\site-packages\torch\cuda\__init__.py", line 162, in _lazy_init
    _check_driver()
  File "D:\anaconda\lib\site-packages\torch\cuda\__init__.py", line 75, in _check_driver
    raise AssertionError("Torch not compiled with CUDA enabled")
AssertionError: Torch not compiled with CUDA enabled

我太南了…

解决方法:

查了好久,后来直觉还是环境的问题,下载了个torch-1.2.0-cp36-cp36m-win_amd64.whl,问题解决。
github 上针对AssertionError: Torch not compiled with CUDA enabled 报错,解决方法是把数据加载里参数pin_memory True改为False,但我改完还是会报错,安装高版本torch也不能解决的小伙伴可以参考。

你可能感兴趣的:(win10 AssertionError: Torch not compiled with CUDA enabled)