当使用比较新的显卡(比如NVIDIA GeForce RTX 50系列显卡)时,由于显卡的架构比较新,可能旧版本的pytorch库没有支持到。这时候就会出现capability sm_120 is not compatible的问题,同时根据输出可以看到 The current PyTorch install supports CUDA capabilities sm_37 sm_50 sm_60 sm_70 sm_75...当前pytorch只能支持上面几种架构
重新创建一个虚拟环境,python 3.9 --pre 的意思是预发布版
pip3 install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cu128
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu128
然后还有报错
WeightsUnpickler error: Unsupported global: GLOBAL ultralytics.nn.tasks.Dete
根据路径找到该文件tasks.py 一般是这样的路径
ultralytics\nn\tasks.py
根据路径找到该文件tasks.py,然后找到提示错误的行代码
torch.load(file, map_location="cpu")
在torch.load里面加个参数weights_only=False
,修改为:
ckpt= torch.load(file, map_location="cpu",weights_only=False)
保存修改后的文件,程序即可正常运行