Skip to content

Commit

Permalink
[Feature] RoboHive integration (#1119)
Browse files Browse the repository at this point in the history
  • Loading branch information
vmoens authored Sep 6, 2023
1 parent 72e8fa4 commit 0ed2208
Show file tree
Hide file tree
Showing 15 changed files with 1,039 additions and 86 deletions.
2 changes: 0 additions & 2 deletions .circleci/unittest/linux_libs/scripts_gym/setup_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ conda env config vars set \
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/pytorch/rl/mujoco-py/mujoco_py/binaries/linux/mujoco210/bin
# LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/circleci/project/mujoco-py/mujoco_py/binaries/linux/mujoco210/bin

# LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/src/nvidia-470.63.01 \

# make env variables apparent
conda deactivate && conda activate "${env_dir}"

Expand Down
28 changes: 28 additions & 0 deletions .circleci/unittest/linux_libs/scripts_robohive/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
channels:
- pytorch
- defaults
dependencies:
- pip
- protobuf
- pip:
# Initial version is required to install Atari ROMS in setup_env.sh
- gym==0.13
- hypothesis
- future
- cloudpickle
- pygame
- moviepy
- tqdm
- pytest
- pytest-cov
- pytest-mock
- pytest-instafail
- pytest-rerunfailures
- pytest-error-for-skips
- expecttest
- pyyaml
- scipy
- hydra-core
- patchelf
- mujoco==2.3.3
- dm_control==1.0.11
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#!/usr/bin/env bash

unset PYTORCH_VERSION
# For unittest, nightly PyTorch is used as the following section,
# so no need to set PYTORCH_VERSION.
# In fact, keeping PYTORCH_VERSION forces us to hardcode PyTorch version in config.
apt-get update && apt-get install -y git wget libglew-dev libx11-dev x11proto-dev g++ gcc libosmesa6-dev

set -e
set -v

eval "$(./conda/bin/conda shell.bash hook)"
conda activate ./env

#apt-get update -y && apt-get install git wget gcc g++ -y

if [ "${CU_VERSION:-}" == cpu ] ; then
cudatoolkit="cpuonly"
version="cpu"
else
if [[ ${#CU_VERSION} -eq 4 ]]; then
CUDA_VERSION="${CU_VERSION:2:1}.${CU_VERSION:3:1}"
elif [[ ${#CU_VERSION} -eq 5 ]]; then
CUDA_VERSION="${CU_VERSION:2:2}.${CU_VERSION:4:1}"
fi
echo "Using CUDA $CUDA_VERSION as determined by CU_VERSION ($CU_VERSION)"
version="$(python -c "print('.'.join(\"${CUDA_VERSION}\".split('.')[:2]))")"
cudatoolkit="cudatoolkit=${version}"
fi

case "$(uname -s)" in
Darwin*) os=MacOSX;;
*) os=Linux
esac

# submodules
git submodule sync && git submodule update --init --recursive

printf "Installing PyTorch with %s\n" "${CU_VERSION}"
if [ "${CU_VERSION:-}" == cpu ] ; then
# conda install -y pytorch torchvision cpuonly -c pytorch-nightly
# use pip to install pytorch as conda can frequently pick older release
# conda install -y pytorch cpuonly -c pytorch-nightly
pip3 install --pre torch --extra-index-url https://download.pytorch.org/whl/nightly/cpu --force-reinstall
else
pip3 install --pre torch --extra-index-url https://download.pytorch.org/whl/nightly/cu116 --force-reinstall
fi

# install tensordict
pip install git+https://github.com/pytorch-labs/tensordict.git

# smoke test
python -c "import tensordict"

printf "* Installing torchrl\n"
python setup.py develop
python -c "import torchrl"

# Extracted from run_test.sh to run once.

export PYTORCH_TEST_WITH_SLOW='1'
python -m torch.utils.collect_env
# Avoid error: "fatal: unsafe repository"
git config --global --add safe.directory '*'

root_dir="$(git rev-parse --show-toplevel)"
env_dir="${root_dir}/env"
lib_dir="${env_dir}/lib"

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$lib_dir
export MKL_THREADING_LAYER=GNU

python .circleci/unittest/helpers/coverage_run_parallel.py -m pytest test/smoke_test.py -v --durations 20

# let's make sure we have a GPU at our disposal
python -c """
import torch
devcount = torch.cuda.device_count()
assert devcount
print('device count', devcount)
"""

echo $MUJOCO_GL
echo $sim_backend

sim_backend=MUJOCO MUJOCO_GL=egl python .circleci/unittest/helpers/coverage_run_parallel.py -m pytest test/test_libs.py --instafail -v --durations 20 -k "robohive" --error-for-skips
coverage combine
coverage xml -i
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

set -e

eval "$(./conda/bin/conda shell.bash hook)"
conda activate ./env
Loading

1 comment on commit 0ed2208

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'CPU Benchmark Results'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: 0ed2208 Previous: 72e8fa4 Ratio
benchmarks/test_objectives_benchmarks.py::test_values[td0_return_estimate-False-False] 2154.5458310123054 iter/sec (stddev: 0.0001696702737637344) 4960.701323959285 iter/sec (stddev: 0.000028058602672688787) 2.30
benchmarks/test_objectives_benchmarks.py::test_gae_speed[vec_generalized_advantage_estimate-False-32-512] 153.80935347950486 iter/sec (stddev: 0.0007756500058936735) 364.55547161812103 iter/sec (stddev: 0.0000715708843292818) 2.37
benchmarks/test_objectives_benchmarks.py::test_cql_speed 17.12548628912288 iter/sec (stddev: 0.004489653874303065) 36.417492119200304 iter/sec (stddev: 0.001905452174263691) 2.13
benchmarks/test_objectives_benchmarks.py::test_a2c_speed 78.00991744668993 iter/sec (stddev: 0.001796707344310305) 182.11811669523672 iter/sec (stddev: 0.000520353026306427) 2.33
benchmarks/test_objectives_benchmarks.py::test_ppo_speed 75.42018418013396 iter/sec (stddev: 0.0012650167645970921) 173.7927667936809 iter/sec (stddev: 0.0011248995175982786) 2.30
benchmarks/test_objectives_benchmarks.py::test_reinforce_speed 95.93548176739742 iter/sec (stddev: 0.0013886332785366697) 236.8311351406333 iter/sec (stddev: 0.000347613612121172) 2.47
benchmarks/test_objectives_benchmarks.py::test_iql_speed 19.36842447234394 iter/sec (stddev: 0.0057922054725693855) 45.033296378531226 iter/sec (stddev: 0.0020890097224068004) 2.33

This comment was automatically generated by workflow using github-action-benchmark.

CC: @vmoens

Please sign in to comment.