yolo-tiny剪枝错误
Opened this issue · 5 comments
首先非常感谢作者的开源,但是我在使用tiny剪枝时遇到了错误,BrokenPipeError: [Errno 32] Broken pipe RuntimeError: The "freeze_support()" line can be omitted if the program大致是线程之类的错误,我用的使自己训练的四分类网络就是标准的yolo-tiny只更改了yolo层符合我的四个输出。望作者解答
Class Images Targets P R mAP F1: 0%| | 0/108 [00:00<?, ?it/s]Traceback (most recent call last):
File "", line 1, in
File "F:\anaconda\envs\python36\lib\multiprocessing\spawn.py", line 105, in spawn_main
exitcode = _main(fd)
File "F:\anaconda\envs\python36\lib\multiprocessing\spawn.py", line 114, in _main
prepare(preparation_data)
File "F:\anaconda\envs\python36\lib\multiprocessing\spawn.py", line 225, in prepare
_fixup_main_from_path(data['init_main_from_path'])
File "F:\anaconda\envs\python36\lib\multiprocessing\spawn.py", line 277, in _fixup_main_from_path
run_name="mp_main")
File "F:\anaconda\envs\python36\lib\runpy.py", line 263, in run_path
pkg_name=pkg_name, script_name=fname)
File "F:\anaconda\envs\python36\lib\runpy.py", line 96, in _run_module_code
mod_name, mod_spec, pkg_name, script_name)
File "F:\anaconda\envs\python36\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "F:\image_work\jianzhi\YOLOv3-complete-pruning-master\prune_tiny_yolo.py", line 38, in
origin_model_metric = eval_model(model)
File "F:\image_work\jianzhi\YOLOv3-complete-pruning-master\prune_tiny_yolo.py", line 33, in
eval_model = lambda model:test(model=model,cfg=opt.model_def, data=opt.data_config)
File "F:\image_work\jianzhi\YOLOv3-complete-pruning-master\test.py", line 69, in test
Traceback (most recent call last):
File "prune_tiny_yolo.py", line 38, in
origin_model_metric = eval_model(model)
File "prune_tiny_yolo.py", line 33, in
eval_model = lambda model:test(model=model,cfg=opt.model_def, data=opt.data_config)
File "F:\image_work\jianzhi\YOLOv3-complete-pruning-master\test.py", line 69, in test
for batch_i, (imgs, targets, paths, shapes) in enumerate(tqdm(dataloader, desc=s)):
File "F:\anaconda\envs\python36\lib\site-packages\tqdm\std.py", line 1093, in iter
for batch_i, (imgs, targets, paths, shapes) in enumerate(tqdm(dataloader, desc=s)):
File "F:\anaconda\envs\python36\lib\site-packages\tqdm\std.py", line 1093, in iter
for obj in iterable:
File "F:\anaconda\envs\python36\lib\site-packages\torch\utils\data\dataloader.py", line 819, in iter
for obj in iterable:
File "F:\anaconda\envs\python36\lib\site-packages\torch\utils\data\dataloader.py", line 819, in iter
return _DataLoaderIter(self)
return _DataLoaderIter(self)
File "F:\anaconda\envs\python36\lib\site-packages\torch\utils\data\dataloader.py", line 560, in init
File "F:\anaconda\envs\python36\lib\site-packages\torch\utils\data\dataloader.py", line 560, in init
w.start()
File "F:\anaconda\envs\python36\lib\multiprocessing\process.py", line 105, in start
w.start()
self._popen = self._Popen(self)
File "F:\anaconda\envs\python36\lib\multiprocessing\process.py", line 105, in start
File "F:\anaconda\envs\python36\lib\multiprocessing\context.py", line 223, in _Popen
self._popen = self._Popen(self)
File "F:\anaconda\envs\python36\lib\multiprocessing\context.py", line 223, in _Popen
return _default_context.get_context().Process._Popen(process_obj)
return _default_context.get_context().Process._Popen(process_obj)
File "F:\anaconda\envs\python36\lib\multiprocessing\context.py", line 322, in _Popen
File "F:\anaconda\envs\python36\lib\multiprocessing\context.py", line 322, in _Popen
return Popen(process_obj)
File "F:\anaconda\envs\python36\lib\multiprocessing\popen_spawn_win32.py", line 65, in init
return Popen(process_obj)
File "F:\anaconda\envs\python36\lib\multiprocessing\popen_spawn_win32.py", line 33, in init
reduction.dump(process_obj, to_child)
File "F:\anaconda\envs\python36\lib\multiprocessing\reduction.py", line 60, in dump
prep_data = spawn.get_preparation_data(process_obj._name)
File "F:\anaconda\envs\python36\lib\multiprocessing\spawn.py", line 143, in get_preparation_data
_check_not_importing_main()
File "F:\anaconda\envs\python36\lib\multiprocessing\spawn.py", line 136, in _check_not_importing_main
is not going to be frozen to produce an executable.''')
RuntimeError:
An attempt has been made to start a new process before the
current process has finished its bootstrapping phase.
This probably means that you are not using fork to start your
child processes 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 an executable.
ForkingPickler(file, protocol).dump(obj)
BrokenPipeError: [Errno 32] Broken pipe
Class Images Targets P R mAP F1: 0%| | 0/108 [00:00<?, ?it/s]
Class Images Targets P R mAP F1: 0%| | 0/108 [00:02<?, ?it/s]
您好作者,我已经勉强的解决了该问题,问题可能是在两个地方的线程抢占,导致了错误,我一开始将错误语句放在main()中保护起来还是出现了莫名的错误,后来我将test.py中Dateloder模块的num_works从一开始min([os.cpu_count(), batch_size, 16],改成0,让图像可以在主线程读取,解决了这个问题,这样想想也有可能是我电脑本身的问题?
win10 将test.py中Dateloder模块的num_works从一开始min([os.cpu_count(), batch_size, 16],改成0
不用改成单线程,加上if name == 'main':即可
我也遇到同样的问题,请问是在哪里加上if name == 'main': 呢?