问题:运行yolov9./train_dual.py时(device=0)
报错:
AssertionError: Invalid CUDA '--device 0' requested, use '--device cpu' or pass valid CUDA device(s)
寻找问题
nvcc -V 有版本号
nvidia -smi 有信息
print(torch.cuda.is_available()) 输出:False
#已安装yolov9 requirement的环境 (yolo)
conda list 输出:无
pip list 有
解决:
重新下载cuda11.7 与对应cudnn直接安装
配置conda channel 镜像源(在管理员权限powershell中运行)
conda config --set channel_priority flexible
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes
查看镜像源
conda config --show channels
删除源
conda config --remove-key channels
查看源优先级
conda config --get channels
重新下载 pytorch (在管理员权限powershell中运行)
conda install pytorch==2.0.1 torchvision==0.15.2 torchaudio==2.0.2 pytorch-cuda=11.7 -c pytorch -c nvidia
然后
import torch
print(torch.cuda.is_available())
print(torch.cuda.device_count())
print(torch.cuda.get_device_name(0))
*******pip 清华镜像源*******