[PYTHON] Run MuJoCo on WSL (2) (also GUI)

It is possible to run MuJoCo on WSL2 as well.

Please refer to the separate article that summarizes the difficult points regarding the introduction of WSL2 and GUI. Introduction of WSL2 and construction of GUI environment

We will proceed on the assumption that Python has already been installed when you want to run mujoco-py.

Introduced MuJoCo

Download MuJoCo

Download MuJoCo from https://www.roboti.us/index.html in any way you like and unzip it to ~ / .mujoco / mujoco200. For example

wget https://www.roboti.us/download/mujoco200_linux.zip
unzip mujoco.zip -d /home/{username}/.mujoco
mv /home/{username}/.mujoco/mujoco200_linux /home/{username}/.mujoco/mujoco200
rm mujoco.zip

Also, prepare the license key in ~ / .mujoco / mjkey.txt.

Add environment variables

In addition, to ~ / .bashrc

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/{username}/.mujoco/mujoco200/bin

To add.

Introducing dependents

I'll put in some necessary things.

sudo apt update
sudo apt install gcc
sudo apt install libosmesa6-dev

At this point, you can do pip install mujoco-py !!

Draw with GUI

As a preparation

sudo apt install libgl1-mesa-dev xorg-dev

I will do it.

For GUI, please refer to Installing WSL2 and building GUI environment.

$ cd ~/.mujoco/mujoco200/bin
$ ./simulate ../model/humanoid.xml
MuJoCo Pro version 2.00
ERROR: could not initialize GLFW

Press Enter to exit ...

If appears, uncheck wsl in the public domain protected network connection from the properties of the Windows Defender firewall in the firewall.

However, if you keep the defaults introduced here (or those introduced on various sites),

MuJoCo Pro version 2.00
libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast
ERROR: OpenGL version 1.5 or higher required

Press Enter to exit ...

It will become. The version of OpenGL seems to be too low. Only one in the world? There was a site that came up with an answer. https://superuser.com/questions/1487555/how-to-troubleshoot-opengl-on-ubuntu-under-windows-10-wsl

in short,

  1. Do not set LIBGL_ALWAYS_INDIRECT in ~ .bashrc
  2. Do not set any LIBGL_ALWAYS_INDIRECT variable
  3. When starting VcXsrv, uncheck the Native opengl guy. Also, don't add the -wgl option.

For 1 and 2, LIBGL_ALWAYS_INDIRECT is originally defined in \ etc \ profile.d \ wsl-integration.sh (this is a symbolic link and is really /usr/share/wslu/wsl-integration.sh ). Therefore, in ~ / .bashrc

unset LIBGL_ALWAYS_INDIRECT

You can delete the variable by writing. Now you can do ./simulate ../model/humanoid.xml, and you can also draw using mujoco-py or OpenAI gym.

Recommended Posts

Run MuJoCo on WSL (2) (also GUI)
How to run GUI programs such as tkinter in Python environment on WSL2
Install python on WSL
Run Kali Linux on Windows with GUI (without VirtualBox)
Linux (WSL) on Windows
Run Django on PythonAnywhere
Run mysqlclient on Lambda
Error around GUI when using PyQt5 on Ubuntu (WSL2)
Run OpenMVG on Mac
Run Jupyter on Ubuntu on Windows
Run Openpose on Python (Windows)
Run Tensorflow 2.x on Python 3.7
Display GUI messages on Ubuntu
wsl Install PostgreSQL on Ubuntu 18.04
Run Python CGI on CORESERVER
Run unix command on python
Run IPython Notebook on Docker
Install Docker on WSL Ubuntu 18.04
Run YOLO v3 on AWS v2
Run CircuitPython on Seeeduino XIAO
Linux environment construction (on WSL environment)
Run Jupyter Notebook on windows
Run FreeBSD on Linux + qemu
Run OpenVino on macOS Catalina
Use Linux on Windows 10 (WSL2)
Run YOLO v3 on AWS