CUDA initialization: The NVIDIA driver on your system is too old (found version 11040). Please update your GPU driver by downloading and installing a new version from the URL: http://www.nvidia.com/Download/index.aspx Alternatively, go to: https://pytorch.org to install a PyTorch version that has been compiled with your version of the CUDA driver.
import torch
print(torch.__version__)
print(torch.cuda.is_available())
1.12.1+cu113
nvidia-smi
NVIDIA-SMI 470.82.01 Driver Version: 470.82.01 CUDA Version: 11.4
在指定的conda环境下命令行运行下列代码,发现输出false
python
import torch
print(torch.cuda.is_available())
更新gpu版本的torch
pip install torch==2.0.1 torchvision==0.15.2 torchaudio==2.0.2
可以顺利使用GPU