This problem affects nvidia GPUs only. The simulator is currently unable to fork so that multiple processes can be run at the same time. This is somewhat problematic as creating subprocesses is the method used by SubprocVecEnv to create multiple simulators to train with in parallel.
The fix would come down to importing Pyglet lazily, after forking. I've experimented a bit and was unable to get this to work previously. It might be possible to completely avoid importing gym_duckietown until after the fork.
This problem affects nvidia GPUs only. The simulator is currently unable to fork so that multiple processes can be run at the same time. This is somewhat problematic as creating subprocesses is the method used by SubprocVecEnv to create multiple simulators to train with in parallel.
To reproduce:
I've opened an issue with Pyglet: https://bitbucket.org/pyglet/pyglet/issues/160/creating-a-new-opengl-context-without-a
A fix has been proposed: https://bitbucket.org/pyglet/pyglet/issues/166/multiprocessing-macos-osx-sierra-python3
The fix would come down to importing Pyglet lazily, after forking. I've experimented a bit and was unable to get this to work previously. It might be possible to completely avoid importing
gym_duckietown
until after the fork.