|
|
Line 7: |
Line 7: |
|
| |
|
| <!--T:4--> | | <!--T:4--> |
| It is frequently used with the associated Python module <code>mujoco_py</code> as an environment for reinforcement learning (RL) research. | | It is frequently used with the associated Python bindings <code>mujoco</code> as an environment for reinforcement learning (RL) research. |
|
| |
|
| <!--T:5-->
| | The module contains MuJoCo C/C++ library and its Python bindings. |
| __TOC__
| |
|
| |
|
| ==Installation== <!--T:6--> | | == Library == |
| | In order to access headers and binaries, load the module: |
| | {{Command|module load mujoco}} |
|
| |
|
| === Base files === <!--T:2--> | | == Python bindings == |
| | To discover which are the compatible Python versions, run |
| | {{Command|module spider mujoco/2.2.2}} |
|
| |
|
| <!--T:7-->
| | 1. Load the required modules. |
| First, the .mujoco folder in your home directory must be set up. MuJoCo '''requires a licence key''' to be placed in
| | {{Command|module load mujoco python}} |
| ~/.mujoco/mjkey.txt. This key is obtained by e-mail after registration.
| |
|
| |
|
| <!--T:8-->
| | 2. Import MuJoCo. |
| The appropriate (Linux) MuJoCo distribution must also be downloaded and unzipped into the ~/.mujoco directory from the ''Download'' section of the [https://www.roboti.us/index.html MuJoCo website].
| | {{Command|python -c "import mujoco"}} |
|
| |
|
| <!--T:9-->
| | If the command displays nothing, the import was successful. |
| Your ~/.mujoco folder should now look like this (the version might differ):
| |
| {{Command
| |
| |ls ~/.mujoco
| |
| |result=
| |
| mjkey.txt mjproj150
| |
| }}
| |
| | |
| === mujoco_py === <!--T:3-->
| |
| | |
| <!--T:10-->
| |
| The Python interface to MuJoCo is the <code>mujoco_py</code> module. Getting it to work requires some special steps because library paths need to be patched.
| |
| | |
| <!--T:11-->
| |
| 1. After using <code>module</code> to load the desired Python version, you should set up a clean virtual environment:
| |
| | |
| <!--T:12-->
| |
| {{Commands
| |
| |mkdir mujoco_env
| |
| |virtualenv mujoco_env
| |
| |source mujoco_env/bin/activate
| |
| }}
| |
| 2. Install the <code>mujoco_py</code> moduleː
| |
| {{Command
| |
| |prompt=(mujoco_env) [name@server $]
| |
| |pip install mujoco_py
| |
| }}
| |
| | |
| <!--T:13-->
| |
| 3. Patch the paths with setrpaths.sh. Use the appropriate python version in the commands below if it is not 3.5:
| |
| | |
| <!--T:14-->
| |
| {{Commands
| |
| |prompt=(mujoco_env) [name@server $]
| |
| |setrpaths.sh --path $VIRTUAL_ENV/lib/python3.5/site-packages/mujoco_py
| |
| |setrpaths.sh --add_origin --path $HOME/.mujoco
| |
| |export LD_LIBRARY_PATH=$HOME/.mujoco/mjpro150/bin:$LD_LIBRARY_PATH
| |
| }}
| |
| | |
| <!--T:15-->
| |
| 4. Run the following command:
| |
| | |
| <!--T:16-->
| |
| {{Command
| |
| |prompt=(mujoco_env) [name@server $]
| |
| |python -c "import mujoco_py"}}
| |
| | |
| <!--T:17-->
| |
| It should have crashed, but the necessary paths will have been created to run:
| |
| | |
| <!--T:18-->
| |
| {{Command
| |
| |prompt=(mujoco_env) [name@server $]
| |
| |setrpaths.sh --path $VIRTUAL_ENV/lib/python3.5/site-packages/mujoco_py}}
| |
| | |
| <!--T:19-->
| |
| 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:
| |
| {{Command
| |
| |prompt=(mujoco_env) [name@server $]
| |
| |python -c "import mujoco_py"}}
| |
|
| |
|
| </translate> | | </translate> |