An offical implementation of PatchTST: "A Time Series is Worth 64 Words: Long-term Forecasting with Transformers." (ICLR 2023) https://arxiv.org/abs/2211.14730
Apache License 2.0
1.37k
stars
248
forks
source link
RuntimeError on Mac trying python multiprocessing #56
Hi, thanks for the valuable work! While following the README, I encountered one issue and fixed it according to this StackOverflow answer. Just wanted to share this with others!
$sh ./scripts/PatchTST/etth1.sh
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Users/dorothyko/miniconda3/envs/patchtst/lib/python3.10/multiprocessing/spawn.py", line 116, in spawn_main
exitcode = _main(fd, parent_sentinel)
File "/Users/dorothyko/miniconda3/envs/patchtst/lib/python3.10/multiprocessing/spawn.py", line 125, in _main
prepare(preparation_data)
File "/Users/dorothyko/miniconda3/envs/patchtst/lib/python3.10/multiprocessing/spawn.py", line 236, in prepare
_fixup_main_from_path(data['init_main_from_path'])
File "/Users/dorothyko/miniconda3/envs/patchtst/lib/python3.10/multiprocessing/spawn.py", line 287, in _fixup_main_from_path
main_content = runpy.run_path(main_path,
File "/Users/dorothyko/miniconda3/envs/patchtst/lib/python3.10/runpy.py", line 289, in run_path
return _run_module_code(code, init_globals, run_name,
File "/Users/dorothyko/miniconda3/envs/patchtst/lib/python3.10/runpy.py", line 96, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "/Users/dorothyko/miniconda3/envs/patchtst/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/Users/dorothyko/network-ml/PatchTST/PatchTST_supervised/run_longExp.py", line 139, in <module>
exp.train(setting)
File "/Users/dorothyko/network-ml/PatchTST/PatchTST_supervised/exp/exp_main.py", line 132, in train
for i, (batch_x, batch_y, batch_x_mark, batch_y_mark) in enumerate(train_loader):
File "/Users/dorothyko/miniconda3/envs/patchtst/lib/python3.10/site-packages/torch/utils/data/dataloader.py", line 368, in __iter__
return self._get_iterator()
File "/Users/dorothyko/miniconda3/envs/patchtst/lib/python3.10/site-packages/torch/utils/data/dataloader.py", line 314, in _get_iterator
return _MultiProcessingDataLoaderIter(self)
File "/Users/dorothyko/miniconda3/envs/patchtst/lib/python3.10/site-packages/torch/utils/data/dataloader.py", line 927, in __init__
w.start()
File "/Users/dorothyko/miniconda3/envs/patchtst/lib/python3.10/multiprocessing/process.py", line 121, in start
self._popen = self._Popen(self)
File "/Users/dorothyko/miniconda3/envs/patchtst/lib/python3.10/multiprocessing/context.py", line 224, in _Popen
return _default_context.get_context().Process._Popen(process_obj)
File "/Users/dorothyko/miniconda3/envs/patchtst/lib/python3.10/multiprocessing/context.py", line 288, in _Popen
return Popen(process_obj)
File "/Users/dorothyko/miniconda3/envs/patchtst/lib/python3.10/multiprocessing/popen_spawn_posix.py", line 32, in __init__
super().__init__(process_obj)
File "/Users/dorothyko/miniconda3/envs/patchtst/lib/python3.10/multiprocessing/popen_fork.py", line 19, in __init__
self._launch(process_obj)
File "/Users/dorothyko/miniconda3/envs/patchtst/lib/python3.10/multiprocessing/popen_spawn_posix.py", line 42, in _launch
prep_data = spawn.get_preparation_data(process_obj._name)
File "/Users/dorothyko/miniconda3/envs/patchtst/lib/python3.10/multiprocessing/spawn.py", line 154, in get_preparation_data
_check_not_importing_main()
File "/Users/dorothyko/miniconda3/envs/patchtst/lib/python3.10/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.
Hi, thanks for the valuable work! While following the README, I encountered one issue and fixed it according to this StackOverflow answer. Just wanted to share this with others!
This has been fixed by https://stackoverflow.com/questions/18204782/runtimeerror-on-windows-trying-python-multiprocessing
If needed, I can send out a fixup PR for this.