From CC Doc
Jump to navigation Jump to search
This site replaces the former Compute Canada documentation site, and is now being managed by the Digital Research Alliance of Canada.

Ce site remplace l'ancien site de documentation de Calcul Canada et est maintenant géré par l'Alliance de recherche numérique du Canada.

Other languages:

MuJoCo stands for Multi-Joint dynamics with Contact. It is a physics engine aiming to facilitate research and development in robotics, biomechanics, graphics and animation, and other areas where fast and accurate simulation is needed.[1]

It is frequently used with the associated Python module mujoco_py as an environment for reinforcement learning (RL) research.


Base files

First, the .mujoco folder in your home directory must be set up. MuJoCo requires a licence key to be placed in ~/.mujoco/mjkey.txt. This key is obtained by e-mail after registration.

The appropriate (Linux) MuJoCo distribution must also be downloaded and unzipped into the ~/.mujoco directory from the Download section of the MuJoCo website.

Your ~/.mujoco folder should now look like this (the version might differ):

[name@server ~]$ ls ~/.mujoco
mjkey.txt mjproj150


The Python interface to MuJoCo is the mujoco_py module. Getting it to work requires some special steps because library paths need to be patched.

1. After using module to load the desired Python version, you should set up a clean virtual environment:

  [name@server ~]$ mkdir mujoco_env
  [name@server ~]$ virtualenv mujoco_env
  [name@server ~]$ source mujoco_env/bin/activate

2. Install the mujoco_py moduleː

(mujoco_env) [name@server $] pip install mujoco_py

3. Patch the paths with Use the appropriate python version in the commands below if it is not 3.5:

  (mujoco_env) [name@server $] --path $VIRTUAL_ENV/lib/python3.5/site-packages/mujoco_py
  (mujoco_env) [name@server $] --add_origin --path $HOME/.mujoco

4. Run the following command:

(mujoco_env) [name@server $] python -c "import mujoco_py"

It should have crashed, but the necessary paths will have been created to run:

(mujoco_env) [name@server $] --path $VIRTUAL_ENV/lib/python3.5/site-packages/mujoco_py

After that last command, mujoco_py should be ready to use in the virtual environment. If everything is installed correctly, this next command should run without any errors:

(mujoco_env) [name@server $] python -c "import mujoco_py"