问题描述
在conda环境中安装了torch,执行torch.cuda.is_available()报错:
/home/xy/anaconda3/envs/py38/lib/python3.8/site-packages/torch/cuda/init.py:52: UserWarning: CUDA initialization: CUDA driver initialization failed, you might not have a CUDA gpu. (Triggered internally at /pytorch/c10/cuda/CUDAFunctions.cpp:109.)
环境说明:ubuntu16.04, GeForce GTX 1080 Ti, torch 1.8.1+cu111, Driver version: 440.82
问题分析
安装torch时选择的cuda版本和驱动版本不兼容,可以从官网查看cuda版本对应的驱动版本:https://docs.nvidia.com/cuda/cuda-toolkit-release-notes/index.html
使用nvidia-smi查看当前的驱动版本:发现驱动版本440.82可以使用cuda10.2
问题解决
使用pip uninstall torch卸载之前安装的torch1.8.1+cu111,
重新安装torch(版本为torch1.8.1+cu102),上述报错解决。
或者更新驱动版本>=455.32