ubuntu安装强化学习环境
mujoco
conda install -n mujoco-test python==3.7
conda activate mujoco-test
https://github.com/deepmind/mujoco/releases
下载mujoco210,放到主目录.mujoco下
运行example里面的实例
cd ~/.mujoco/mujoco210/bin
./simulate ../model/humanoid.xml
安装依赖
sudo apt-get install libglew-dev glew-utils
sudo apt install libosmesa6-dev libgl1-mesa-glx libglfw3
pip3 install -U 'mujoco-py<2.2,>=2.1'
环境变量
sudo gedit ~/.bashrc
在文件里加这几个
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/xyx/.mujoco/mujoco210/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/nvidia
export MUJOCO_KEY_PATH=~/.mujoco${MUJOCO_KEY_PATH}
更新
source ~/.bashrc
测试一下
import mujoco_py
import os
mj_path = mujoco_py.utils.discover_mujoco()
xml_path = os.path.join(mj_path, 'model', 'humanoid.xml')
model = mujoco_py.load_model_from_path(xml_path)
sim = mujoco_py.MjSim(model)
print(sim.data.qpos)
# [0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
sim.step()
print(sim.data.qpos)
# [-2.09531783e-19 2.72130735e-05 6.14480786e-22 -3.45474715e-06
# 7.42993721e-06 -1.40711141e-04 -3.04253586e-04 -2.07559344e-04
# 8.50646247e-05 -3.45474715e-06 7.42993721e-06 -1.40711141e-04
# -3.04253586e-04 -2.07559344e-04 -8.50646247e-05 1.11317030e-04
# -7.03465386e-05 -2.22862221e-05 -1.11317030e-04 7.03465386e-05
# -2.22862221e-05]
这样就行了
pip
Package Version
----------------------------- ---------
alabaster 0.7.12
attrs 22.1.0
Babel 2.10.3
backcall 0.2.0
certifi 2022.9.14
cffi 1.15.1
charset-normalizer 2.1.1
Cython 0.29.32
decorator 5.1.1
docutils 0.17.1
fasteners 0.18
glfw 2.5.5
grpcio 1.23.0
idna 3.4
ImageHash 4.3.0
imageio 2.22.0
imagesize 1.4.1
importlib-metadata 4.12.0
iniconfig 1.1.1
ipdb 0.13.9
ipython 7.34.0
jedi 0.18.1
Jinja2 3.1.2
MarkupSafe 2.1.1
matplotlib-inline 0.1.6
mujoco-py 2.1.2.14
numpy 1.21.6
numpydoc 1.4.0
packaging 21.3
parso 0.8.3
pexpect 4.8.0
pickleshare 0.7.5
Pillow 9.2.0
pip 22.2.2
pluggy 1.0.0
prompt-toolkit 3.0.31
ptyprocess 0.7.0
py 1.11.0
pycparser 2.21
Pygments 2.13.0
pyparsing 3.0.9
pytest 7.1.3
pytest-instafail 0.3.0
pytz 2022.2.1
PyWavelets 1.3.0
requests 2.28.1
scipy 1.7.3
setuptools 65.3.0
six 1.16.0
snowballstemmer 2.2.0
Sphinx 5.1.1
sphinx-rtd-theme 1.0.0
sphinxcontrib-applehelp 1.0.2
sphinxcontrib-devhelp 1.0.2
sphinxcontrib-htmlhelp 2.0.0
sphinxcontrib-jsmath 1.0.1
sphinxcontrib-qthelp 1.0.3
sphinxcontrib-serializinghtml 1.1.5
toml 0.10.2
tomli 2.0.1
traitlets 5.4.0
typing_extensions 4.3.0
urllib3 1.26.12
wcwidth 0.2.5
wheel 0.37.1
zipp 3.8.1
conda
# packages in environment at /home/xyx/anaconda3/envs/mujoco-test:
#
# Name Version Build Channel
alabaster 0.7.12 <pip>
attrs 22.1.0 <pip>
Babel 2.10.3 <pip>
backcall 0.2.0 <pip>
ca-certificates 2022.07.19 h06a4308_0
certifi 2022.9.14 py37h06a4308_0
cffi 1.15.1 <pip>
charset-normalizer 2.1.1 <pip>
Cython 0.29.32 <pip>
decorator 5.1.1 <pip>
docutils 0.17.1 <pip>
fasteners 0.18 <pip>
glfw 2.5.5 <pip>
grpcio 1.23.0 <pip>
idna 3.4 <pip>
ImageHash 4.3.0 <pip>
imageio 2.22.0 <pip>
imagesize 1.4.1 <pip>
importlib-metadata 4.12.0 <pip>
iniconfig 1.1.1 <pip>
ipdb 0.13.9 <pip>
ipython 7.34.0 <pip>
jedi 0.18.1 <pip>
Jinja2 3.1.2 <pip>
ld_impl_linux-64 2.38 h1181459_1
libffi 3.3 he6710b0_2
libgcc 7.2.0 h69d50b8_2
libgcc-ng 11.2.0 h1234567_1
libstdcxx-ng 11.2.0 h1234567_1
MarkupSafe 2.1.1 <pip>
matplotlib-inline 0.1.6 <pip>
mujoco-py 2.1.2.14 <pip>
ncurses 6.3 h5eee18b_3
numpy 1.21.6 <pip>
numpydoc 1.4.0 <pip>
openssl 1.1.1q h7f8727e_0
packaging 21.3 <pip>
parso 0.8.3 <pip>
pexpect 4.8.0 <pip>
pickleshare 0.7.5 <pip>
Pillow 9.2.0 <pip>
pip 22.1.2 py37h06a4308_0
pip 22.2.2 <pip>
pluggy 1.0.0 <pip>
prompt-toolkit 3.0.31 <pip>
ptyprocess 0.7.0 <pip>
py 1.11.0 <pip>
pycparser 2.21 <pip>
Pygments 2.13.0 <pip>
pyparsing 3.0.9 <pip>
pytest 7.1.3 <pip>
pytest-instafail 0.3.0 <pip>
python 3.7.13 h12debd9_0
pytz 2022.2.1 <pip>
PyWavelets 1.3.0 <pip>
readline 8.1.2 h7f8727e_1
requests 2.28.1 <pip>
scipy 1.7.3 <pip>
setuptools 63.4.1 py37h06a4308_0
setuptools 65.3.0 <pip>
six 1.16.0 <pip>
snowballstemmer 2.2.0 <pip>
Sphinx 5.1.1 <pip>
sphinx-rtd-theme 1.0.0 <pip>
sphinxcontrib-applehelp 1.0.2 <pip>
sphinxcontrib-devhelp 1.0.2 <pip>
sphinxcontrib-htmlhelp 2.0.0 <pip>
sphinxcontrib-jsmath 1.0.1 <pip>
sphinxcontrib-qthelp 1.0.3 <pip>
sphinxcontrib-serializinghtml 1.1.5 <pip>
sqlite 3.39.2 h5082296_0
tk 8.6.12 h1ccaba5_0
toml 0.10.2 <pip>
tomli 2.0.1 <pip>
traitlets 5.4.0 <pip>
typing_extensions 4.3.0 <pip>
urllib3 1.26.12 <pip>
wcwidth 0.2.5 <pip>
wheel 0.37.1 pyhd3eb1b0_0
xz 5.2.5 h7f8727e_1
zipp 3.8.1 <pip>
zlib 1.2.12 h5eee18b_3