I’m a beginner, and when I run a program on a book on jupyter notebook, I get a problem with having to label the cores=1 to sample, otherwise something will go wrong: RuntimeError: The pipe pipe process and its spawned children is broken.
What should I do, please? Thank you for your busy guidance
such as:
with model:
step1 = pm.Metropolis(vars=[p, sds, centers])
step2 = pm.ElemwiseCategorical(vars=[assignment])
trace = pm.sample(15000, step=[step1, step2])
run error is:
BrokenPipeError Traceback (most recent call last)
D:\ProgramData\Anaconda3\lib\site-packages\pymc3\parallel_sampling.py in init(self, draws, tune, step_method, chain, seed, start)
241 try:
–> 242 self._process.start()
243 except IOError as e:
D:\ProgramData\Anaconda3\lib\multiprocessing\process.py in start(self)
111 _cleanup()
–> 112 self._popen = self._Popen(self)
113 self._sentinel = self._popen.sentinel
D:\ProgramData\Anaconda3\lib\multiprocessing\context.py in _Popen(process_obj)
222 def _Popen(process_obj):
–> 223 return _default_context.get_context().Process._Popen(process_obj)
224
D:\ProgramData\Anaconda3\lib\multiprocessing\context.py in _Popen(process_obj)
321 from .popen_spawn_win32 import Popen
–> 322 return Popen(process_obj)
323
D:\ProgramData\Anaconda3\lib\multiprocessing\popen_spawn_win32.py in init(self, process_obj)
88 reduction.dump(prep_data, to_child)
—> 89 reduction.dump(process_obj, to_child)
90 finally:
D:\ProgramData\Anaconda3\lib\multiprocessing\reduction.py in dump(obj, file, protocol)
59 ‘’‘Replacement for pickle.dump() using ForkingPickler.’’’
—> 60 ForkingPickler(file, protocol).dump(obj)
61
BrokenPipeError: [Errno 32] Broken pipe
During handling of the above exception, another exception occurred:
RuntimeError Traceback (most recent call last)
in
2 step1 = pm.Metropolis(vars=[p, sds, centers])
3 step2 = pm.ElemwiseCategorical(vars=[assignment])
----> 4 trace = pm.sample(15000, step=[step1, step2])
D:\ProgramData\Anaconda3\lib\site-packages\pymc3\sampling.py in sample(draws, step, init, n_init, start, trace, chain_idx, chains, cores, tune, progressbar, model, random_seed, discard_tuned_samples, compute_convergence_checks, **kwargs)
467 _print_step_hierarchy(step)
468 try:
–> 469 trace = _mp_sample(**sample_args)
470 except pickle.PickleError:
471 _log.warning(“Could not pickle model, sampling singlethreaded.”)
D:\ProgramData\Anaconda3\lib\site-packages\pymc3\sampling.py in _mp_sample(draws, tune, step, chains, cores, chain, random_seed, start, progressbar, trace, model, **kwargs)
1052
1053 sampler = ps.ParallelSampler(
-> 1054 draws, tune, chains, cores, random_seed, start, step, chain, progressbar
1055 )
1056 try:
D:\ProgramData\Anaconda3\lib\site-packages\pymc3\parallel_sampling.py in init(self, draws, tune, chains, cores, seeds, start_points, step_method, start_chain_num, progressbar)
357 draws, tune, step_method, chain + start_chain_num, seed, start
358 )
–> 359 for chain, seed, start in zip(range(chains), seeds, start_points)
360 ]
361
D:\ProgramData\Anaconda3\lib\site-packages\pymc3\parallel_sampling.py in (.0)
357 draws, tune, step_method, chain + start_chain_num, seed, start
358 )
–> 359 for chain, seed, start in zip(range(chains), seeds, start_points)
360 ]
361
D:\ProgramData\Anaconda3\lib\site-packages\pymc3\parallel_sampling.py in init(self, draws, tune, step_method, chain, seed, start)
249 # all its error message
250 time.sleep(0.2)
–> 251 raise exc
252 raise
253
RuntimeError: The communication pipe between the main process and its spawned children is broken.
In Windows OS, this usually means that the child process raised an exception while it was being spawned, before it was setup to communicate to the main process.
The exceptions raised by the child process while spawning cannot be caught or handled from the main process, and when running from an IPython or jupyter notebook interactive kernel, the child’s exception and traceback appears to be lost.
A known way to see the child’s error, and try to fix or handle it, is to run the problematic code as a batch script from a system’s Command Prompt. The child’s exception will be printed to the Command Promt’s stderr, and it should be visible above this error and traceback.
Note that if running a jupyter notebook that was invoked from a Command Prompt, the child’s exception should have been printed to the Command Prompt on which the notebook is running.
and The following code can run until the end of the sampling:
with model:
step1 = pm.Metropolis(vars=[p, sds, centers])
step2 = pm.ElemwiseCategorical(vars=[assignment])
trace = pm.sample(15000, step=[step1, step2],cores=1)
[I 10:47:19.420 NotebookApp] Saving file at /Probabilistic-Programming-and-Bayes
ian-Methods-for-Hackers-master/Chapter3_MCMC/Ch3_IntroMCMC_PyMC3.ipynb
[I 10:49:19.443 NotebookApp] Saving file at /Probabilistic-Programming-and-Bayes
ian-Methods-for-Hackers-master/Chapter3_MCMC/Ch3_IntroMCMC_PyMC3.ipynb
ERROR (theano.gpuarray): Could not initialize pygpu, support disabled
Traceback (most recent call last):
File “D:\ProgramData\Anaconda3\lib\site-packages\theano\gpuarray_init_.py”,
line 227, in
use(config.device)
File “D:\ProgramData\Anaconda3\lib\site-packages\theano\gpuarray_init_.py”,
line 214, in use
init_dev(device, preallocate=preallocate)
File “D:\ProgramData\Anaconda3\lib\site-packages\theano\gpuarray_init_.py”,
line 65, in init_dev
raise RuntimeError(“You can’t initialize the GPU in a subprocess if the pare
nt process already did it”)
RuntimeError: You can’t initialize the GPU in a subprocess if the parent process
already did it
Traceback (most recent call last):
File “”, line 1, in
File “D:\ProgramData\Anaconda3\lib\multiprocessing\spawn.py”, line 105, in spa
wn_main
exitcode = _main(fd)
File “D:\ProgramData\Anaconda3\lib\multiprocessing\spawn.py”, line 115, in _ma
in
self = reduction.pickle.load(from_parent)
File “D:\ProgramData\Anaconda3\lib\site-packages\theano\gpuarray\type.py”, lin
e 899, in GpuArray_unpickler
ctx = get_context(ctx_name)
File “D:\ProgramData\Anaconda3\lib\site-packages\theano\gpuarray\type.py”, lin
e 104, in get_context
raise ContextNotDefined(“context name %s not defined” % (name,))
theano.gpuarray.type.ContextNotDefined: context name None not defined
[I 11:01:19.451 NotebookApp] Saving file at /Probabilistic-Programming-and-Bayes
ian-Methods-for-Hackers-master/Chapter3_MCMC/Ch3_IntroMCMC_PyMC3.ipynb
win7+anaconda_python3.7+theano1.0.4+pymc3 3.8
thank you !