Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[examples] fix multiprocessing on Linux #39

Merged
merged 2 commits into from
Dec 24, 2023

Conversation

GradientSurfer
Copy link
Contributor

@GradientSurfer GradientSurfer commented Dec 24, 2023

  1. use multiprocessing context to specify the "spawn" start method, which fixes the RuntimeError: Cannot re-initialize CUDA in forked subprocess on Linux (in Python on POSIX systems "fork" is currently the default and that won't change until Python 3.14 [docs])

  2. call .join() to wait for processes to complete (avoids exiting program immediately)

I believe this resolves issues #21 and #17.

All the examples are now working for me, the optimal-performance/multi.py script is showing ~85 FPS.

OS: Ubuntu 22.04 (Linux kernel 6.2.0)
CUDA: 11.8
GPU: RTX 4090
Python: 3.10.6

@cumulo-autumn

- use multiprocessing context to specify the spawn start method, which fixes the "RuntimeError: Cannot re-initialize CUDA in forked subprocess" on Linux (verified with Ubuntu 22.04 and kernel 6.2.0-39)
- call `.join()` to wait for processes to complete (avoids exiting program immediately)
@cumulo-autumn
Copy link
Owner

Thank you for addressing the issue with multi-processes in the Linux environment!

I have confirmed that it works on both Windows and Linux, and the speed is satisfactory, so I will merge it. Thank you for your contribution!

@cumulo-autumn cumulo-autumn merged commit 62596fd into cumulo-autumn:main Dec 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants