I’m trying to install OpenAI gym (https://gym.openai.com/) on my Jetson Xavier NX and was wondering if anyone was successful in getting it to run on their setup, and if so what configurations they used, thanks!
You can find some information below:
Hi @peter.moser, the jetson-reinforcement is outdated, although I hope to update it in the future.
However I was able to confirm that gym installed via pip3. I installed it into the l4t-ml container because that container already includes many of the dependencies that gym package needs (like scipy, ect)
This is how I was able to install it:
sudo docker run -it --rm --net=host --runtime nvidia nvcr.io/nvidia/l4t-ml:r32.5.0-py3 pip3 install gym
Hi Dusty, thank you for your reply! I was able to install OpenAI gym on the container you specified and run it. Everything works except for the rendering part. I was following some of the instructions on this post: python - How to run OpenAI Gym .render() over a server - Stack Overflow
but was still not able to get it to render properly. Would you have any advice on how to get gym.render() to work when running in docker?
I also tried to build from source on the Jetson Xavier NX (from jetson-reinforcement git library). There were a couple of errors during the build process and it then fails to locate the torch module when running the intro-pytorch notebook. Does jetson-reinforcement run on the Jetson Xavier NX?
The error occurs since gym tries to enable the window but fails.
We can successfully enable the
gym.render() after export the DISPLAY variable.
Below is the detailed information for your reference:
$ export DISPLAY=:0 $ xhost + $ sudo docker run -it --rm --net=host --runtime nvidia nvcr.io/nvidia/l4t-ml:r32.5.0-py3
# export DISPLAY=:0 # pip3 install gym
# python3 Python 3.6.9 (default, Oct 8 2020, 12:12:24) [GCC 8.4.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import gym >>> env = gym.make('CartPole-v0') >>> env.reset() array([-0.01348513, -0.01656567, -0.010208 , 0.02606423]) >>> env.render() True >>>
Hi, set the DISPLAY variable outside and inside of docker, everything runs fine up to the command env.render() where the error message below is displayed:
>>> env.render() No protocol specified Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python3.6/dist-packages/gym/core.py", line 240, in render return self.env.render(mode, **kwargs) File "/usr/local/lib/python3.6/dist-packages/gym/envs/classic_control/cartpole.py", line 174, in render from gym.envs.classic_control import rendering File "/usr/local/lib/python3.6/dist-packages/gym/envs/classic_control/rendering.py", line 25, in <module> from pyglet.gl import * File "/usr/local/lib/python3.6/dist-packages/pyglet/gl/__init__.py", line 232, in <module> import pyglet.window File "/usr/local/lib/python3.6/dist-packages/pyglet/window/__init__.py", line 1899, in <module> gl._create_shadow_window() File "/usr/local/lib/python3.6/dist-packages/pyglet/gl/__init__.py", line 206, in _create_shadow_window _shadow_window = Window(width=1, height=1, visible=False) File "/usr/local/lib/python3.6/dist-packages/pyglet/window/xlib/__init__.py", line 173, in __init__ super(XlibWindow, self).__init__(*args, **kwargs) File "/usr/local/lib/python3.6/dist-packages/pyglet/window/__init__.py", line 585, in __init__ display = pyglet.canvas.get_display() File "/usr/local/lib/python3.6/dist-packages/pyglet/canvas/__init__.py", line 94, in get_display return Display() File "/usr/local/lib/python3.6/dist-packages/pyglet/canvas/xlib.py", line 123, in __init__ raise NoSuchDisplayException('Cannot connect to "%s"' % name) pyglet.canvas.xlib.NoSuchDisplayException: Cannot connect to "None"
NoSuchDisplayException: Cannot connect to “None”
Do you have a display device that is connected to Jetson?
If yes, could you check if it is on
Could you also share the output log when you running