如何修复 Colab 上的 Autodistill Invalid Cuda 错误?

问题描述 投票:0回答:1

https://colab.research.google.com/github/roboflow-ai/notebooks/blob/main/notebooks/how-to-auto-train-yolov8-model-with-autodistill.ipynb

我正在尝试在 Colab 上测试这个。关于此部分:

%cd {HOME}
from autodistill_yolov8 import YOLOv8
target_model = YOLOv8("yolov8n.pt")
target_model.train(DATA_YAML_PATH, epochs=50)

但是当我开始训练时却找不到这个错误的解决方案:

/usr/local/lib/python3.10/dist-packages/ultralytics/yolo/utils/torch_utils.py in select_device(device, batch, newline, verbose)
67 install = 'See https://pytorch.org/get-started/locally/ for up-to-date torch install instructions if no '
68 'CUDA devices are seen by torch.\\n' if torch.cuda.device_count() == 0 else ''
\---\> 69 raise ValueError(f"Invalid CUDA 'device={device}' requested."
70 f" Use 'device=cpu' or pass valid CUDA device(s) if available,"
71 f" i.e. 'device=0' or 'device=0,1,2,3' for Multi-GPU.\\n"

ValueError: Invalid CUDA 'device=cuda' requested. Use 'device=cpu' or pass valid CUDA device(s) if available, i.e. 'device=0' or 'device=0,1,2,3' for Multi-GPU.

torch.cuda.is_available(): True
torch.cuda.device_count(): 1
os.environ\['CUDA_VISIBLE_DEVICES'\]: cuda

我似乎可以使用 GPU,但我无法解决这个问题。

我搜索了这个问题,但没有找到任何东西。

pytorch google-colaboratory yolo
1个回答
0
投票

对于您在开始时遇到的摩擦深表歉意。我推动了一项更改,以在 Autodistill 中启用 YOLOv8 训练的

mps
加速支持,但默认设备配置未正确设置。

升级到autodistill-yolov8 0.1.3:

pip install --upgrade autodistill-yolov8==0.1.3

使用此代码进行训练:

target_model.train(DATA_YAML_PATH, epochs=50, devices=[0,1...])

其中

devices
是您要在训练中使用的 CUDA 设备 ID 列表。

© www.soinside.com 2019 - 2024. All rights reserved.