pytorch / pytorch/rl

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

Open
#4,122 1 comment 0 reactions 1 assignee View on GitHub

@vmoens is already working on this.

Since Aug 17, 2026.

bug
Dominant language
Python
Stars
3.6k
Forks
487
Avg merge
1d 1h
Merged PRs (30d)
207

Description

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

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.