Skip to content

Commit 26881b3

Browse files
authored
[CI] Added CircleCI pipeline to test compatibility across supported gym versions (#645)
1 parent 170c6f3 commit 26881b3

File tree

9 files changed

+670
-0
lines changed

9 files changed

+670
-0
lines changed

.circleci/config.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,49 @@ jobs:
402402
- store_test_results:
403403
path: test-results
404404

405+
unittest_linux_gym_gpu:
406+
<<: *binary_common
407+
machine:
408+
image: ubuntu-2004-cuda-11.4:202110-01
409+
resource_class: gpu.nvidia.medium
410+
environment:
411+
image_name: "pytorch/manylinux-cuda113"
412+
TAR_OPTIONS: --no-same-owner
413+
PYTHON_VERSION: << parameters.python_version >>
414+
CU_VERSION: << parameters.cu_version >>
415+
416+
steps:
417+
- checkout
418+
- designate_upload_channel
419+
- run:
420+
name: Generate cache key
421+
# This will refresh cache on Sundays, nightly build should generate new cache.
422+
command: echo "$(date +"%Y-%U")" > .circleci-weekly
423+
- restore_cache:
424+
keys:
425+
- env-v2-linux-{{ arch }}-py<< parameters.python_version >>-{{ checksum ".circleci/unittest/linux_libs/scripts_gym/environment.yml" }}-{{ checksum ".circleci-weekly" }}
426+
- run:
427+
name: Setup
428+
command: docker run -e PYTHON_VERSION -t --gpus all -v $PWD:$PWD -w $PWD "${image_name}" .circleci/unittest/linux_libs/scripts_gym/setup_env.sh
429+
- save_cache:
430+
key: env-v2-linux-{{ arch }}-py<< parameters.python_version >>-{{ checksum ".circleci/unittest/linux_libs/scripts_gym/environment.yml" }}-{{ checksum ".circleci-weekly" }}
431+
paths:
432+
- conda
433+
- env
434+
- run:
435+
name: Install torchrl, run tests
436+
command: |
437+
docker run -t --env=CUDA_VISIBLE_DEVICES="" --gpus all -v $PWD:$PWD -w $PWD -e UPLOAD_CHANNEL -e CU_VERSION "${image_name}" .circleci/unittest/linux_libs/scripts_gym/batch_scripts.sh
438+
- run:
439+
name: Codecov upload
440+
command: |
441+
bash <(curl -s https://codecov.io/bash) -Z -F linux-gpu
442+
- run:
443+
name: Post process
444+
command: docker run -t --gpus all -v $PWD:$PWD -w $PWD -e UPLOAD_CHANNEL -e CU_VERSION "${image_name}" .circleci/unittest/linux_libs/scripts_gym/post_process.sh
445+
- store_test_results:
446+
path: test-results
447+
405448
unittest_linux_optdeps_gpu:
406449
<<: *binary_common
407450
machine:
@@ -785,6 +828,11 @@ workflows:
785828
cu_version: cu113
786829
name: unittest_linux_habitat_gpu_py3.8
787830
python_version: '3.8'
831+
- unittest_linux_gym_gpu:
832+
cu_version: cu113
833+
name: unittest_linux_gym_gpu_py3.8
834+
python_version: '3.8'
835+
788836

789837
- unittest_macos_cpu:
790838
cu_version: cpu
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/usr/bin/env bash
2+
3+
# Runs a batch of scripts in a row to allow docker run to keep installed libraries
4+
# and env variables across runs.
5+
6+
DIR="$(cd "$(dirname "$0")" && pwd)"
7+
8+
set -e
9+
10+
eval "$(./conda/bin/conda shell.bash hook)"
11+
conda activate ./env
12+
13+
# Install PyTorch and TorchRL.
14+
$DIR/install.sh
15+
16+
# Extracted from run_test.sh to run once.
17+
yum makecache && yum install libglvnd-devel mesa-libGL mesa-libGL-devel mesa-libEGL mesa-libEGL-devel glfw mesa-libOSMesa-devel glew glew-devel egl-utils freeglut xorg-x11-server-Xvfb -y
18+
19+
# This version is installed initially (see environment.yml)
20+
for GYM_VERSION in '0.13'
21+
do
22+
echo "Testing gym version: ${GYM_VERSION}"
23+
pip3 install 'gym[atari]'==$GYM_VERSION
24+
$DIR/run_test.sh
25+
done
26+
27+
# gym[atari]==0.19 is broken, so we install only gym without dependencies.
28+
for GYM_VERSION in '0.19'
29+
do
30+
echo "Testing gym version: ${GYM_VERSION}"
31+
pip3 install gym==$GYM_VERSION
32+
$DIR/run_test.sh
33+
done
34+
35+
# gym[atari]==0.20 installs ale-py==0.8, but this version is not compatible with gym<0.26, so we downgrade it.
36+
for GYM_VERSION in '0.20'
37+
do
38+
echo "Testing gym version: ${GYM_VERSION}"
39+
pip3 install 'gym[atari]'==$GYM_VERSION
40+
pip3 install ale-py==0.7
41+
$DIR/run_test.sh
42+
done
43+
44+
for GYM_VERSION in '0.25'
45+
do
46+
echo "Testing gym version: ${GYM_VERSION}"
47+
pip3 install 'gym[atari]'==$GYM_VERSION
48+
$DIR/run_test.sh
49+
done
50+
51+
# For this version "gym[accept-rom-license]" is required.
52+
for GYM_VERSION in '0.26'
53+
do
54+
echo "Testing gym version: ${GYM_VERSION}"
55+
pip3 install 'gym[accept-rom-license]'==$GYM_VERSION
56+
pip3 install 'gym[atari]'==$GYM_VERSION
57+
$DIR/run_test.sh
58+
done
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
channels:
2+
- pytorch
3+
- defaults
4+
dependencies:
5+
- pip
6+
- protobuf
7+
- pip:
8+
# Initial version is required to install Atari ROMS in setup_env.sh
9+
- gym[atari]==0.13
10+
- hypothesis
11+
- future
12+
- cloudpickle
13+
- pygame
14+
- moviepy
15+
- tqdm
16+
- pytest
17+
- pytest-cov
18+
- pytest-mock
19+
- pytest-instafail
20+
- expecttest
21+
- pyyaml
22+
- scipy
23+
- hydra-core
24+
- dm_control -e git+https://github.com/deepmind/dm_control.git@c053360edea6170acfd9c8f65446703307d9d352#egg={dm_control}
25+
- patchelf
26+
- pyopengl==3.1.4
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/usr/bin/env bash
2+
3+
unset PYTORCH_VERSION
4+
# For unittest, nightly PyTorch is used as the following section,
5+
# so no need to set PYTORCH_VERSION.
6+
# In fact, keeping PYTORCH_VERSION forces us to hardcode PyTorch version in config.
7+
8+
set -e
9+
10+
eval "$(./conda/bin/conda shell.bash hook)"
11+
conda activate ./env
12+
13+
#apt-get update -y && apt-get install git wget gcc g++ -y
14+
15+
if [ "${CU_VERSION:-}" == cpu ] ; then
16+
cudatoolkit="cpuonly"
17+
version="cpu"
18+
else
19+
if [[ ${#CU_VERSION} -eq 4 ]]; then
20+
CUDA_VERSION="${CU_VERSION:2:1}.${CU_VERSION:3:1}"
21+
elif [[ ${#CU_VERSION} -eq 5 ]]; then
22+
CUDA_VERSION="${CU_VERSION:2:2}.${CU_VERSION:4:1}"
23+
fi
24+
echo "Using CUDA $CUDA_VERSION as determined by CU_VERSION ($CU_VERSION)"
25+
version="$(python -c "print('.'.join(\"${CUDA_VERSION}\".split('.')[:2]))")"
26+
cudatoolkit="cudatoolkit=${version}"
27+
fi
28+
29+
case "$(uname -s)" in
30+
Darwin*) os=MacOSX;;
31+
*) os=Linux
32+
esac
33+
34+
# submodules
35+
git submodule sync && git submodule update --init --recursive
36+
37+
printf "Installing PyTorch with %s\n" "${CU_VERSION}"
38+
if [ "${CU_VERSION:-}" == cpu ] ; then
39+
conda install pytorch==1.10.0 torchvision==0.11.0 torchaudio==0.10.0 cpuonly -c pytorch -y
40+
else
41+
conda install pytorch==1.10.0 torchvision==0.11.0 torchaudio==0.10.0 cudatoolkit=11.3 -c pytorch -c conda-forge -y
42+
fi
43+
44+
# install tensordict
45+
pip install git+https://github.com/pytorch-labs/tensordict
46+
47+
printf "* Installing torchrl\n"
48+
python setup.py develop
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
eval "$(./conda/bin/conda shell.bash hook)"
6+
conda activate ./env

0 commit comments

Comments
 (0)