问题原因:没有安装对应的CUDA toolkit(toolkit就是指工具包)和
cuDNN(用于配置深度学习使用)
解决办法: 参考下面这篇博客安装对应的cuda
和cuDNN
问题即可解决
https://blog.csdn.net/weixin_43848614/article/details/117221384
结果验证:
按上面的操作结束后使用conda新建一个环境安装然后安装pytorch
可参考这篇博客
https://blog.csdn.net/QH2107/article/details/126326149?spm=1001.2014.3001.5501
看是否可用,新建一个python文件,运行下面的代码
import torch
def gpu_is_available():
print('\nGPU details:')
print(f' gpu_is_available : ', torch.cuda.is_available())
print(f' cuda_device_count : ', torch.cuda.device_count())
print(f' cuda_device_name : ', torch.cuda.get_device_name())
print(f' cuda_device_capability: ', torch.cuda.get_device_capability(0))
gpu_is_available()
可以看到GPU可用了!
希望有所帮助!喜欢就点个赞吧!