Git Product home page Git Product logo

Comments (11)

diviyank avatar diviyank commented on July 19, 2024

Hi,
I had this issue, I think it is linked to gym/pyglet and the displays. Are you running this script from a server (without displays)? If yes, please use the command:

xvfb-run -s "-screen 0 600x400x24" python generation_script.py

Best,
Diviyan

from world-models.

whikwon avatar whikwon commented on July 19, 2024

Thank you I'll try it out.

from world-models.

twoflypig avatar twoflypig commented on July 19, 2024

Hi,I just had the same error as you have . For my case , I use anaconda2 and I am on Ubuntu 18.04 .
And I run this command on shell
glxinfo
got the followings:

name of display: :1
libGL error: unable to load driver: swrast_dri.so
libGL error: failed to load driver: swrast
X Error of failed request:  GLXBadContext
  Major opcode of failed request:  154 (GLX)
  Minor opcode of failed request:  6 (X_GLXIsDirect)
  Serial number of failed request:  53
  Current serial number in output stream:  52

The problem is that in my anaconda environment (i.e /home/me/anaconda2/envs/tensorflow-gpu/lib),the file libstdc++.so is not assosciated with system's drivers( I 'm not totally sure about this). So we can do followings.

cd /home/me/anaconda2/envs/tensorflow-gpu/lib (cd the environment where you excute the command)
mkdir backup  #backup the origin libstdc++
mv libstd* backup  
#copy  the system's libstdc++.so.6 to the local folder
cp /usr/lib/x86_64-linux-gnu/libstdc++.so.6  ./
# create soft links
ln -s libstdc++.so.6 libstdc++.so
ln -s libstdc++.so.6 libstdc++.so.6.0.19
 

Then excute glxinfo anagin on shell you will get

name of display: :1
display: :1  screen: 0
direct rendering: Yes
server glx vendor string: SGI
server glx version string: 1.4
server glx extensions:
....

Finally , it works when I excute the generation_script.py .
ref: csdn bolg in chinese

from world-models.

whikwon avatar whikwon commented on July 19, 2024

I'm not executing in the server and when i execute your command,
Traceback (most recent call last): File "generation_script.py", line 20, in <module> rpt = args.roolouts // args.threads + 1 TypeError: unsupported operand type(s) for //: 'NoneType' and 'NoneType'

from world-models.

diviyank avatar diviyank commented on July 19, 2024

I forgot to add the command line arguments in my previous comment:

xvfb-run -s "-screen 0 600x400x24" python data/generation_script.py --rollouts 1000 --rootdir datasets/carracing --threads 8

Could you reset your environment by pulling and reinstall the required packages ?

from world-models.

0xsamgreen avatar 0xsamgreen commented on July 19, 2024

I am getting a similar error. I am running within a conda environment that I created for this project. I am running locally (not over a server) and I can pass all the OpenAI gym unit tests (I install gym from source, and within the the gym git directory, with my conda environment activated, run 'python -m test'). I then run the following command

PYTHONPATH='.' python data/generation_script.py --rollouts 1000 --rootdir datasets/carracing --threads 1

