rl icon indicating copy to clipboard operation
rl copied to clipboard

Bug: ValueError: cannot find context for 'fork' breaks 10 tutorials on Windows

Open coder-jayp opened this issue 3 months ago • 1 comments

Describe the bug

When running the TorchRL tutorials on Windows, the scripts crash immediately with a ValueError. This happens because the tutorials explicitly attempt to set the multiprocessing start method to "fork", but the "fork" method is not supported on Windows (which only supports "spawn").

This affects 10 different tutorials in the tutorials/sphinx-tutorials/ directory that all hardcode multiprocessing.set_start_method("fork").

The affected files are:

  1. coding_ppo.py
  2. coding_ddpg.py
  3. coding_dqn.py
  4. dqn_with_rnn.py
  5. multi_task.py
  6. pendulum.py
  7. pretrained_models.py
  8. recurrent_sequence_training.py
  9. torchrl_demo.py
  10. torchrl_envs.py

To Reproduce

Steps to reproduce the behavior.

  1. Use a Windows machine.
  2. Clone the pytorch/rl repository.
  3. Run any of the affected tutorial scripts from the root directory.

Expected behavior

The tutorial scripts should run successfully on Windows without crashing due to unsupported multiprocessing start methods.

Screenshots

N/A

System info

Describe the characteristic of your environment:

  • Windows 10 / 11
  • Python 3.12 (also affects other versions on Windows)

Checklist

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

coder-jayp avatar Aug 17 '26 18:08 coder-jayp

/assign

coder-jayp avatar Aug 17 '26 18:08 coder-jayp