当前位置:   article > 正文

Isaac Gym 1. 安装的部分问题和多智能体训练测试

Isaac Gym 1. 安装的部分问题和多智能体训练测试

官方github链接:(注意不要和isaac sim的库混淆)

https://github.com/NVIDIA-Omniverse/IsaacGymEnvs

1. 安装

1.1. 本人安装环境

  1. # >>> conda initialize >>>
  2. # !! Contents within this block are managed by 'conda init' !!
  3. # __conda_setup="$('/home/blamlight/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
  4. # if [ $? -eq 0 ]; then
  5. # eval "$__conda_setup"
  6. # else
  7. # if [ -f "/home/blamlight/anaconda3/etc/profile.d/conda.sh" ]; then
  8. # . "/home/blamlight/anaconda3/etc/profile.d/conda.sh"
  9. # else
  10. # export PATH="/home/blamlight/anaconda3/bin:$PATH"
  11. # fi
  12. # fi
  13. # unset __conda_setup
  14. # <<< conda initialize <<<
  15. # >>> cuda initialize >>>
  16. export PATH=$PATH:/usr/local/cuda/bin
  17. export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64
  18. export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/cuda/lib64
  19. # <<< cuda initialize <<<
  20. # >>> isaacgym initialize >>>
  21. export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/blamlight/anaconda3/envs/isaacgym/lib
  22. # <<< isaacgym initialize <<<
  23. # >>> mujoco initialize >>>
  24. export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/blamlight/.mujoco/mujoco-3.0.1/bin
  25. # export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/blamlight/.mujoco/mujoco210/bin
  26. export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/nvidia
  27. export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libGLEW.so
  28. # <<< mujoco initialize <<<
  29. # >>> ocs2 initialize >>>
  30. export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/ROS1_WS/ocs2_ws/src/raisimLib/raisim/linux/lib
  31. export PYTHONPATH=$PYTHONPATH:~/ROS1_WS/ocs2_ws/src/raisimLib/raisim/linux/lib
  32. export PATH=/opt/openrobots/bin:$PATH
  33. export PKG_CONFIG_PATH=/opt/openrobots/lib/pkgconfig:$PKG_CONFIG_PATH
  34. export LD_LIBRARY_PATH=/opt/openrobots/lib:$LD_LIBRARY_PATH
  35. #export PYTHONPATH=/opt/openrobots/lib/python3.10/site-packages:$PYTHONPATH # Adapt your desired python version here
  36. export CMAKE_PREFIX_PATH=/opt/openrobots:$CMAKE_PREFIX_PATH
  37. # <<< ocs2 initialize <<<
  38. alias src='source ~/.bashrc'
  39. alias initconda='. ~/anaconda3/bin/activate'
  40. alias deconda='conda deactivate'
  41. alias myisaac='. ~/anaconda3/bin/activate && conda activate isaacgym'
  42. alias mymujoco='. ~/anaconda3/bin/activate && conda activate mujoco'
  43. alias myocs2='. ~/anaconda3/bin/activate && conda activate ocs2'
  44. echo "ros noetic(1) or ros2 foxy(2)?"
  45. read edition
  46. if [ "$edition" -eq "2" ];then
  47. source /opt/ros/foxy/setup.bash
  48. source ~/ROS2_WS/catkin_ws/install/setup.bash
  49. echo "source ros foxy"
  50. else
  51. source /opt/ros/noetic/setup.bash
  52. source ~/ROS1_WS/blamlight_ws/devel/setup.bash
  53. source ~/ROS1_WS/unitree_ws/devel/setup.bash
  54. source ~/ROS1_WS/ocs2_ws/devel/setup.bash
  55. source ~/ROS1_WS/go1_ocs2_ws/devel/setup.bash
  56. echo "source ros noetic"
  57. fi
  58. export ROBOT_TYPE=go1

1.2. 安装说明

根据官方github步骤克隆工作区,但是不建议使用bash文件创建conda环境。可以直接自定义一个anaconda环境。

使用python3.7。

使用pip安装环境。使用conda安装环境可能出现该错误:

出现 错误代码:... undefined symbol: free_gemm_select, version libcublasLt.so.11(3090显卡)-CSDN博客

 Previous PyTorch Versions | PyTorch

pip install torch==1.8.1+cu111 torchvision==0.9.1+cu111 torchaudio==0.8.1 -f https://download.pytorch.org/whl/torch_stable.html

2. 测试环境

开始训练ant模型:如果想要查看效果可以headless=False

python train.py task=Ant headless=True

headless=True大约2分钟训练完。 

查看训练结果:

python train.py task=Ant checkpoint=runs/Ant_26-21-14-55/nn/last_Ant_ep_500_rew__6816.49_.pth test=True num_envs=64

其中的参数参考:

https://github.com/NVIDIA-Omniverse/IsaacGymEnvs

Key arguments to the train.py script are:

  • task=TASK - selects which task to use. Any of AllegroHandAllegroHandDextremeADRAllegroHandDextremeManualDRAllegroKukaLSTMAllegroKukaTwoArmsLSTMAntAnymalAnymalTerrainBallBalanceCartpoleFrankaCabinetHumanoidIngenuity QuadcopterShadowHandShadowHandOpenAI_FFShadowHandOpenAI_LSTM, and Trifinger (these correspond to the config for each environment in the folder isaacgymenvs/config/task)
  • train=TRAIN - selects which training config to use. Will automatically default to the correct config for the environment (ie. <TASK>PPO).
  • num_envs=NUM_ENVS - selects the number of environments to use (overriding the default number of environments set in the task config).
  • seed=SEED - sets a seed value for randomizations, and overrides the default seed set up in the task config
  • sim_device=SIM_DEVICE_TYPE - Device used for physics simulation. Set to cuda:0 (default) to use GPU and to cpu for CPU. Follows PyTorch-like device syntax.
  • rl_device=RL_DEVICE - Which device / ID to use for the RL algorithm. Defaults to cuda:0, and also follows PyTorch-like device syntax.
  • graphics_device_id=GRAPHICS_DEVICE_ID - Which Vulkan graphics device ID to use for rendering. Defaults to 0. Note - this may be different from CUDA device ID, and does not follow PyTorch-like device syntax.
  • pipeline=PIPELINE - Which API pipeline to use. Defaults to gpu, can also set to cpu. When using the gpu pipeline, all data stays on the GPU and everything runs as fast as possible. When using the cpu pipeline, simulation can run on either CPU or GPU, depending on the sim_device setting, but a copy of the data is always made on the CPU at every step.
  • test=TEST- If set to True, only runs inference on the policy and does not do any training.
  • checkpoint=CHECKPOINT_PATH - Set to path to the checkpoint to load for training or testing.
  • headless=HEADLESS - Whether to run in headless mode.
  • experiment=EXPERIMENT - Sets the name of the experiment.
  • max_iterations=MAX_ITERATIONS - Sets how many iterations to run for. Reasonable defaults are provided for the provided environments.

参考多机器狗在复杂地形的并行训练示例:

https://github.com/NVIDIA-Omniverse/IsaacGymEnvs/blob/main/docs/rl_examples.md

先启动conda环境,然后进入 IsaacGymEnvs/isaacgymenvs文件夹,可以看到train.py。

python train.py task=AnymalTerrain headless=HEADLESS

使用headless模式约15分钟可以训练完。

查看训练好的模型:(修改模型名字)

python train.py task=AnymalTerrain test=True  checkpoint=runs/AnymalTerrain_17-22-41-07/nn/last_AnymalTerrain_ep_1500_rew__19.45_.pth num_envs=64

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/722650
推荐阅读
相关标签
  

闽ICP备14008679号