1.虚拟机 vm16 安装ubuntu 20.04,修改源为清华
sudo sed -i "s@http://.*archive.ubuntu.com@https://mirrors.tuna.tsinghua.edu.cn@g" /etc/apt/sources.list sudo sed -i "s@http://.*security.ubuntu.com@https://mirrors.tuna.tsinghua.edu.cn@g" /etc/apt/sources.list
sudo apt update sudo apt install gcc g++ build-essential sudo apt install libosmesa6-dev libgl1-mesa-glx libglfw3 sudo apt install patchelf libopenmpi-dev
2.安装conda
下载地址 https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/
选择 Anaconda3-5.3.1-Linux-x86_64.sh
然后直接bash
bash Anaconda3-5.3.1-Linux-x86_64.sh
source .bashrc //检查版本 conda -V
3.创建py3.6的虚拟环境
以下均基于py36的虚拟环境
4.安装mujoco
4.1 下载地址 选择 150 linux
https://www.roboti.us/download.html
4.2 下载key
https://www.roboti.us/license.html
4.3 在家目录新建.mujoco文件夹
mkdir .mujoco
打开文件管理器,按快捷键 ctrl+h 显示隐藏文件,将下载的mujoco解压到.mujoco文件夹。将key放在三个地方1.同级目录 2.mjpro150下 3.mjpro150/bin 下
4.5 设置环境变量
vim .bashrc //添加以下两行 export LD_LIBRARY_PATH=~/.mujoco/mjpro150/bin${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}} export MUJOCO_KEY_PATH=~/.mujoco${MUJOCO_KEY_PATH}
4.6 测试
//重启终端或者source .bashrc cd .mujoco/mjpro150/bin ./simulate ../model/humanoid.xml
运行效果
5.安装mujoco-py
新建ai文件夹
5.1 下载地址
https://github.com/openai/mujoco-py/tree/1.50.1.0
5.2 解压到ai文件夹
5.3
cd mujoco-py-1.50.1.0 pip install -r requirements.txt pip install -r requirements.dev.txt python setup.py install
5.4 测试
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) sim.step() print(sim.data.qpos)
大致结果如下
6.安装openai
6.1 下载依赖
https://github.com/openai/multi-agent-emergence-environments
https://github.com/openai/mujoco-worldgen
6.2 下载以后解压到ai目录
然后
pip install -r mujoco-worldgen/requirements.txt pip install -e mujoco-worldgen/ pip install -r multi-agent-emergence-environments/requirements_ma_policy.txt pip install -e multi-agent-emergence-environments/
6.3 运行一下试试
cd multi-agent-emergence-environments bin/examine.py examples/hide_and_seek_quadrant.jsonnet examples/hide_and_seek_quadrant.npz
7.报错
7.1 问题:AttributeError: ‘dict2’ object has no attribute 'mj_ray’
解决办法:
pip3 install -U 'mujoco-py<1.50.2,>=1.50.1'
本文为看恩吧原创文章,转载无需和我联系,但请注明来自knsay.com