In this guide, we’ll walk you through the steps to implement the SHAC algorithm, as described in the paper Accelerated Policy Learning with Parallel Differentiable Simulation. This will not only involve the installation but also example codes to train and test your policy using the provided differentiable simulation.
Installation Steps
To get started with SHAC, follow the installation steps carefully. Here’s a structured approach:
- Clone the repository:
git clone https://github.com/NVlabs/DiffRL.git --recursive
- Operating System: Ubuntu 16.04, 18.04, 20.04, 21.10, 22.04
- Python Versions: 3.7, 3.8
- Supported GPUs: TITAN X, RTX 1080, RTX 2080, RTX 3080, RTX 3090, RTX 3090 Ti
Setting Up the Environment
Next, we’ll create a virtual environment and install the necessary packages:
- In your project folder, create a virtual environment using Anaconda:
conda env create -f diffrl_conda.yml
conda activate shac
cd dflex
pip install -e .
cd externals/rl_games
pip install -e .
pip install protobuf==3.20.0
Testing Your Installation
Once all installations are complete, you can run a test example. Switch to the examples folder and run:
python test_env.py --env AntEnv
If the console outputs Finish Successfully, congratulations! You’ve successfully set up the environment.
Training Your Model
Now it’s time to train your model. Use the following commands within the examples folder:
python train_shac.py --cfg .cfgshacant.yaml --logdir .logsAntshac
For convenience, we also provide a script to replicate results from the paper:
bash examples/train_script.sh
Running SHAC Methodology
If you wish to train specific environments with multiple seeds, execute:
python train_script.py --env Ant --algo shac --num-seeds 5
python train_script.py --env SNUHumanoid --algo shac --num-seeds 5
Using Baseline Algorithms
If you’re interested in training with baseline algorithms, like PPO, run:
python train_script.py --env Ant --algo ppo --num-seeds 5
Testing Your Model
To test the trained policy, input the policy checkpoint as follows:
python train_shac.py --cfg .cfgshacant.yaml --checkpoint .logsAntshacpolicy.pt --play [--render]
The –render flag enables video export in `.usd` format, saved in the examples/output folder.
Troubleshooting
If you encounter issues during installation or execution, here are some troubleshooting tips:
- Ensure you are operating in the correct Anaconda environment.
- Check your GPU compatibility and driver versions.
- Reinstall dependencies if any packages fail to install.
For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.
Conclusion
At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.

