Open Kai0KenX20 opened 4 months ago
đ Hello @Kai0KenX20, thank you for raising an issue about Ultralytics HUB đ! Please visit our HUB Docs to learn more:
If this is a đ Bug Report, please provide screenshots and steps to reproduce your problem to help us get started working on a fix.
If this is a â Question, please provide as much information as possible, including dataset, model, environment details etc. so that we might provide the most helpful response.
We try to respond to all issues as promptly as possible. Thank you for your patience!
Hi @Kai0KenX20,
Thank you for reaching out and providing detailed information about the issue you're encountering. It looks like the error is related to the multiprocessing module in Python when trying to start a new process during training. This is a common issue on Windows systems.
To resolve this, you need to ensure that your training script includes the following safeguard:
if __name__ == '__main__':
import torch
from ultralytics import YOLO
# Your training code here
model = YOLO('yolov8n.pt') # Example model
results = model.train(data='path/to/your/dataset.yaml', epochs=100)
This if __name__ == '__main__':
block is necessary to prevent the multiprocessing module from attempting to re-import the main module, which causes the error you are seeing.
Additionally, please ensure you are using the latest versions of all relevant packages, including ultralytics
and torch
. You can update them using:
pip install --upgrade ultralytics torch
If the issue persists after making these changes, please let us know, and we can further investigate. Thank you for your patience and for being part of the YOLO community! đ
Search before asking
Question
this happens when i try to train using my own hardware...", line 1, in
File "C:\Users\BIGBANGz\AppData\Local\Programs\Python\Python311\Lib\multiprocessing\spawn.py", line 122, in spawn_main
exitcode = _main(fd, parent_sentinel)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\BIGBANGz\AppData\Local\Programs\Python\Python311\Lib\multiprocessing\spawn.py", line 131, in _main
prepare(preparation_data)
File "C:\Users\BIGBANGz\AppData\Local\Programs\Python\Python311\Lib\multiprocessing\spawn.py", line 246, in prepare
_fixup_main_from_path(data['init_main_from_path'])
File "C:\Users\BIGBANGz\AppData\Local\Programs\Python\Python311\Lib\multiprocessing\spawn.py", line 297, in _fixup_main_from_path
main_content = runpy.run_path(main_path,
^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 291, in run_path
File "", line 98, in _run_module_code
File "", line 88, in _run_code
File "C:\Users\BIGBANGz\Desktop\Res-Softaim-ControllerSupport-main\test3.py", line 7, in
results = model.train()
^^^^^^^^^^^^^
File "C:\Users\BIGBANGz\AppData\Local\Programs\Python\Python311\Lib\site-packages\ultralytics\engine\model.py", line 811, in train
self.trainer.train()
File "C:\Users\BIGBANGz\AppData\Local\Programs\Python\Python311\Lib\site-packages\ultralytics\engine\trainer.py", line 205, in train
self._do_train(world_size)
File "C:\Users\BIGBANGz\AppData\Local\Programs\Python\Python311\Lib\site-packages\ultralytics\engine\trainer.py", line 324, in _do_train
self._setup_train(world_size)
File "C:\Users\BIGBANGz\AppData\Local\Programs\Python\Python311\Lib\site-packages\ultralytics\engine\trainer.py", line 288, in _setup_train
self.train_loader = self.get_dataloader(self.trainset, batch_size=batch_size, rank=RANK, mode="train")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\BIGBANGz\AppData\Local\Programs\Python\Python311\Lib\site-packages\ultralytics\models\yolo\detect\train.py", line 55, in get_dataloader
return build_dataloader(dataset, batch_size, workers, shuffle, rank) # return dataloader
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\BIGBANGz\AppData\Local\Programs\Python\Python311\Lib\site-packages\ultralytics\data\build.py", line 135, in build_dataloader
return InfiniteDataLoader(
^^^^^^^^^^^^^^^^^^^
File "C:\Users\BIGBANGz\AppData\Local\Programs\Python\Python311\Lib\site-packages\ultralytics\data\build.py", line 39, in init
self.iterator = super().iter()
^^^^^^^^^^^^^^^^^^
File "C:\Users\BIGBANGz\AppData\Local\Programs\Python\Python311\Lib\site-packages\torch\utils\data\dataloader.py", line 484, in iter
return self._get_iterator()
^^^^^^^^^^^^^^^^^^^^
File "C:\Users\BIGBANGz\AppData\Local\Programs\Python\Python311\Lib\site-packages\torch\utils\data\dataloader.py", line 415, in _get_iterator
return _MultiProcessingDataLoaderIter(self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\BIGBANGz\AppData\Local\Programs\Python\Python311\Lib\site-packages\torch\utils\data\dataloader.py", line 1138, in init
w.start()
File "C:\Users\BIGBANGz\AppData\Local\Programs\Python\Python311\Lib\multiprocessing\process.py", line 121, in start
self._popen = self._Popen(self)
^^^^^^^^^^^^^^^^^
File "C:\Users\BIGBANGz\AppData\Local\Programs\Python\Python311\Lib\multiprocessing\context.py", line 224, in _Popen
return _default_context.get_context().Process._Popen(process_obj)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\BIGBANGz\AppData\Local\Programs\Python\Python311\Lib\multiprocessing\context.py", line 336, in _Popen
return Popen(process_obj)
^^^^^^^^^^^^^^^^^^
File "C:\Users\BIGBANGz\AppData\Local\Programs\Python\Python311\Lib\multiprocessing\popen_spawn_win32.py", line 46, in init
prep_data = spawn.get_preparation_data(process_obj._name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\BIGBANGz\AppData\Local\Programs\Python\Python311\Lib\multiprocessing\spawn.py", line 164, in get_preparation_data
_check_not_importing_main()
File "C:\Users\BIGBANGz\AppData\Local\Programs\Python\Python311\Lib\multiprocessing\spawn.py", line 140, in _check_not_importing_main
raise RuntimeError('''
RuntimeError:
An attempt has been made to start a new process before the
current process has finished its bootstrapping phase.
train: Scanning C:\Users\BIGBANGz\Desktop\new\yolov8_aimbot-main\datasets\fn.v2i.yolov8\train\labels.cache... 8587 imag Traceback (most recent call last): File "
Additional
No response