MuJoCo Setup on macOS
Reinforcement Learning with Physics simulations
MuJoCo stands for Multi-Joint dynamics with Contact. Generally, any reinforcement algorithm takes in pixels as inputs viz. a game state. In MuJoCo, the inputs are the angles. When we use the trained models on real-world robots, they perform well.
To set up the MuJoCo environment we need to have a license. We can take a free 30-day trial license or student license or personal/commercial licenses. You can go to this page for details.
- Download the key for the respective OS. In my case, I chose free 30-day trial on OSX which downloaded a file
getid_osx
- Change the permissions of the file by running
chmod 777 getid_osx
- Run the file in terminal
./getid_osx
- It will generate the Computer ID.
- Copy that and paste in the website and provide your details.
- You will receive an email with License.txt and mjkey.txt. Download them
- Click here to download the mujoco-py for macOS. Unzip it.
- Paste these downloaded files ( License.txt and mjkey.txt) inside mujoco200 directory.
- Move the directory to HOME by running
mv mujoco200 ~/.mujoco/mujoco200
open ~/.bash_profile
- Add these lines in that bash_profile file
export LD_LIBRARY_PATH=$HOME/.mujoco/mujoco200/bin:$LD_LIBRARY_PATH
export MUJOCO_PY_MJPRO_PATH=$HOME/.mujoco/mujoco200/
export MUJOCO_PY_MJKEY_PATH=$HOME/.mujoco/mjkey.txt
12. cd ~/.mujoco/mujoco200/bin
13. Run ./simulate ../model/humanoid.xml
14. If it is successful, it should open the below simulator.
Common Errors
MuJoCo python failing on macOS older version
brew install llvm boost hdf5
There is no way you don’t have llvm
and still want to proceed with gcc
. If you are in an older version of macOS Sierra like me, upgrade your gcc
to new versions.
Installation of llvm
especially when you are running out of memory is painful. It takes a lot of time. It is around 1–3 GB in size.
Please do not try to install installing llvm
before upgrading your gcc
. It is tonnes of time waste and finally, llvm
throws an error saying incompatible gcc version
.