mjpro150 | mujoco-py 1.50.1 | Gym 0.9.6 |
---|---|---|
mjpro131 | mujoco-py 1.3 | Gym 0.9.3 |
环境:Ubuntu 16.04, Cuda 9.1, nvidia-390, Python 3.5.2
安装顺序:Mujoco, Mujoco-py, Gym
Mujoco
- source: https://www.roboti.us/index.html
- version:
mjpro150
- 获取license:学生可通过教育邮箱获取一年免费license,在
mjkey.txt
中。同一个license可用于131,140,150版本的Mujoco
#download mjpro150.zip
wget -O mjpro150.zip https://www.roboti.us/download/mjpro150_linux.zip
mkdir ~/.mujoco
unzip mjpro150.zip -d ~/.mujoco/mjpro150
#put the license file into ~/.mujoco & ~/.mujoco/mjpro150/bin
cp mjkey.txt ~/.mujoco
cp mjkey.txt ~/.mujoco/mjpro150/bin
#test
cd ~/.mujoco/mjpro150/bin
./simulate ../model/humanoid.xml
测试完后将~/.mujoco/mjpro150/bin
添加到LD_LIBRARY_PATH
中,~/.mujoco
添加到MUJOCO_KEY_PATH
中
Mujoco-py
- version:
mujoco-py 1.50.1
- Github: https://github.com/openai/mujoco-py
#install dependencies
sudo apt-get update -q
DEBIAN_FRONTEND=noninteractive sudo apt-get install -y \
curl \
git \
libgl1-mesa-dev \
libgl1-mesa-glx \
libosmesa6-dev \
python3-pip \
python3-numpy \
python3-scipy \
unzip \
vim \
wget \
xpra \
xserver-xorg-dev
sudo apt-get clean
sudo rm -rf /var/lib/apt/lists/*
#install patchelf
sudo curl -o /usr/local/bin/patchelf https://s3-us-west-2.amazonaws.com/openai-sci-artifacts/manual-builds/patchelf_0.9_amd64.elf
sudo chmod +x /usr/local/bin/patchelf
#download mujoco-py
git clone https://github.com/openai/mujoco-py.git
在我的配置环境下,如果直接安装或在此时通过源码编译后在import时会报GLEW initalization error: Missing GL version
,按照https://github.com/openai/mujoco-py/issues/44中的回复,这是mujoco-py
这一版本的问题,可以按照对应版本将其降到1.3,同时对应的mujoco
和Gym
版本也要改变。在此按照https://github.com/openai/mujoco-py/pull/145/files中的方法改变/mujoco-py/mujoco-py/builder.py
文件后,再进行安装。
#install mujoco-py
cd mujoco-py
sudo python3 setup.py install
#test
python3
import mujoco_py
from os.path import dirname
model = mujoco_py.load_model_from_path(dirname(dirname(mujoco_py.__file__)) +"/xmls/claw.xml")
sim = mujoco_py.MjSim(model)
print(sim.data.qpos)
# [ 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
sim.step()
print(sim.data.qpos)
# [ 2.09217903e-06 -1.82329050e-12 -1.16711384e-07 -4.69613872e-11
# -1.43931860e-05 4.73350204e-10 -3.23749942e-05 -1.19854057e-13
# -2.39251380e-08 -4.46750545e-07 1.78771599e-09 -1.04232280e-08]
注意: 此时尚不能跑通例程,因为可视化时渲染还是会报错,需要使用LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libGLEW.so:/usr/lib/nvidia-390/libGL.so
#test for visualization
cd mujoco-py/examples
LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libGLEW.so:/usr/lib/nvidia-390/libGL.so python3 body_interaction.py
body_interaction渲染结果
Gym
- version:
Gym 0.9.6
- Github: https://github.com/openai/gym
#download source code
git clone https://github.com/openai/gym.git
cd gym
#install requirements
sudo apt-get install -y python-numpy python-dev cmake zlib1g-dev libjpeg-dev xvfb libav-tools xorg-dev python-opengl libboost-all-dev libsdl2-dev swig
#install gym (full-version)
sudo pip3 install -e .
#install particular model
sudo pip3 install -e '.[box2d]'
reference
https://www.jianshu.com/p/9b9247bf6ccb
https://github.com/openai/mujoco-py/pull/145
https://github.com/openai/mujoco-py/issues/44
网友评论
这个错误。。。我是在python中测试mujoco_py 时执行model = mujoco_py.load_model_from_path(dirname(dirname(mujoco_py.__file__)) +"/xmls/claw.xml")得到的这个错误~~~~~~~
ENV LANG C.UTF-8
RUN mkdir -p /root/.mujoco \
&& wget https://www.roboti.us/download/mjpro150_linux.zip -O mujoco.zip \
&& unzip mujoco.zip -d /root/.mujoco \
&& rm mujoco.zip
COPY ./mjkey.txt /root/.mujoco/
ENV LD_LIBRARY_PATH /root/.mujoco/mjpro150/bin:$LD_LIBRARY_PATH
COPY vendor/Xdummy /usr/local/bin/Xdummy
RUN chmod +x /usr/local/bin/Xdummy
不知这些什么意思?