launchpad icon indicating copy to clipboard operation
launchpad copied to clipboard

MuJoCo error when deployed inside launchpad

Open Akella17 opened this issue 2 years ago • 0 comments

Context: I have MuJoCo physics simulator setup on my machine and works fine for my RL experiments. However, when I launch multiple instances of the MuJoCo environment inside launchpad nodes, I get the following error:

ERROR: GLEW initialization error: Missing GL version
Press Enter to exit ...

This error happens only when I launch multiple environments on different launchpad nodes or one environment outside the launchpad and one inside a launchpad node (refer to the example below). This error does not occur when I do not use launchpad.

Here's a minimal code to reproduce this on my machine:

import gym
import launchpad as lp

def make_env():
    env = gym.make('FetchReach-v1')
    _ = env.render(mode='rgb_array', height=64, width=64)

_ = make_env() # Successfully creates the env outside lp

# Fails if the above line isn't commented out
# Only works when the line above or everything below is commented
program = lp.Program(name='agent')
env_node = lp.PyNode(make_env)
program.add_node(env_node, label = 'test_node')
lp.launch(program, terminal='current_terminal')

Edit The issue seems to be with multi-threading (refer to the code example below). Is there any way of bypassing this error with MuJoCo? I am using the following research code released by google research, which happens to be multi-threading with MuJoCo environments.

import gym
import threading

def make_env():
    env = gym.make('FetchReach-v1')
    _ = env.render(mode='rgb_array', height=64, width=64)

_ = make_env() # Successfully creates the env outside lp

thread = threading.Thread(target=make_env)
thread.start()
thread.join()
# >>> ERROR: GLEW initalization error: Missing GL version

Akella17 avatar Mar 02 '23 18:03 Akella17