Pytorch天坑

【错误】# Torch not compiled with CUDA enabled解决方法

1-测试是否有CUDA

1
2
3
import torch
print(torch.__version__)
print(torch.cuda.is_available())

2-结果打印False,查看显卡驱动程序版本【右键- NVIDIA控制面板-系统信息-显示】

1
nvcc -v

>下载CUDA<

3-测试Pytorch可用

1
2
3
import torch
print(torch.__version__)
print(torch.cuda.is_available)

*注:若返回结果类似【2.0.1+cpu】,则安装PyTorch版本是CPU版,需要卸载重新安装

1
pip uninstall torch torchvision

>PyTorch<