You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
When running the file, it appears as:
Auto-assigning NUTS sampler...
Initializing NUTS using jitter+adapt_diag...
Multiprocess sampling (8 chains in 4 jobs)
NUTS: [beta, intercept_0]
Auto-assigning NUTS sampler...
Initializing NUTS using jitter+adapt_diag...
Multiprocess sampling (8 chains in 4 jobs)
NUTS: [beta, intercept_0]
Immediately after that, it shows the runtime error.
This failure appears when running the code directly from conda (base) or inside a conda environment.
I tried running this on a python venv on windows and it also did not work.
When running the same code under a conda environment in Ubuntu24 it worked without any problems.
I have no idea what kind of information is needed to replicate the error. I will try to paste here what I think important.
Windows 11
Version 10.0.22631
Build 22631
Processor i7-11800H
Installed Physical Memory (RAM) 64.0 GB
Reproduceable code example:
importpymcaspmimportnumpyasnpdata=np.array([[ True, False, False, False, False, False, False, False, False,
False, False, False, False, False],
[False, False, False, False, False, False, True, False, False,
False, False, False, False, False],
[False, False, False, False, False, True, False, False, False,
False, False, False, True, False],
[False, False, False, False, False, False, False, False, False,
False, False, False, False, False],
[False, False, False, False, False, False, False, False, False,
False, False, False, False, False]])
# Define the logistic regression modelwithpm.Model() asmodel:
beta=pm.Normal('beta', mu=0, sigma=1, shape=13) # Coefficients for the other 13 products# for i in range(14):i=0# Intercept term (optional)intercept=pm.Normal(f'intercept_{i}', mu=0, sigma=1)
# Define likelihoodp=pm.math.invlogit(intercept+beta.dot(data[:, np.arange(14) !=i].T))
observed=pm.Bernoulli(f'observed_{i}', p=p, observed=data[:, i])
# Sample from the posterior distribution using MCMCtrace=pm.sample(draws=2000, tune=1000, chains=8)
# Plot posterior distributions of the coefficientspm.plot_posterior(trace, var_names=['beta'])
# Compute and print the posterior means and credible intervalsprint(pm.summary(trace, var_names=['beta']))
Error message:
Traceback (most recent call last):
File "<string>", line 1, in<module>
File "C:\Users\52331\anaconda3\envs\pymc_env\lib\multiprocessing\spawn.py", line 116, in spawn_main
exitcode = _main(fd, parent_sentinel)
File "C:\Users\52331\anaconda3\envs\pymc_env\lib\multiprocessing\spawn.py", line 125, in _main
prepare(preparation_data)
File "C:\Users\52331\anaconda3\envs\pymc_env\lib\multiprocessing\spawn.py", line 236, in prepare
_fixup_main_from_path(data['init_main_from_path'])
File "C:\Users\52331\anaconda3\envs\pymc_env\lib\multiprocessing\spawn.py", line 287, in _fixup_main_from_path
main_content = runpy.run_path(main_path,
File "C:\Users\52331\anaconda3\envs\pymc_env\lib\runpy.py", line 289, in run_path
return _run_module_code(code, init_globals, run_name,
File "C:\Users\52331\anaconda3\envs\pymc_env\lib\runpy.py", line 96, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "C:\Users\52331\anaconda3\envs\pymc_env\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "C:\Users\52331\Documents\GitHub\marlitros\minimum_reproducible_error.py", line 29, in<module>
trace = pm.sample(draws=2000, tune=1000, chains=8)
File "C:\Users\52331\anaconda3\envs\pymc_env\lib\site-packages\pymc\sampling\mcmc.py", line 808, in sample
_mp_sample(**sample_args, **parallel_args)
File "C:\Users\52331\anaconda3\envs\pymc_env\lib\site-packages\pymc\sampling\mcmc.py", line 1186, in _mp_sample
sampler = ps.ParallelSampler(
File "C:\Users\52331\anaconda3\envs\pymc_env\lib\site-packages\pymc\sampling\parallel.py", line 405, in __init__
self._samplers = [
File "C:\Users\52331\anaconda3\envs\pymc_env\lib\site-packages\pymc\sampling\parallel.py", line 406, in<listcomp>
ProcessAdapter(
File "C:\Users\52331\anaconda3\envs\pymc_env\lib\site-packages\pymc\sampling\parallel.py", line 261, in __init__
self._process.start()
File "C:\Users\52331\anaconda3\envs\pymc_env\lib\multiprocessing\process.py", line 121, in start
self._popen = self._Popen(self)
File "C:\Users\52331\anaconda3\envs\pymc_env\lib\multiprocessing\context.py", line 336, in _Popen
return Popen(process_obj)
File "C:\Users\52331\anaconda3\envs\pymc_env\lib\multiprocessing\popen_spawn_win32.py", line 45, in __init__
prep_data = spawn.get_preparation_data(process_obj._name)
File "C:\Users\52331\anaconda3\envs\pymc_env\lib\multiprocessing\spawn.py", line 154, in get_preparation_data
_check_not_importing_main()
File "C:\Users\52331\anaconda3\envs\pymc_env\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.
Describe the issue:
RuntimeError:
An attempt has been made to start a new process before the
current process has finished its bootstrapping phase.
When running the file, it appears as:
Auto-assigning NUTS sampler...
Initializing NUTS using jitter+adapt_diag...
Multiprocess sampling (8 chains in 4 jobs)
NUTS: [beta, intercept_0]
Auto-assigning NUTS sampler...
Initializing NUTS using jitter+adapt_diag...
Multiprocess sampling (8 chains in 4 jobs)
NUTS: [beta, intercept_0]
Immediately after that, it shows the runtime error.
This failure appears when running the code directly from conda (base) or inside a conda environment.
I tried running this on a python venv on windows and it also did not work.
When running the same code under a conda environment in Ubuntu24 it worked without any problems.
I have no idea what kind of information is needed to replicate the error. I will try to paste here what I think important.
conda 24.4.0
arviz 0.18.0
mkl 2023.2.0
numpy 1.26.4
pandas 2.2.2
pymc 5.14.0
pytensor 2.20.0
Windows 11
Version 10.0.22631
Build 22631
Processor i7-11800H
Installed Physical Memory (RAM) 64.0 GB
Reproduceable code example:
Error message:
PyMC version information:
conda create -c conda-forge -n pymc_env "pymc>=5"
conda activate pymc_env
Context for the issue:
Nothing could run in windows :(
The text was updated successfully, but these errors were encountered: