Skip to content

Commit f5d98af

Browse files
authored
[Feature] Jumanji envs (#674)
1 parent 09b28d3 commit f5d98af

File tree

16 files changed

+1110
-41
lines changed

16 files changed

+1110
-41
lines changed

.circleci/config.yml

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

405+
unittest_linux_jumanji_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-v3-linux-{{ arch }}-py<< parameters.python_version >>-{{ checksum ".circleci/unittest/linux_libs/scripts_jumanji/environment.yml" }}-{{ checksum ".circleci-weekly" }}
426+
- run:
427+
name: Setup
428+
command: .circleci/unittest/linux_libs/scripts_jumanji/setup_env.sh
429+
- save_cache:
430+
key: env-v3-linux-{{ arch }}-py<< parameters.python_version >>-{{ checksum ".circleci/unittest/linux_libs/scripts_jumanji/environment.yml" }}-{{ checksum ".circleci-weekly" }}
431+
paths:
432+
- conda
433+
- env
434+
- run:
435+
name: Install torchrl
436+
command: docker run -t --gpus all -v $PWD:$PWD -w $PWD -e UPLOAD_CHANNEL -e CU_VERSION "${image_name}" .circleci/unittest/linux_libs/scripts_jumanji/install.sh
437+
- run:
438+
name: Run tests
439+
command: bash .circleci/unittest/linux_libs/scripts_jumanji/run_test.sh
440+
- run:
441+
name: Codecov upload
442+
command: |
443+
bash <(curl -s https://codecov.io/bash) -Z -F linux-jumanji
444+
- run:
445+
name: Post Process
446+
command: docker run -t --gpus all -v $PWD:$PWD -w $PWD "${image_name}" .circleci/unittest/linux_libs/scripts_jumanji/post_process.sh
447+
- store_test_results:
448+
path: test-results
449+
405450
unittest_linux_gym_gpu:
406451
<<: *binary_common
407452
machine:
@@ -828,6 +873,10 @@ workflows:
828873
cu_version: cu113
829874
name: unittest_linux_habitat_gpu_py3.8
830875
python_version: '3.8'
876+
- unittest_linux_jumanji_gpu:
877+
cu_version: cu113
878+
name: unittest_linux_jumanji_gpu_py3.8
879+
python_version: '3.8'
831880
- unittest_linux_gym_gpu:
832881
cu_version: cu113
833882
name: unittest_linux_gym_gpu_py3.8
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
channels:
2+
- pytorch
3+
- defaults
4+
dependencies:
5+
- pip
6+
- pip:
7+
- hypothesis
8+
- future
9+
- cloudpickle
10+
- pytest
11+
- pytest-cov
12+
- pytest-mock
13+
- pytest-instafail
14+
- expecttest
15+
- pyyaml
16+
- scipy
17+
- hydra-core
18+
- jumanji
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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+
if [ "${CU_VERSION:-}" == cpu ] ; then
14+
version="cpu"
15+
else
16+
if [[ ${#CU_VERSION} -eq 4 ]]; then
17+
CUDA_VERSION="${CU_VERSION:2:1}.${CU_VERSION:3:1}"
18+
elif [[ ${#CU_VERSION} -eq 5 ]]; then
19+
CUDA_VERSION="${CU_VERSION:2:2}.${CU_VERSION:4:1}"
20+
fi
21+
echo "Using CUDA $CUDA_VERSION as determined by CU_VERSION ($CU_VERSION)"
22+
version="$(python -c "print('.'.join(\"${CUDA_VERSION}\".split('.')[:2]))")"
23+
fi
24+
25+
# submodules
26+
git submodule sync && git submodule update --init --recursive
27+
28+
printf "Installing PyTorch with %s\n" "${CU_VERSION}"
29+
if [ "${CU_VERSION:-}" == cpu ] ; then
30+
# conda install -y pytorch torchvision cpuonly -c pytorch-nightly
31+
# use pip to install pytorch as conda can frequently pick older release
32+
# conda install -y pytorch cpuonly -c pytorch-nightly
33+
pip3 install --pre torch --extra-index-url https://download.pytorch.org/whl/nightly/cpu --force-reinstall
34+
else
35+
pip3 install --pre torch --extra-index-url https://download.pytorch.org/whl/nightly/cu116 --force-reinstall
36+
fi
37+
38+
# smoke test
39+
python -c "import functorch"
40+
41+
printf "* Installing torchrl\n"
42+
pip3 install -e .
43+
44+
# smoke test
45+
python -c "import torchrl"
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)