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

Failed to initialize OpenGL #1

Closed
leeivan1007 opened this issue May 3, 2019 · 9 comments
Closed

Failed to initialize OpenGL #1

leeivan1007 opened this issue May 3, 2019 · 9 comments

Comments

@leeivan1007
Copy link

I find this but didn't help for me...
https://github.com/openai/mujoco-py/issues/187
My devire is ubuntu16, and has run FetchPickAndPlace-v1 from (penai/baselines) then it can run with env(softlearning)

Using seed 8179
2019-05-02 18:19:51.057481: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
Registering multiworld mujoco gym environments
Choosing the latest nvidia driver: /usr/lib/nvidia-396, among ['/usr/lib/nvidia-390', '/usr/lib/nvidia-396']
Choosing the latest nvidia driver: /usr/lib/nvidia-396, among ['/usr/lib/nvidia-390', '/usr/lib/nvidia-396']
/home/ivan/anaconda3/envs/softlearning/lib/python3.6/site-packages/gym/logger.py:30: UserWarning: WARN: gym.spaces.Box autodetected dtype as <class 'numpy.float32'>. Please provide explicit dtype.
warnings.warn(colorize('%s: %s'%('WARN', msg % args), 'yellow'))
Registering goal example multiworld mujoco gym environments
Found 2 GPUs for rendering. Using device 0.
2019-05-02 18:19:53,330 ERROR trial_runner.py:412 -- Error processing event.
Traceback (most recent call last):
File "/home/ivan/anaconda3/envs/softlearning/lib/python3.6/site-packages/ray/tune/trial_runner.py", line 378, in _process_events
result = self.trial_executor.fetch_result(trial)
File "/home/ivan/anaconda3/envs/softlearning/lib/python3.6/site-packages/ray/tune/ray_trial_executor.py", line 228, in fetch_result
result = ray.get(trial_future[0])
File "/home/ivan/anaconda3/envs/softlearning/lib/python3.6/site-packages/ray/worker.py", line 2211, in get
raise value
ray.worker.RayTaskError: ray_ExperimentRunnerClassifierRL:train() (pid=6795, host=ivan-All-Series-Invalid-entry-length-16-Fixed-up-to-11)
File "/home/ivan/anaconda3/envs/softlearning/lib/python3.6/site-packages/ray/tune/trainable.py", line 151, in train
result = self._train()
File "/home/ivan/RL/reward-learning-rl/examples/development/main.py", line 66, in _train
self._build()
File "/home/ivan/RL/reward-learning-rl/examples/classifier_rl/main.py", line 29, in _build
env = self.env = get_goal_example_environment_from_variant(variant)
File "/home/ivan/RL/reward-learning-rl/softlearning/environments/utils.py", line 34, in get_goal_example_environment_from_variant
return GymAdapter(env=gym.make(variant['task']))
File "/home/ivan/anaconda3/envs/softlearning/lib/python3.6/site-packages/gym/envs/registration.py", line 171, in make
return registry.make(id, **kwargs)
File "/home/ivan/anaconda3/envs/softlearning/lib/python3.6/site-packages/gym/envs/registration.py", line 123, in make
env = spec.make(kwargs)
File "/home/ivan/anaconda3/envs/softlearning/lib/python3.6/site-packages/gym/envs/registration.py", line 84, in make
env = self._entry_point(
_kwargs)
File "/home/ivan/anaconda3/envs/softlearning/lib/python3.6/site-packages/multiworld/envs/mujoco/init.py", line 324, in create_image_48_sawyer_door_pull_hook_v0
non_presampled_goal_img_is_garbage=True,
File "/home/ivan/anaconda3/envs/softlearning/lib/python3.6/site-packages/multiworld/core/image_env.py", line 75, in init
sim = self._wrapped_env.initialize_camera(init_camera)
File "/home/ivan/anaconda3/envs/softlearning/lib/python3.6/site-packages/multiworld/envs/mujoco/mujoco_env.py", line 152, in initialize_camera
viewer = mujoco_py.MjRenderContextOffscreen(sim, device_id=self.device_id)
File "mujoco_py/mjrendercontext.pyx", line 43, in mujoco_py.cymj.MjRenderContext.init
File "mujoco_py/mjrendercontext.pyx", line 108, in mujoco_py.cymj.MjRenderContext._setup_opengl_context
File "mujoco_py/opengl_context.pyx", line 128, in mujoco_py.cymj.OffscreenOpenGLContext.init
RuntimeError: Failed to initialize OpenGL

@leeivan1007
Copy link
Author

I found the problem, well i call:

env = gym.make('Image48SawyerDoorPullHookEnv-v0')

and the same error is happen.
how did I build 'Image48SawyerDoorPullHookEnv-v0' in my env, have something I miss?

@avisingh599
Copy link
Owner

Can you try running unset LD_PRELOAD and then try building the environment again?

@leeivan1007
Copy link
Author

leeivan1007 commented May 6, 2019

It can run, thank you!!!

@huiwenzhang
Copy link

huiwenzhang commented May 15, 2019

@avisingh599 @leeivan1007 Hi, this problem happens because of the contradiction between MjViewer.render() method and MjSim.render() method, as posted in openai/mujoco-py#187 and solved by @vitchyr . But this solution only solves the problem partially, which means you can use either of the method by enable and disable the LD_PRELOAD variable. However, if I need both of these two methods work in a same script, what should I do? This case happens when I create an image based environment and want to render the scene later. I think the image based env like Image48SawyerDoorPullHookEnv-v0 use kind of MjSim.render() to initial the camera (call initialize_camera func), but usually the env.render() method is used to render the scene. A simple example is:

env = gym.make('Image48SawyerReachXYEnv-v1') # sim.render() used
obs = env.reset()
for _ in range(2000):
    action = env.action_space.sample()
    obs, rew, done, info = env.step(action)
    env.render() # 
    if done:
        env.reset()

So in this case, the problem still exists, right?

@avisingh599
Copy link
Owner

Yeah, I'm not aware of any clean way to use the two different rendering methods at the same time. If you really want to use them both, you could try changing the environment variable within python, but it would be a pretty hacky solution.

@leeivan1007
Copy link
Author

leeivan1007 commented May 30, 2019

HI~
I git clone in new computer with CUAD10.
but it appeared again
RuntimeError: Failed to initialize OpenGL
but
unset LD_PRELOAD
cann't slove this problem.
and in my old compute (that last time It can run successfully )
create new env, also appeared.
RuntimeError: Failed to initialize OpenGL

it is a frustrating thing, I does not find the reason
why it was success last time, and the old env, that successful one can run in the present...

I think that reason is package.
So I git reset back to 93bb52f, (the time was download the repository)
also can not solve...

@avisingh599
Copy link
Owner

avisingh599 commented Jun 1, 2019

I am not sure what the reason is behind these mujoco-py/opengl errors, since the unset command usually fixes them for me. I would suggest making an issue in the mujoco-py repository to see if someone there can help resolve your issue: https://github.com/openai/mujoco-py

@leeivan1007
Copy link
Author

ok ! thank you

@iparrondo
Copy link

hello , is there a solution to that problem ?
my myjoco environment work until i installed cuda on my new computer.
no way to solve this issue with information available on web.

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

No branches or pull requests

4 participants