[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When running python train_cifar10.py, RuntimeError: An attempt has been made to start a new process before the current process has finished its bootstrapping phase. #267

Closed
laserljy opened this issue May 21, 2023 · 0 comments

Comments

@laserljy
Copy link

Hi, I am trying your code, in Win10 OS, PyCharm 2022.
When using cmd python train_cifar10.py in terminal, I got the following error message.
Would you please help answer, thanks!

K:\anaconda3\envs\vit_cifar10\python.exe train_cifar10.py
'stty' is not recognized as an internal or external command,
operable program or batch file.
wandb: Currently logged in as: lijiyinglaser. Use wandb login --relogin to force relogin
wandb: Tracking run with wandb version 0.15.3
wandb: Run data is saved locally in D:\Repos\vision-transformers-cifar10\wandb\run-20230520_235205-twxr012g
wandb: Run wandb offline to turn off syncing.
wandb: Syncing run vit_lr0.0001
wandb: View project at https://wandb.ai/lijiyinglaser/cifar10-challange
wandb: View run at https://wandb.ai/lijiyinglaser/cifar10-challange/runs/twxr012g
==> Preparing data..
Files already downloaded and verified
Files already downloaded and verified
==> Building model..
cuda
using data parallel
Epoch: 0
'stty' is not recognized as an internal or external command,
operable program or batch file.
wandb: Currently logged in as: lijiyinglaser. Use wandb login --relogin to force relogin
wandb: Tracking run with wandb version 0.15.3
wandb: Run data is saved locally in D:\Repos\vision-transformers-cifar10\wandb\run-20230520_235228-3ccuigga
wandb: Run wandb offline to turn off syncing.
wandb: Syncing run vit_lr0.0001
wandb: View project at https://wandb.ai/lijiyinglaser/cifar10-challange
wandb: View run at https://wandb.ai/lijiyinglaser/cifar10-challange/runs/3ccuigga
==> Preparing data..
Files already downloaded and verified
Files already downloaded and verified
==> Building model..
cuda
using data parallel
Epoch: 0
Traceback (most recent call last):
File "", line 1, in
File "K:\anaconda3\envs\vit_cifar10\lib\multiprocessing\spawn.py", line 116, in spawn_main
exitcode = _main(fd, parent_sentinel)
File "K:\anaconda3\envs\vit_cifar10\lib\multiprocessing\spawn.py", line 125, in _main
prepare(preparation_data)
File "K:\anaconda3\envs\vit_cifar10\lib\multiprocessing\spawn.py", line 236, in prepare
_fixup_main_from_path(data['init_main_from_path'])
File "K:\anaconda3\envs\vit_cifar10\lib\multiprocessing\spawn.py", line 287, in _fixup_main_from_path
main_content = runpy.run_path(main_path,
File "K:\anaconda3\envs\vit_cifar10\lib\runpy.py", line 289, in run_path
return _run_module_code(code, init_globals, run_name,
File "K:\anaconda3\envs\vit_cifar10\lib\runpy.py", line 96, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "K:\anaconda3\envs\vit_cifar10\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "D:\Repos\vision-transformers-cifar10\train_cifar10.py", line 328, in
trainloss = train(epoch)
File "D:\Repos\vision-transformers-cifar10\train_cifar10.py", line 259, in train
for batch_idx, (inputs, targets) in enumerate(trainloader):
File "K:\anaconda3\envs\vit_cifar10\lib\site-packages\torch\utils\data\dataloader.py", line 441, in iter
return self._get_iterator()
File "K:\anaconda3\envs\vit_cifar10\lib\site-packages\torch\utils\data\dataloader.py", line 388, in _get_iterator
return _MultiProcessingDataLoaderIter(self)
File "K:\anaconda3\envs\vit_cifar10\lib\site-packages\torch\utils\data\dataloader.py", line 1042, in init
w.start()
File "K:\anaconda3\envs\vit_cifar10\lib\multiprocessing\process.py", line 121, in start
self._popen = self._Popen(self)
File "K:\anaconda3\envs\vit_cifar10\lib\multiprocessing\context.py", line 224, in _Popen
return _default_context.get_context().Process._Popen(process_obj)
File "K:\anaconda3\envs\vit_cifar10\lib\multiprocessing\context.py", line 336, in _Popen
return Popen(process_obj)
File "K:\anaconda3\envs\vit_cifar10\lib\multiprocessing\popen_spawn_win32.py", line 45, in init
prep_data = spawn.get_preparation_data(process_obj._name)
File "K:\anaconda3\envs\vit_cifar10\lib\multiprocessing\spawn.py", line 154, in get_preparation_data
_check_not_importing_main()
File "K:\anaconda3\envs\vit_cifar10\lib\multiprocessing\spawn.py", line 134, 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.
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant