openai / mujoco-py

MuJoCo is a physics engine for detailed, efficient rigid body simulations with contacts. mujoco-py allows using MuJoCo from Python 3.
Other
2.89k stars 813 forks source link

[Tutorial]: Tested solution for install `mujoco_py` on linux server `without root`, Enjoy #803

Open Josh00-Lu opened 3 months ago

Josh00-Lu commented 3 months ago

Recommendation: Ubuntu, Conda

## Create conda
conda create -n demo python=3.9 mesalib glew glfw -c conda-forge -y
conda activate demo

## Install mujoco dependency
USER_DIR=$USER
echo $USER_DIR
wget -c "https://mujoco.org/download/mujoco210-linux-x86_64.tar.gz"
mkdir -p /home/$USER_DIR/.mujoco
cp mujoco210-linux-x86_64.tar.gz /home/$USER_DIR/mujoco.tar.gz
rm mujoco210-linux-x86_64.tar.gz
mkdir -p /home/$USER_DIR/.mujoco
tar -zxvf /home/$USER_DIR/mujoco.tar.gz -C /home/$USER_DIR/.mujoco
echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/$USER_DIR/.mujoco/mujoco210/bin" >> ~/.bashrc
echo "export MUJOCO_PY_MUJOCO_PATH=/home/$USER_DIR/.mujoco/mujoco210" >> ~/.bashrc

# activate 
source ~/.bashrc
conda activate demo

#  install 
export CC="/usr/bin/gcc"
pip install "mujoco_py>=2.0"
pip install "cython<3"

# compile mujoco using gcc
python
import mujoco_py

Tested: Ubuntu 22.04.4 LTS

Good luck, enjoy.