Dear experts
I am practicing with pymc3. Now I am carrying out sampling method in pymc3 with the code following.
import pymc3 as pm
model = pm.Model()
with model:
mu1 = pm.Normal (“mu1”,mu=0,sd=1,shape=10)
with model:
trace =pm.sample(2000)
When I run the this code, it has appeared the error
Auto-assigning NUTS sampler…
Initializing NUTS using jitter+adapt_diag…
Multiprocess sampling (4 chains in 4 jobs)
NUTS: [mu1]
Traceback (most recent call last):
File “”, line 1, in
File “C:\Users\hoaithanh\Anaconda3\lib\multiprocessing\spawn.py”, line 105, in spawn_main
exitcode = _main(fd)
File “C:\Users\hoaithanh\Anaconda3\lib\multiprocessing\spawn.py”, line 114, in _main
Traceback (most recent call last):
File “C:/Users/hoaithanh/Desktop/hocpython/thuproject.py”, line 12, in
prepare(preparation_data)
File “C:\Users\hoaithanh\Anaconda3\lib\multiprocessing\spawn.py”, line 225, in prepare
trace = pm.sample(2000)
File “C:\Users\hoaithanh\Anaconda3\lib\site-packages\pymc3\sampling.py”, line 449, in sample
_fixup_main_from_path(data[‘init_main_from_path’])
File “C:\Users\hoaithanh\Anaconda3\lib\multiprocessing\spawn.py”, line 277, in _fixup_main_from_path
trace = _mp_sample(**sample_args)
File “C:\Users\hoaithanh\Anaconda3\lib\site-packages\pymc3\sampling.py”, line 996, in _mp_sample
run_name=“mp_main”)
File “C:\Users\hoaithanh\Anaconda3\lib\runpy.py”, line 263, in run_path
chain, progressbar)
File “C:\Users\hoaithanh\Anaconda3\lib\site-packages\pymc3\parallel_sampling.py”, line 275, in init
pkg_name=pkg_name, script_name=fname)
File “C:\Users\hoaithanh\Anaconda3\lib\runpy.py”, line 96, in _run_module_code
for chain, seed, start in zip(range(chains), seeds, start_points)
File “C:\Users\hoaithanh\Anaconda3\lib\site-packages\pymc3\parallel_sampling.py”, line 275, in
mod_name, mod_spec, pkg_name, script_name)
File “C:\Users\hoaithanh\Anaconda3\lib\runpy.py”, line 85, in _run_code
for chain, seed, start in zip(range(chains), seeds, start_points)
File “C:\Users\hoaithanh\Anaconda3\lib\site-packages\pymc3\parallel_sampling.py”, line 182, in init
exec(code, run_globals)
File “C:\Users\hoaithanh\Desktop\hocpython\thuproject.py”, line 12, in
self._process.start()
File “C:\Users\hoaithanh\Anaconda3\lib\multiprocessing\process.py”, line 105, in start
trace = pm.sample(2000)
self._popen = self._Popen(self) File “C:\Users\hoaithanh\Anaconda3\lib\site-packages\pymc3\sampling.py”, line 449, in sample
File “C:\Users\hoaithanh\Anaconda3\lib\multiprocessing\context.py”, line 223, in _Popen
return _default_context.get_context().Process._Popen(process_obj)
File “C:\Users\hoaithanh\Anaconda3\lib\multiprocessing\context.py”, line 322, in _Popen
return Popen(process_obj)
File “C:\Users\hoaithanh\Anaconda3\lib\multiprocessing\popen_spawn_win32.py”, line 65, in init
trace = _mp_sample(**sample_args)
File “C:\Users\hoaithanh\Anaconda3\lib\site-packages\pymc3\sampling.py”, line 996, in _mp_sample
reduction.dump(process_obj, to_child)
File “C:\Users\hoaithanh\Anaconda3\lib\multiprocessing\reduction.py”, line 60, in dump
ForkingPickler(file, protocol).dump(obj)
BrokenPipeError: [Errno 32] Broken pipe
chain, progressbar)
File “C:\Users\hoaithanh\Anaconda3\lib\site-packages\pymc3\parallel_sampling.py”, line 275, in init
for chain, seed, start in zip(range(chains), seeds, start_points)
File “C:\Users\hoaithanh\Anaconda3\lib\site-packages\pymc3\parallel_sampling.py”, line 275, in
for chain, seed, start in zip(range(chains), seeds, start_points)
File “C:\Users\hoaithanh\Anaconda3\lib\site-packages\pymc3\parallel_sampling.py”, line 182, in init
self._process.start()
File “C:\Users\hoaithanh\Anaconda3\lib\multiprocessing\process.py”, line 105, in start
self._popen = self._Popen(self)
File “C:\Users\hoaithanh\Anaconda3\lib\multiprocessing\context.py”, line 223, in _Popen
return _default_context.get_context().Process._Popen(process_obj)
File “C:\Users\hoaithanh\Anaconda3\lib\multiprocessing\context.py”, line 322, in _Popen
return Popen(process_obj)
File “C:\Users\hoaithanh\Anaconda3\lib\multiprocessing\popen_spawn_win32.py”, line 33, in init
prep_data = spawn.get_preparation_data(process_obj._name)
File “C:\Users\hoaithanh\Anaconda3\lib\multiprocessing\spawn.py”, line 143, in get_preparation_data
_check_not_importing_main()
File “C:\Users\hoaithanh\Anaconda3\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.
Process finished with exit code 1
I want to konw what is this error? and how to fix it ? I also try to run the code in the getting started guide but it too.
please help me !!!
Thanks you