(See this Issue for PYTHONPATH addition to command: #20)

Calling generation_script.py fails with the following:

xvfb-run -s "-screen 0 1400x900x24" --server-num=1 python data/carracing.py --dir datasets/carracing/thread_0 --rollouts 1001 --policy brown
Track generation: 1063..1333 -> 270-tiles track
Traceback (most recent call last):
  File "data/carracing.py", line 58, in <module>
    generate_data(args.rollouts, args.dir, args.policy)
  File "data/carracing.py", line 20, in generate_data
    env.reset()
  File "/media/storage/world-models/gym/gym/wrappers/time_limit.py", line 44, in reset
    return self.env.reset(**kwargs)
  File "/media/storage/world-models/gym/gym/envs/box2d/car_racing.py", line 293, in reset
    return self.step(None)[0]
  File "/media/storage/world-models/gym/gym/envs/box2d/car_racing.py", line 305, in step
    self.state = self.render("state_pixels")
  File "/media/storage/world-models/gym/gym/envs/box2d/car_racing.py", line 327, in render
    from gym.envs.classic_control import rendering
  File "/media/storage/world-models/gym/gym/envs/classic_control/rendering.py", line 23, in <module>
    from pyglet.gl import *
  File "/home/sam/anaconda3/envs/ctallec-world-models/lib/python3.7/site-packages/pyglet/gl/__init__.py", line 239, in <module>
    import pyglet.window
  File "/home/sam/anaconda3/envs/ctallec-world-models/lib/python3.7/site-packages/pyglet/window/__init__.py", line 1896, in <module>
    gl._create_shadow_window()
  File "/home/sam/anaconda3/envs/ctallec-world-models/lib/python3.7/site-packages/pyglet/gl/__init__.py", line 208, in _create_shadow_window
    _shadow_window = Window(width=1, height=1, visible=False)
  File "/home/sam/anaconda3/envs/ctallec-world-models/lib/python3.7/site-packages/pyglet/window/xlib/__init__.py", line 166, in __init__
    super(XlibWindow, self).__init__(*args, **kwargs)
  File "/home/sam/anaconda3/envs/ctallec-world-models/lib/python3.7/site-packages/pyglet/window/__init__.py", line 571, in __init__
    self._create()
  File "/home/sam/anaconda3/envs/ctallec-world-models/lib/python3.7/site-packages/pyglet/window/xlib/__init__.py", line 263, in _create
    self.context.attach(self.canvas)
  File "/home/sam/anaconda3/envs/ctallec-world-models/lib/python3.7/site-packages/pyglet/gl/xlib.py", line 323, in attach
    self.set_current()
  File "/home/sam/anaconda3/envs/ctallec-world-models/lib/python3.7/site-packages/pyglet/gl/xlib.py", line 328, in set_current
    super(XlibContext13, self).set_current()
  File "/home/sam/anaconda3/envs/ctallec-world-models/lib/python3.7/site-packages/pyglet/gl/base.py", line 301, in set_current
    gl_info.set_active_context()
  File "/home/sam/anaconda3/envs/ctallec-world-models/lib/python3.7/site-packages/pyglet/gl/gl_info.py", line 98, in set_active_context
    if self.have_version(3):
  File "/home/sam/anaconda3/envs/ctallec-world-models/lib/python3.7/site-packages/pyglet/gl/gl_info.py", line 170, in have_version
    imajor, iminor, irelease = [int(v) for v in ver.split('.', 3)[:3]]
  File "/home/sam/anaconda3/envs/ctallec-world-models/lib/python3.7/site-packages/pyglet/gl/gl_info.py", line 170, in <listcomp>
    imajor, iminor, irelease = [int(v) for v in ver.split('.', 3)[:3]]
ValueError: invalid literal for int() with base 10: ''

Do I need to make a different call to xvfb-run?

from world-models.

waiyc avatar waiyc commented on July 19, 2024

@SG2 I am facing the same issue. I commented the following lines to disable xvfb-run in generation_script.py and it start to generate random rollout data.

#cmd = ['xvfb-run', '-s', '"-screen 0 1400x900x24"']
#cmd += ['--server-num={}'.format(i + 1)]
cmd = ["python", "-m", "data.carracing", "--dir",
tdir, "--rollouts", str(rpt), "--policy", args.policy]

Hope it helps :)

from world-models.

philipjball avatar philipjball commented on July 19, 2024

I was having exactly the same error, and my glxinfo and xvfb-run were working as expected. Instead it seems to have been a build issue with Box2D. I believe that this happens because for some reason not having a display (I'm sshing into a VM) makes the Box2D-py in gym not work properly, so you must roll it back to an older version (2.3.2/2.3.3). This older version however will only work if you build it with a specific version of swig. So in short, I had to do the following:

  • Upgrade Ubuntu from 16.04 -> 18.04 (so I can use swig 3.0.12)
  • Install the requirements as stated, except just gym (not gym[all])
  • Downgrade pyglet to 1.3.2
  • Install box2d and box2d-kengz

from world-models.

giubacchio avatar giubacchio commented on July 19, 2024

I still have the same error.
I'm using conda, and I followed the suggestions given by @fiorenza2, apart from upgrading to Ubuntu 18.04 (I managed to install swig 3.0.12, box2d 2.3.2, and box2d-kengz, the last two using pip).
It gives me the same error both locally and sshing to a server, in both cases using xvfb-run.

However, it works locally if I don't use xvfb, so I suspect that xvfb may be the cause. Unluckily, the same error appears when training the controller, and in this case I can't do it locally because the GPUs are in the server.

Any other suggestion?

Thank you

from world-models.

0xsamgreen avatar 0xsamgreen commented on July 19, 2024

@giubacchio can you provide a requirements.txt file for your installation? If you can, I'll see if I can run it.

from world-models.

giubacchio avatar giubacchio commented on July 19, 2024

@SG2 Here is the list with the commands I used to set the conda environment, together with the last rows of the error I get.
conda_installation_and_error.txt

from world-models.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.