Skip to content

Commit a3bbba0

Browse files
authored
[BugFix] Fix Examples (#687)
1 parent 40c04ef commit a3bbba0

File tree

22 files changed

+774
-51
lines changed

22 files changed

+774
-51
lines changed

.circleci/config.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,57 @@ jobs:
347347
- store_test_results:
348348
path: test-results
349349

350+
351+
unittest_linux_examples_gpu:
352+
<<: *binary_common
353+
machine:
354+
image: ubuntu-2004-cuda-11.4:202110-01
355+
resource_class: gpu.nvidia.medium
356+
environment:
357+
image_name: "pytorch/manylinux-cuda113"
358+
TAR_OPTIONS: --no-same-owner
359+
PYTHON_VERSION: << parameters.python_version >>
360+
CU_VERSION: << parameters.cu_version >>
361+
362+
steps:
363+
- checkout
364+
- designate_upload_channel
365+
- run:
366+
name: Generate cache key
367+
# This will refresh cache on Sundays, nightly build should generate new cache.
368+
command: echo "$(date +"%Y-%U")" > .circleci-weekly
369+
- restore_cache:
370+
371+
keys:
372+
- env-v3-linux-{{ arch }}-py<< parameters.python_version >>-{{ checksum ".circleci/unittest/linux_examples/scripts/environment.yml" }}-{{ checksum ".circleci-weekly" }}
373+
374+
- run:
375+
name: Setup
376+
command: docker run -e PYTHON_VERSION -t --gpus all -v $PWD:$PWD -w $PWD "${image_name}" .circleci/unittest/linux_examples/scripts/setup_env.sh
377+
- save_cache:
378+
379+
key: env-v3-linux-{{ arch }}-py<< parameters.python_version >>-{{ checksum ".circleci/unittest/linux_examples/scripts/environment.yml" }}-{{ checksum ".circleci-weekly" }}
380+
381+
paths:
382+
- conda
383+
- env
384+
- run:
385+
name: Install torchrl
386+
command: docker run -t --gpus all -v $PWD:$PWD -w $PWD -e UPLOAD_CHANNEL -e CU_VERSION "${image_name}" .circleci/unittest/linux_examples/scripts/install.sh
387+
- run:
388+
name: Run tests
389+
command: bash .circleci/unittest/linux_examples/scripts/run_test.sh
390+
# command: docker run --env-file ./env.list -t --gpus all -v $PWD:$PWD -w $PWD "${image_name}" .circleci/unittest/linux/scripts/run_test.sh
391+
- run:
392+
name: Codecov upload
393+
command: |
394+
bash <(curl -s https://codecov.io/bash) -Z -F linux_examples-gpu
395+
- run:
396+
name: Post Process
397+
command: docker run -t --gpus all -v $PWD:$PWD -w $PWD "${image_name}" .circleci/unittest/linux_examples/scripts/post_process.sh
398+
- store_test_results:
399+
path: test-results
400+
350401
unittest_linux_habitat_gpu:
351402
<<: *binary_common
352403
machine:
@@ -937,3 +988,8 @@ workflows:
937988
cu_version: cu113
938989
name: unittest_linux_olddeps_gpu_py3.9
939990
python_version: '3.9'
991+
992+
- unittest_linux_examples_gpu:
993+
cu_version: cu113
994+
name: unittest_linux_examples_gpu_py3.9
995+
python_version: '3.9'
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
channels:
2+
- pytorch
3+
- defaults
4+
dependencies:
5+
- pip
6+
- protobuf
7+
- pip:
8+
- hypothesis
9+
- future
10+
- cloudpickle
11+
- gym
12+
- pygame
13+
- gym[accept-rom-license]
14+
- gym[atari]
15+
- moviepy
16+
- tqdm
17+
- pytest
18+
- pytest-cov
19+
- pytest-mock
20+
- pytest-instafail
21+
- expecttest
22+
- pyyaml
23+
- scipy
24+
- hydra-core
25+
- tensorboard
26+
- wandb
27+
- dm_control
28+
- mlflow
29+
- av
30+
- coverage
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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+
echo "Using cpu build"
16+
else
17+
if [[ ${#CU_VERSION} -eq 4 ]]; then
18+
CUDA_VERSION="${CU_VERSION:2:1}.${CU_VERSION:3:1}"
19+
elif [[ ${#CU_VERSION} -eq 5 ]]; then
20+
CUDA_VERSION="${CU_VERSION:2:2}.${CU_VERSION:4:1}"
21+
fi
22+
echo "Using CUDA $CUDA_VERSION as determined by CU_VERSION ($CU_VERSION)"
23+
version="$(python -c "print('.'.join(\"${CUDA_VERSION}\".split('.')[:2]))")"
24+
fi
25+
26+
# submodules
27+
git submodule sync && git submodule update --init --recursive
28+
29+
printf "Installing PyTorch with %s\n" "${CU_VERSION}"
30+
if [ "${CU_VERSION:-}" == cpu ] ; then
31+
pip3 install --pre torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/nightly/cpu
32+
else
33+
pip3 install --pre torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/nightly/cu113
34+
fi
35+
36+
# smoke test
37+
python -c "import functorch"
38+
39+
# install snapshot
40+
pip install git+https://github.com/pytorch/torchsnapshot
41+
42+
# install tensordict
43+
pip install git+https://github.com/pytorch-labs/tensordict
44+
45+
printf "* Installing torchrl\n"
46+
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)