Open PL-EduardoSanchez opened 1 year ago
:tada: Welcome to PyMC! :tada: We're really excited to have your input into the project! :sparkling_heart:
If you haven't done so already, please make sure you check out our Contributing Guidelines and Code of Conduct.
Is this caused by the parallelization? Does it work otherwise?
Otherwise it works, so most likely has to do with the parallelisation. Actually, I've got roughly 750 combinations and it collapses typically around 600.
By the way, for the record, funnily enough, I just run the code from VS Code in interactive mode and it worked...
Can you report the whole traceback?
Indeed. It's a little bit messy; my feeling is that this is because, as I'm parallelising, when the code collapses there're several pm.sample()
running in parallel and we get somehow several errors in parallel. Anyway, here it is:
ERROR (pytensor.graph.rewriting.basic): Rewrite failure due to: constant_folding ERROR (pytensor.graph.rewriting.basic): node: Sum{axes=None}([3.5835189 ... .98898405]) ERROR (pytensor.graph.rewriting.basic): TRACEBACK: ERROR (pytensor.graph.rewriting.basic): Rewrite failure due to: constant_folding ERROR (pytensor.graph.rewriting.basic): node: Log(likelihood{[ 15. 74. ... 47. 65.]}) ERROR (pytensor.graph.rewriting.basic): TRACEBACK: ERROR (pytensor.graph.rewriting.basic): Rewrite failure due to: constant_folding ERROR (pytensor.graph.rewriting.basic): Rewrite failure due to: constant_folding ERROR (pytensor.graph.rewriting.basic): Traceback (most recent call last): File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\graph\rewriting\basic.py", line 1914, in process_node replacements = node_rewriter.transform(fgraph, node) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\graph\rewriting\basic.py", line 1074, in transform return self.fn(fgraph, node) ^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\tensor\rewriting\basic.py", line 1138, in constant_folding thunk = node.op.make_thunk(node, storage_map, compute_map, no_recycling=[]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\link\c\op.py", line 131, in make_thunk return self.make_c_thunk(node, storage_map, compute_map, no_recycling) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\link\c\op.py", line 96, in make_c_thunk outputs = cl.make_thunk( ^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\link\c\basic.py", line 1200, in make_thunk cthunk, module, in_storage, out_storage, error_storage = self.compile( ^^^^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\link\c\basic.py", line 1120, in compile thunk, module = self.cthunk_factory( ^^^^^^^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\link\c\basic.py", line 1644, in cthunk_factory module = cache.module_from_key(key=key, lnk=self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\link\c\cmodule.py", line 1206, in module_from_key module = self._get_from_hash(module_hash, key) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\link\c\cmodule.py", line 1109, in _get_from_hash with lock_ctx(): File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\contextlib.py", line 137, in enter return next(self.gen) ^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\compile\compilelock.py", line 74, in lock_ctx fl.acquire(timeout=timeout) File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\filelock_api.py", line 222, in acquire raise Timeout(lock_filename) # noqa: TRY301 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ filelock._error.Timeout: The file lock 'C:\Users\EDUARDO\AppData\Local\PyTensor\compiledir_Windows-10-10.0.19045-SP0-Intel64_Family_6_Model_158_Stepping_13_GenuineIntel-3.11.4-64.lock' could not be acquired.
ERROR (pytensor.graph.rewriting.basic): node: Mul([-1.], likelihood{[ 77. 14. ... 25. 52.]}, [1.]) ERROR (pytensor.graph.rewriting.basic): TRACEBACK: ERROR (pytensor.graph.rewriting.basic): node: Mul([2.6390573 ... .73766962], [1.]) ERROR (pytensor.graph.rewriting.basic): Traceback (most recent call last): File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\graph\rewriting\basic.py", line 1914, in process_node replacements = node_rewriter.transform(fgraph, node) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\graph\rewriting\basic.py", line 1074, in transform return self.fn(fgraph, node) ^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\tensor\rewriting\basic.py", line 1138, in constant_folding thunk = node.op.make_thunk(node, storage_map, compute_map, no_recycling=[]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\link\c\op.py", line 131, in make_thunk return self.make_c_thunk(node, storage_map, compute_map, no_recycling) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\link\c\op.py", line 96, in make_c_thunk outputs = cl.make_thunk( ^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\link\c\basic.py", line 1200, in make_thunk cthunk, module, in_storage, out_storage, error_storage = self.compile( ^^^^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\link\c\basic.py", line 1120, in compile thunk, module = self.cthunk_factory( ^^^^^^^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\link\c\basic.py", line 1644, in cthunk_factory module = cache.module_from_key(key=key, lnk=self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\link\c\cmodule.py", line 1206, in module_from_key module = self._get_from_hash(module_hash, key) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\link\c\cmodule.py", line 1109, in _get_from_hash with lock_ctx(): File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\contextlib.py", line 137, in enter return next(self.gen) ^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\compile\compilelock.py", line 74, in lock_ctx fl.acquire(timeout=timeout) File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\filelock_api.py", line 222, in acquire raise Timeout(lock_filename) # noqa: TRY301 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ filelock._error.Timeout: The file lock 'C:\Users\EDUARDO\AppData\Local\PyTensor\compiledir_Windows-10-10.0.19045-SP0-Intel64_Family_6_Model_158_Stepping_13_GenuineIntel-3.11.4-64.lock' could not be acquired.
ERROR (pytensor.graph.rewriting.basic): TRACEBACK: ERROR (pytensor.graph.rewriting.basic): Traceback (most recent call last): File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\graph\rewriting\basic.py", line 1914, in process_node replacements = node_rewriter.transform(fgraph, node) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\graph\rewriting\basic.py", line 1074, in transform return self.fn(fgraph, node) ^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\tensor\rewriting\basic.py", line 1138, in constant_folding thunk = node.op.make_thunk(node, storage_map, compute_map, no_recycling=[]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\link\c\op.py", line 131, in make_thunk return self.make_c_thunk(node, storage_map, compute_map, no_recycling) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\link\c\op.py", line 96, in make_c_thunk outputs = cl.make_thunk( ^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\link\c\basic.py", line 1200, in make_thunk cthunk, module, in_storage, out_storage, error_storage = self.compile( ^^^^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\link\c\basic.py", line 1120, in compile thunk, module = self.cthunk_factory( ^^^^^^^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\link\c\basic.py", line 1644, in cthunk_factory module = cache.module_from_key(key=key, lnk=self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\link\c\cmodule.py", line 1206, in module_from_key module = self._get_from_hash(module_hash, key) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\link\c\cmodule.py", line 1109, in _get_from_hash with lock_ctx(): File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\contextlib.py", line 137, in enter return next(self.gen) ^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\compile\compilelock.py", line 74, in lock_ctx fl.acquire(timeout=timeout) File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\filelock_api.py", line 222, in acquire raise Timeout(lock_filename) # noqa: TRY301 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ filelock._error.Timeout: The file lock 'C:\Users\EDUARDO\AppData\Local\PyTensor\compiledir_Windows-10-10.0.19045-SP0-Intel64_Family_6_Model_158_Stepping_13_GenuineIntel-3.11.4-64.lock' could not be acquired.
Sampling 2 chains for 1_000 tune and 2_000 draw iterations (2_000 + 4_000 draws total) took 672 seconds. Sequential sampling (2 chains in 1 job) ERROR (pytensor.graph.rewriting.basic): Traceback (most recent call last): File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\graph\rewriting\basic.py", line 1914, in process_node replacements = node_rewriter.transform(fgraph, node) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\graph\rewriting\basic.py", line 1074, in transform return self.fn(fgraph, node) ^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\tensor\rewriting\basic.py", line 1138, in constant_folding thunk = node.op.make_thunk(node, storage_map, compute_map, no_recycling=[]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\link\c\op.py", line 131, in make_thunk return self.make_c_thunk(node, storage_map, compute_map, no_recycling) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\link\c\op.py", line 96, in make_c_thunk outputs = cl.make_thunk( ^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\link\c\basic.py", line 1200, in make_thunk cthunk, module, in_storage, out_storage, error_storage = self.compile( ^^^^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\link\c\basic.py", line 1120, in compile thunk, module = self.cthunk_factory( ^^^^^^^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\link\c\basic.py", line 1644, in cthunk_factory module = cache.module_from_key(key=key, lnk=self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\link\c\cmodule.py", line 1206, in module_from_key module = self._get_from_hash(module_hash, key) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\link\c\cmodule.py", line 1109, in _get_from_hash with lock_ctx(): File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\contextlib.py", line 137, in enter return next(self.gen) ^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\compile\compilelock.py", line 74, in lock_ctx fl.acquire(timeout=timeout) File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\filelock_api.py", line 222, in acquire raise Timeout(lock_filename) # noqa: TRY301 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ filelock._error.Timeout: The file lock 'C:\Users\EDUARDO\AppData\Local\PyTensor\compiledir_Windows-10-10.0.19045-SP0-Intel64_Family_6_Model_158_Stepping_13_GenuineIntel-3.11.4-64.lock' could not be acquired.
NUTS: [alpha, theta] ERROR (pytensor.graph.rewriting.basic): Rewrite failure due to: constant_folding ERROR (pytensor.graph.rewriting.basic): node: Mul([-1.], likelihood{[ 14. 35. ... 56. 42.]}, [1.]) ERROR (pytensor.graph.rewriting.basic): TRACEBACK: ERROR (pytensor.graph.rewriting.basic): Traceback (most recent call last): File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\graph\rewriting\basic.py", line 1914, in process_node replacements = node_rewriter.transform(fgraph, node) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\graph\rewriting\basic.py", line 1074, in transform return self.fn(fgraph, node) ^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\tensor\rewriting\basic.py", line 1138, in constant_folding thunk = node.op.make_thunk(node, storage_map, compute_map, no_recycling=[]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\link\c\op.py", line 131, in make_thunk return self.make_c_thunk(node, storage_map, compute_map, no_recycling) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\link\c\op.py", line 96, in make_c_thunk outputs = cl.make_thunk( ^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\link\c\basic.py", line 1200, in make_thunk cthunk, module, in_storage, out_storage, error_storage = self.compile( ^^^^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\link\c\basic.py", line 1120, in compile thunk, module = self.cthunk_factory( ^^^^^^^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\link\c\basic.py", line 1644, in cthunk_factory module = cache.module_from_key(key=key, lnk=self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\link\c\cmodule.py", line 1206, in module_from_key module = self._get_from_hash(module_hash, key) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\link\c\cmodule.py", line 1120, in _get_from_hash self.check_key(key, key_data.key_pkl) File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\link\c\cmodule.py", line 1290, in check_key key_data = pickle.load(f) ^^^^^^^^^^^^^^ _pickle.UnpicklingError: invalid load key, '3'.
We recommend running at least 4 chains for robust computation of convergence diagnostics Sampling: [likelihood] ERROR (pytensor.graph.rewriting.basic): Rewrite failure due to: constant_folding ERROR (pytensor.graph.rewriting.basic): node: Mul([-1.], likelihood{[ 14. 35. ... 56. 42.]}, [1.]) ERROR (pytensor.graph.rewriting.basic): TRACEBACK: ERROR (pytensor.graph.rewriting.basic): Traceback (most recent call last): File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\graph\rewriting\basic.py", line 1914, in process_node replacements = node_rewriter.transform(fgraph, node) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\graph\rewriting\basic.py", line 1074, in transform return self.fn(fgraph, node) ^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\tensor\rewriting\basic.py", line 1138, in constant_folding thunk = node.op.make_thunk(node, storage_map, compute_map, no_recycling=[]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\link\c\op.py", line 131, in make_thunk return self.make_c_thunk(node, storage_map, compute_map, no_recycling) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\link\c\op.py", line 96, in make_c_thunk outputs = cl.make_thunk( ^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\link\c\basic.py", line 1200, in make_thunk cthunk, module, in_storage, out_storage, error_storage = self.compile( ^^^^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\link\c\basic.py", line 1120, in compile thunk, module = self.cthunk_factory( ^^^^^^^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\link\c\basic.py", line 1644, in cthunk_factory module = cache.module_from_key(key=key, lnk=self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\link\c\cmodule.py", line 1206, in module_from_key module = self._get_from_hash(module_hash, key) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\link\c\cmodule.py", line 1111, in _get_from_hash key_data.add_key(key, save_pkl=bool(key[0])) File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\link\c\cmodule.py", line 544, in add_key assert key not in self.keys ^^^^^^^^^^^^^^^^^^^^ AssertionError
ERROR (pytensor.graph.rewriting.basic): Rewrite failure due to: constant_folding ERROR (pytensor.graph.rewriting.basic): node: Sum{axes=None}([-36. -29. ... -64. -54.]) ERROR (pytensor.graph.rewriting.basic): TRACEBACK: ERROR (pytensor.graph.rewriting.basic): Traceback (most recent call last): File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\graph\rewriting\basic.py", line 1914, in process_node replacements = node_rewriter.transform(fgraph, node) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\graph\rewriting\basic.py", line 1074, in transform return self.fn(fgraph, node) ^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\tensor\rewriting\basic.py", line 1138, in constant_folding thunk = node.op.make_thunk(node, storage_map, compute_map, no_recycling=[]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\link\c\op.py", line 131, in make_thunk return self.make_c_thunk(node, storage_map, compute_map, no_recycling) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\link\c\op.py", line 96, in make_c_thunk outputs = cl.make_thunk( ^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\link\c\basic.py", line 1200, in make_thunk cthunk, module, in_storage, out_storage, error_storage = self.compile( ^^^^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\link\c\basic.py", line 1120, in compile thunk, module = self.cthunk_factory( ^^^^^^^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\link\c\basic.py", line 1644, in cthunk_factory module = cache.module_from_key(key=key, lnk=self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\link\c\cmodule.py", line 1206, in module_from_key module = self._get_from_hash(module_hash, key) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\link\c\cmodule.py", line 1120, in _get_from_hash self.check_key(key, key_data.key_pkl) File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\pytensor\link\c\cmodule.py", line 1290, in check_key key_data = pickle.load(f) ^^^^^^^^^^^^^^ _pickle.UnpicklingError: state is not a dictionary
Auto-assigning NUTS sampler...
Initializing NUTS using jitter+adapt_diag...
joblib.externals.loky.process_executor._RemoteTraceback:
"""
Traceback (most recent call last):
File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\joblib\externals\loky\process_executor.py", line 463, in _process_worker
r = call_item()
^^^^^^^^^^^
File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\joblib\externals\loky\process_executor.py", line 291, in call
return self.fn(*self.args, self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\joblib\parallel.py", line 588, in call
return [func(*args, *kwargs)
^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\EDUARDO\anaconda3\envs\myproject-hierarchical-models\Lib\site-packages\joblib\parallel.py", line 588, in
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\EDUARDO\Documents\repos\myclient-myproject\dev\hierarchical_models.py", line 159, in
Looks like a timeout due to the locking mechanism of the c compilation in PyTensor.
Pinging @ferrine @lucianopaz to see if they have any advice. I think this is a known limitation of PyTensor.
Taking a step back, what are you trying to achieve exactly? Run the same model on different datasets?
Taking a step back, what are you trying to achieve exactly? Run the same model on different datasets?
Indeed, this is what I'm doing.
This is a known limitation (compile/cache lock), I suggest to use https://github.com/pymc-devs/nutpie, specifically compiled_model.with_data(...)
Thank you very much, @ferrine. I'll take a look at this solution.
@PL-EduardoSanchez, Did you find the solution to this issue? I am getting the same error when running the model on different datasets in parallel.
I also tried increasing the compile_timeout of the PyTensor mentioned here, but it didn't work.
Hi @kshhhv. I tried with "nutpie", with compiled_model()
, but I got the same kinds of problems.
@PL-EduardoSanchez @kshhhv , I came across the same issue upon using Pymc in multiple processes.
After quite some trial and error, including several interesting solutions, I found here, and in other related threads (compile_timeout, reinstalling packages using special directives, etc.), I was eventually able to find a working solution by deleting the temp directory that interrupts pytensor compilation.
So, in @PL-EduardoSanchez 's case, given the error:
filelock._error.Timeout: The file lock 'C:\Users\EDUARDO\AppData\Local\PyTensor\compiledir_Windows-10-10.0.19045-SP0-Intel64_Family_6_Model_158_Stepping_13_GenuineIntel-3.11.4-64.lock' could not be acquired.
try deleting the 'compiledir_Windows-10-10.0.19045-SP0-Intel64_Family_6_Model_158_Stepping_13_GenuineIntel-3.11.4-64' sub-directory. I'm not sure whether this will solve your issue but it's worth a try.
Thank you very much, @isilber. Currently I'm not actively working on the project where I used "pymc", but I'll give it a try in the future.
I was having the same issue until trying the solution proposed by @isilber. So far, that seems to have worked. Thank you @isilber, lifesaver!!
Thanks, @philpatton. A quick update. This method started to fail once I spawned 100 processes simultaneously, but I came up with a robust automated workaround by specifying different compilation directories for PyTensor for each process, which is the source of this issue, and deleting the directory if it already exists. This would look something like the following as part of a bash script:
for i in {1..100..1}
do
RUN_NUM=i
COMP_DIR="/path/to/.pytensor_compiles"
COMP_FORM="compiledir_$((RUN_NUM))_mcmc" # compilation directory name format
PYT_FLG="PYTENSOR_FLAGS='compiledir_format=${COMP_FORM},base_compiledir=${COMP_DIR}'" # PyTensor flags
RUN_STR=" python pymc_script_name.py $((RUN_NUM))&"
RUN_COM=$PYT_FLG$RUN_STR # command string
if [ -d "$COMP_DIR/$COMP_FORM" ]
then
# delete the zombie directory
rm -r "$COMP_DIR/$COMP_FORM"
fi
eval "$RUN_COM" # Run command string
done
Any ideas on how you would apply this solution when you are applying the multiprocessing in python rather than bash? I have some pre-fitting data in python dictionary format that is identical for all runs to the point where running them each separately on bash doesn't make sense.
The relevant multiprocessing code is below:
import multiprocessing as mp
pool = mp.Pool(cpu_num)
res = pool.starmap(
fit_routine,
[(i, config, pad_dict) for i in mpargs.items()]
)
pool.close()
fit_rountine
is the fitting function and the (i, config, pad_dict) for i in mpargs.items()]
refers to the arguments for the fitting function
Thank you for any guidance!
@Hope2925 you could write a python script that loads the dictionary then samples, then call that in bash. This is roughly how I run things, except I need to use SLURM on our cluster. But all the python code goes in a python script that's called in a bash script. (You need to write the trace to a file in the python script.)
There's probably a way to set environment variables in multiprocessing, but I'm not familiar with it. Maybe the function you pass to the worker could use 'os.environ' to set the environment variables. Basically you want to set the values from PYT_FLAG as environment variables.
Describe the issue:
Given a table with three columns X1, X2, and Y, I am trying to get independent Bayesian models for the variable Y for each value of X1 and X2. This is why I'm trying to parallelise the MCMC sampling with Parallel+delayed from joblib (see code below). In principle the workflow runs smoothly, but at some point, in principle at random, the code collapses (see the error message below).
For the record, I am running the process as a python script from my terminal like this:
If you need more details, please, let me know.
Thanks in advance!
Best,
Eduardo
Reproduceable code example:
Error message:
PyMC version information:
pymc: 5.5.0 pytensor: 2.12.3 python: 3.11.4 OS: Windows 10 Installation: With conda (see code below)
Context for the issue:
I think it would be very convenient to be able to run in parallel a bunch of different Bayesian models to save some computation time.