- Install Isaac Gym:
- Download and install Isaac Gym Preview 4 from https://developer.nvidia.com/isaac-gym.
cd isaacgym/python && pip install -e .- Run an example with
cd examples && python 1080_balls_of_solitude.py. - Consult
isaacgym/docs/index.htmlfor troubleshooting.
- Install noetix_rl_gym:
- Clone this repository.
- `cd noetix_n2_gym && pip install -e .
conda install pytorch==1.13.1 torchvision==0.14.1 torchaudio==0.13.1 cudatoolkit=11.8 -c pytorch -c nvidia
# Launching PPO Policy Training Across 4096 Environments
# This command initiates the PPO algorithm-based training for the humanoid task.
# In the subdirectory noetix_n2_gym
python humanoid/scripts/train.py --task=n2 --headless --num_envs 4096
# Additionally, it automatically exports a JIT model, suitable for deployment purposes.
python humanoid/scripts/play.py --task=n2
-
Training Command: For training the PPO policy, execute:
python humanoid/scripts/train.py --task=n2_mimic --load_run log_file_pathpython humanoid/scripts/train.py --task=n2_10dof --load_run log_file_path -
Running a Trained Policy: To deploy a trained PPO policy, use:
python humanoid/scripts/play.py --task=n2_mimic --load_run log_file_pathpython humanoid/scripts/play.py --task=n2_10dof --load_run log_file_path -
By default, the latest model of the last run from the experiment folder is loaded. However, other run iterations/models can be selected by adjusting
load_runandcheckpointin the training config.
- Please note: Before initiating the sim-to-sim process, ensure that you run
play.pyto export a JIT policy, copy the policy path to the sim2sim/policy folder, and update the policy_config in the sim2sim/configs/n2_18dof.yaml file. - Mujoco-based Sim2Sim Deployment: Utilize Mujoco for executing simulation-to-simulation (sim2sim) deployments with the
command below:
python sim2sim/sim2sim.py
- CPU and GPU Usage: To run simulations on the CPU, set both
--sim_device=cpuand--rl_device=cpu. For GPU operations, specify--sim_device=cuda:{0,1,2...}and--rl_device={0,1,2...}accordingly. Please note thatCUDA_VISIBLE_DEVICESis not applicable, and it's essential to match the--sim_deviceand--rl_devicesettings. - Headless Operation: Include
--headlessfor operations without rendering. - Rendering Control: Press 'v' to toggle rendering during training.
- Policy Location: Trained policies are saved in
humanoid/logs/<experiment_name>/<date_time>_<run_name>/model_<iteration>.pt.
For RL training, please refer to humanoid/utils/helpers.py#L161.
For the sim-to-sim process, please refer to sim2sim/sim2sim.py#L169.
- Every environment hinges on an
envfile (legged_robot.py) and aconfigurationfile (legged_robot_config.py). The latter houses two classes:LeggedRobotCfg(encompassing all environmental parameters) andLeggedRobotCfgPPO(denoting all training parameters). - Both
envandconfigclasses use inheritance. - Non-zero reward scales specified in
cfgcontribute a function of the corresponding name to the sum-total reward. - Tasks must be registered with
task_registry.register(name, EnvClass, EnvConfig, TrainConfig). Registration may occur withinenvs/__init__.py, or outside of this repository.
The base environment legged_robot constructs a rough terrain locomotion task. The corresponding configuration does not specify a robot asset (URDF/ MJCF) and no reward scales.
- If you need to add a new environment, create a new folder in the
envs/directory with a configuration file named<your_env>_config.py. The new configuration should inherit from existing environment configurations. - If proposing a new robot:
- Insert the corresponding assets in the
resources/folder. - In the
cfgfile, set the path to the asset, define body names, default_joint_positions, and PD gains. Specify the desiredtrain_cfgand the environment's name (python class). - In the
train_cfg, set theexperiment_nameandrun_name.
- Insert the corresponding assets in the
- If needed, create your environment in
<your_env>.py. Inherit from existing environments, override desired functions and/or add your reward functions. - Register your environment in
humanoid/envs/__init__.py. - Modify or tune other parameters in your
cfgorcfg_trainas per requirements. To remove the reward, set its scale to zero. Avoid modifying the parameters of other environments! - If you want a new robot/environment to perform sim2sim, you may need to modify
sim2sim/sim2sim.py:- Check the joint mapping of the robot between MJCF and URDF.
- Change the initial joint position of the robot according to your trained policy.
Observe the following cases:
# error
ImportError: libpython3.8.so.1.0: cannot open shared object file: No such file or directory
# solution
# set the correct path
export LD_LIBRARY_PATH="~/miniconda3/envs/your_env/lib:$LD_LIBRARY_PATH"
# OR
sudo apt install libpython3.8
# error
AttributeError: module 'distutils' has no attribute 'version'
#or
ImportError: /home/roboterax/anaconda3/../../nvidia/cusparse/lib/libcusparse.so.12: undefined symbol: __nvJitLinkAddData_12_1, version libnvJitLink.so.12
# solution
# install pytorch 1.12.0
#conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch
#if GPU Name is RTX 4070 (NVIDIA-SMI 535.230.02 Driver Version: 535.230.02 CUDA Version: 12.2)
conda install pytorch==1.13.1 torchvision==0.14.1 torchaudio==0.13.1 cudatoolkit=11.8 -c pytorch -c nvidia
# error, results from libstdc++ version distributed with conda differing from the one used on your system to build Isaac Gym
ImportError: /home/roboterax/anaconda3/bin/../lib/libstdc++.so.6: version `GLIBCXX_3.4.20` not found (required by /home/roboterax/carbgym/python/isaacgym/_bindings/linux64/gym_36.so)
# solution
mkdir ${YOUR_CONDA_ENV}/lib/_unused
mv ${YOUR_CONDA_ENV}/lib/libstdc++* ${YOUR_CONDA_ENV}/lib/_unused
# error
RuntimeError: The following operation failed in the TorchScript interpreter.
Traceback of TorchScript (most recent call last):
RuntimeError: nvrtc: error: invalid value for --gpu-architecture (-arch)
# solution
conda uninstall pytorch torchvision torchaudio cudatoolkit
pip uninstall torch torchvision torchaudio
conda install pytorch==1.13.1 torchvision==0.14.1 torchaudio==0.13.1 cudatoolkit=11.8 -c pytorch -c nvidia
rm -rf /home/ubuntu/.cache/torch_extensions/py38_cu113/gymtorch/
rm -rf /home/ubuntu/.cache/torch_extensions/py38_cu118/gymtorch/
export CUDA_ARCH_LIST="sm_89" #RTX 4070
export TORCH_CUDNN_V8_API_DISABLED=1