Skip to content

[BUG] AssertionError: daemonic processes are not allowed to have children #3198

@lmBored

Description

@lmBored

Describe the bug

When using benchmarl and setting parallel_collection to True, I get this error

To Reproduce

Set parallel_collection to True when creating experiment with benchmarl, environment created with vizdoom

Process _ProcessNoWarn-11:
Traceback (most recent call last):
  File "/lib/python3.12/multiprocessing/process.py", line 314, in _bootstrap
    self.run()
  File ".venv/lib/python3.12/site-packages/torchrl/_utils.py", line 789, in run
    return mp.Process.run(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/python3.12/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File ".venv/lib/python3.12/site-packages/torchrl/envs/batched_envs.py", line 2373, in _run_worker_pipe_shared_mem
    env = env_fun(**env_fun_kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "ViZDoom/.venv/lib/python3.12/site-packages/torchrl/envs/env_creator.py", line 201, in __call__
    env = self.create_env_fn(**kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "ViZDoom/.venv/lib/python3.12/site-packages/torchrl/data/utils.py", line 260, in __call__
    return self.fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "ViZDoom/examples/python/train_multi_agent_extensive.py", line 188, in _make
    pz_env = make(
             ^^^^^
  File "ViZDoom/pettingzoo_wrapper/__init__.py", line 44, in make
    env = VizdoomParallelEnv(
          ^^^^^^^^^^^^^^^^^^^
  File "ViZDoom/pettingzoo_wrapper/base_pettingzoo_env.py", line 341, in __init__
    p.start()
  File "/lib/python3.12/multiprocessing/process.py", line 118, in start
    assert not _current_process._config.get('daemon'), \
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: daemonic processes are not allowed to have children

Expected behavior

Returns no errors

Fix proposal

Set process.daemon = False in torchrl/envs/batched_envs.py

Screenshots

The log output above is also what I want to attach in the screenshot

System info

Describe the characteristic of your environment:

  • Installed with uv
  • Python version: 3.12.3
  • Torchrl: 0.8.1
  • Benchmarl: Latest version from github
  • Torch: 2.8.0
  • Vizdoom: 1.2.4
  • numpy: 2.2.6
  • Platform: [Clang 17.0.6 ] darwin

Additional context

I was able to fix it myself, but report as an issue to verify if this is case-specific or torchrl issue.

Reason and Possible fixes

So basically in my MARL setup, Benchmarl worker is trying to create child processes, but Python enforces only non-daemonic processes can do that, thus causing the issue.

Checklist

  • [ x ] I have checked that there is no similar issue in the repo (required)
  • [ x ] I have read the documentation (required)
  • [ x ] I have provided a minimal working example to reproduce the bug (required)

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions