0, install nvida driver
if you had installed nvida driver before, please remove it using the following command:
sudo apt-get remove --purge nvidia*
sudo add-apt-repository ppa:graphics-drivers/ppa
then, open "software & updates" from "show application" and choose "additional drivers", and choose a fit driver:
Using NVIDIA driver metapackage from nvidia-driver-440(proprietary)
choose apply chaneges,
then restart.
1, downgrade gcc g++, for if you do not downgrade, cuda_xxx.run wuold not be executed.
sudo apt-get install gcc-7 g++-7
sudo ln -s /usr/bin/gcc-7 /usr/bin/gcc
sudo ln -s /usr/bin/g++-7 /usr/bin/g++
output:
gcc --version
gcc (Ubuntu 7.5.0-6ubuntu2) 7.5.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
g++ --version
g++ (Ubuntu 7.5.0-6ubuntu2) 7.5.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
if system show the soft link exist, but version of gcc and g++ are wrong, please delete the soft link file.
sudo rm /usr/bin/g++
sudo rm /usr/bin/gcc
then rebuild the softlink.
2, install cuda and cudnn:
Download site:
nvidia CUDA history version CUDA Toolkit Archive | NVIDIA Developer
cuDNN history version cuDNN Archive | NVIDIA Developer
Install commands:
sudo chmod a+x cuda_10.0.130_410.48_linux.run
sudo sh cuda_10.0.130_410.48_linux.run
sudo gedit ~/.bashrc
add follow text:
"
export CUDA_HOME=/usr/local/cuda
export PATH=$PATH:$CUDA_HOME/bin
export LD_LIBRARY_PATH=/usr/local/cuda-10.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
"
source ~/.bashrc
test cuda:
cd /usr/local/cuda/samples/1_Utilities/deviceQuery
sudo make
./deviceQuery
output:
deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 10.2, CUDA Runtime Version = 10.0, NumDevs = 1
Result = PASS
test cuda version:
nvcc --version
output:
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2018 NVIDIA Corporation
Built on Sat_Aug_25_21:08:01_CDT_2018
Cuda compilation tools, release 10.0, V10.0.130
install cudnn:
tar -xzvf cudnn-10.0-linux-x64-v7.6.5.32.tgz cuda/
sudo cp cuda/include/cudnn.h /usr/local/cuda/include
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64
sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*
3, install anaconda3:
download
https://repo.anaconda.com/archive/Anaconda3-2020.07-Linux-x86_64.sh
bash Anaconda3-2020.07-Linux-x86_64.sh
4, install pytorch1.2, python3.7:
conda create -n rltorch python=3.7
conda activate rltorch
pytorch with gpu support:
conda install pytorch==1.2.0 torchvision==0.4.0 cudatoolkit=10.0 -c pytorch #can not install by this command in china.
get some help in follow site:
https://pytorch.org/get-started/previous-versions/#via-pip
https://download.pytorch.org/whl/torch_stable.html
pip install torch==1.2.0 torchvision==0.4.0 -f https://download.pytorch.org/whl/torch_stable.html
other options:
pip install torch==1.4.0 -f https://download.pytorch.org/whl/cu100/torch-1.4.0%2Bcu100-cp37-cp37m-linux_x86_64.whl
pip install torchvision==0.4.0 -f https://download.pytorch.org/whl/cu100/torchvision-0.4.0-cp37-cp37m-manylinux1_x86_64.whl --no-deps
5, test pytorch
import torch as t
x = t.rand(5,3)
y = t.rand(5,3)
if t.cuda.is_available():
x = x.cuda()
y = y.cuda()
print(x+y)
output:
ensor([[1.4095, 1.4061, 1.1705],
[1.6440, 0.6937, 1.0405],
[0.7109, 0.5343, 1.1778],
[0.5223, 0.1559, 1.3047],
[1.4479, 0.5002, 1.1370]], device='cuda:0')
>>import torch
>>print(torch.cuda.get_device_name(0))
GeForce RTX 2060
6, install gym, mujoco
gym:
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple gym
7, structurenet
pip install -r requirements.txt
install PyTorch Scatter
pip install torch-scatter==latest+cu100 -f https://pytorch-geometric.com/whl/torch-1.4.0.html
8,install pytorch-geometric
pip install torch-scatter==latest+${CUDA} -f https://pytorch-geometric.com/whl/torch-1.4.0.html
pip install torch-sparse==latest+${CUDA} -f https://pytorch-geometric.com/whl/torch-1.4.0.html
pip install torch-cluster==latest+${CUDA} -f https://pytorch-geometric.com/whl/torch-1.4.0.html
pip install torch-spline-conv==latest+${CUDA} -f https://pytorch-geometric.com/whl/torch-1.4.0.html
pip install torch-geometric
according to your own cudn version,replace ${CUDA}
pip install torch-scatter==latest+cu100 -f https://pytorch-geometric.com/whl/torch-1.4.0.html
pip install torch-sparse==latest+cu100 -f https://pytorch-geometric.com/whl/torch-1.4.0.html
pip install torch-cluster==latest+cu100 -f https://pytorch-geometric.com/whl/torch-1.4.0.html
pip install torch-spline-conv==latest+cu100 -f https://pytorch-geometric.com/whl/torch-1.4.0.html
pip install torch-geometric
9, install tensorflow1.15 gpu, keras
pip install tensorflow-gpu==1.15.0 -i https://pypi.tuna.tsinghua.edu.cn/simple/
pip install keras==2.3.1 -i https://pypi.tuna.tsinghua.edu.cn/simple/
test:
import tensorflow as tf
a = tf.test.is_built_with_cuda() #判断CUDA是否可用
b = tf.test.is_gpu_available(cuda_only=False,min_cuda_compute_capability=None) #判断GPU是否可用
print(a)
print(b)
10, install pybullet
pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple pybullet --upgrade --user
before test the third example "python3 -m pybullet_envs.deep_mimic.testrl --arg_file run_humanoid3d_backflip_args.txt"
please install:
sudo apt install libopenmpi-dev
pip install mpi4py -i https://pypi.tuna.tsinghua.edu.cn/simple/
else it will give an error of "no module of mpi4py"
11, install mujoco, mujoco_py
1.1 mujoco证书秘钥获取
不同身份可获取不同证书 :正常可获取30天免费试用 MuJoCo 权限,如果是学生,通过学校邮箱可获取更长使用期限的秘钥mjkey.txt和证书License.txt;
获取地址: https://www.roboti.us/license.html,需注意,非学生身份可立即获取邮件,学生身份则需要等待一段时间;
生成计算机id:点击右侧Linux,需要下载一个文件到本地,并执行,过程如下:
cd Downloads
chmod a+x getid_linux (给予执行权限)
./getid_linux
1.2 mujoco下载
下载 MuJoCo version 2.0 Linux 版本 :https://www.roboti.us/download/mujoco200_linux.zip
解压下载的 mujoco200 到目录 ~/.mujoco/mujoco200中, 替换license key (邮件附件中的 mjkey.txt) .
按下列流程操作
mkdir ~/.mujoco # 创建文件夹
cp mujoco200_linux.zip的文件路径 ~/.mujoco # 复制
cd .mujoco # 进入隐藏文件夹
unzip mujoco200_linux.zip # 解压
mv mujoco200_linux mujoco200 # 将mujoco200_linux重命名为mujoco200
cd Downloads # 进入下载将mjkey.txt的文件夹
unzip MuJoCo\ Pro\ Trial.zip #
# 复制秘钥到路径
cp mjkey.txt ~/.mujoco/
cp mjkey.txt ~/.mujoco/mujoco200/bin
测试安装是否成功
cd ~/.mujoco/mujoco200/bin
./simulate ../model/humanoid.xml
2. mujoco的环境变量配置
配置环境变量
参考文献:https://www.cnblogs.com/qiuhong10/p/7815943.html
逐步操作
# 注意,路径名需要更改成你自己的路径名,替代“我的计算机名”
gedit ~/.bashrc # 打开,在打开的窗口最后加入以下2行内容
export MUJOCO_KEY_PATH=~/.mujoco${MUJOCO_KEY_PATH}
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/我的计算机名/.mujoco/mujoco200/bin
source ~/.bashrc # 生效
3. mujoco_py的安装与配置
参考文献:https://blog.csdn.net/gsww404/article/details/80636676
https://github.com/deepmind/dm_control/commit/3b736812407d821ec5d48bdea08ac53e00d78d2e
这一步容易出错
3.1 mujoco_py下载
在桌面中另开终端,运行:
git clone https://github.com/openai/mujoco-py.git
1
3.2 mujoco_py安装
进入mujoco-py目录
cd mujoco-py
1
利用 pip3 安装requirements中的包
# When updating these, you may need to also update pyproject.toml
glfw>=1.4.0
numpy>=1.11
Cython>=0.27.2
imageio>=2.1.2
cffi>=1.10
fasteners~=0.15
安装mujoco_py
pip3 install -U 'mujoco-py<2.1,>=2.0'
1
遇见错误:
patchelf 错误
No such file or directory: 'patchelf': 'patchelf'
1
解决办法:
sudo apt-get update -y
sudo apt-get install -y patchelf
PEP 517错误
ubuntu18 Could not build wheels for mujoco-py which use PEP 517 and cannot be installed directly
解决办法:
pip3 install --no-use-pep517 'mujoco-py<2.1,>=2.0'.
测试
$ python3
>>> 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)
结果1:
测试结果1
>>> sim.step()
>>> print(sim.data.qpos)
结果2
测试结果2
运行mujoco_py中自带的例子
cd ~/mujoco-py/examples/
python3 setting_state.py
GLEW 错误:(这个错误比较棘手)
ERROR GLEW initalization error: Missing GL version
按如下操作进行:
sudo apt-get install libglfw3 libglew2.0
将运行程序与显卡进行动态链接
sudo gedit ~/.bashrc # 在.bashrc中添加以下内容
export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libGLEW.so:
source ~/.bashrc # 执行生效
进入解压好的目录~/mujoco-py/examples,再次运行:
python3 setting_state.py
mujoco GLEW initalization error: Missing GL version
Step 1
Run update command to update package repositories and get the latest package information.
sudo apt-get update -y
Step 2
Run the install command with -y
flag to quickly install the packages and dependencies.
sudo apt-get install -y libglew-dev
Got these from : https://zoomadmin.com/HowToInstall/UbuntuPackage/libglew-dev
and then
Step 3:
export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libGLEW.so
ERROR
1,ValueError: Object arrays cannot be loaded when allow_pickle=False
!pip install numpy==1.16.1