尝试 YOLOv8 python 在 Windows 多处理上出现运行时错误

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

我正在使用 Pycharm 在 Python 中尝试我的第一个 YOLOv8。 代码很简单。

from ultralytics import YOLO

model = YOLO("yolov8n.yaml")

results = model.train(data="config.yaml", epochs=2)

我得到的错误如下。

RuntimeError:  Attempt to start a new process before the current process has finished its bootstrapping phase. This probably means that you are on Windows and you have forgotten to use the proper idiom in the main module: if __name__ == '__main__': freeze_support() ... The "freeze_support()" line can be omitted if the program is not going to be frozen to produce a executable.

我使用的是以下版本的 MIC-770 V3:

  • Python:3.11.9
  • CUDA 可用:正确
  • CUDA版本:12.4
  • YOLOv8版本:8.2.100

有人遇到过这个问题吗? GPU 或 CPU 是否需要驱动器来处理多处理?

我尝试使用带有以下函数 multiprocessing.freeze_support() 的多处理库,但它不起作用。

python windows yolov8
1个回答
0
投票

此错误意味着您需要将代码放入其中

main
:

if __name__ == '__main__':
     from ultralytics import YOLO
     model = YOLO("yolov8n.yaml")
     results = model.train(data="config.yaml", epochs=2)
© www.soinside.com 2019 - 2024. All rights reserved.