完整报错
serWarning:
NVIDIA GeForce RTX 4060 Laptop GPU with CUDA capability sm_89 is not compatible with the current PyTorch installation.
The current PyTorch install supports CUDA capabilities sm_37 sm_50 sm_60 sm_61 sm_70 sm_75 compute_37.
If you want to use the NVIDIA GeForce RTX 4060 Laptop GPU GPU with PyTorch, please check the instructions at https://pytorch.org/get-started/locally/
warnings.warn(incompatible_device_warn.format(device_name, capability, " ".join(arch_list), device_name))
报错原因
显卡算力与cuda版本不匹配
解决方案
方案一(推荐)
正确使用40系显卡训练深度学习模型的方法_哔哩哔哩_bilibili
方案二(常规方案)
1.检查显卡算力
import torch
print('CUDA版本:',torch.version.cuda)
print('Pytorch版本:',torch.__version__)
print('显卡是否可用:','可用' if(torch.cuda.is_available()) else '不可用')
print('显卡数量:',torch.cuda.device_count())
print('是否支持BF16数字格式:','支持' if (torch.cuda.is_bf16_supported()) else '不支持')
print('当前显卡型号:',torch.cuda.get_device_name())
print('当前显卡的CUDA算力:',torch.cuda.get_device_capability())
print('当前显卡的总显存:',torch.cuda.get_device_properties(0).total_memory/1024/1024/1024,'GB')
print('是否支持TensorCore:','支持' if (torch.cuda.get_device_properties(0).major >= 7) else '不支持')
print('当前显卡的显存使用率:',torch.cuda.memory_allocated(0)/torch.cuda.get_device_properties(0).total_memory*100,'%')
你也可以直接在链接里查看:CUDA GPU - 计算能力 |NVIDIA 开发者
2. 算力和cuda的版本对应关系
哪些 CUDA 版本支持哪种计算能力?- 堆栈溢出 (stackoverflow.com)
3.显卡驱动和cuda对应关系
CUDA 12.3 Update 2 Release Notes (nvidia.com)
卸载cuda
4.安装cuda
方案三(不失为一种方法)
不用40系显卡,我最后换30系显卡,还是30用得顺手