|
| 1 | +# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. |
| 2 | +# Python CircleCI 2.0 configuration file |
| 3 | +# |
| 4 | +# Check https://circleci.com/docs/2.0/language-python/ for more details |
| 5 | +# |
| 6 | +version: 2 |
| 7 | + |
| 8 | +# ------------------------------------------------------------------------------------- |
| 9 | +# Environments to run the jobs in |
| 10 | +# ------------------------------------------------------------------------------------- |
| 11 | +cpu: &cpu |
| 12 | + environment: |
| 13 | + TERM: xterm |
| 14 | + machine: |
| 15 | + image: default |
| 16 | + resource_class: medium |
| 17 | + |
| 18 | +gpu: &gpu |
| 19 | + environment: |
| 20 | + CUDA_VER: "10.2" |
| 21 | + TORCH_CUDA_ARCH_LIST: "5.0;5.2;5.3" |
| 22 | + TERM: xterm |
| 23 | + machine: |
| 24 | + image: ubuntu-1604:201903-01 |
| 25 | + resource_class: gpu.medium # Tesla M60 |
| 26 | + |
| 27 | +# ------------------------------------------------------------------------------------- |
| 28 | +# Re-usable commands |
| 29 | +# ------------------------------------------------------------------------------------- |
| 30 | +install_python: &install_python |
| 31 | + - run: |
| 32 | + name: Install Python |
| 33 | + working_directory: ~/ |
| 34 | + command: | |
| 35 | + pyenv versions |
| 36 | + pyenv install 3.6.2 |
| 37 | + pyenv global 3.6.2 |
| 38 | +
|
| 39 | +update_gcc7: &update_gcc7 |
| 40 | + - run: |
| 41 | + name: Update GCC7 |
| 42 | + working_directory: ~/ |
| 43 | + command: | |
| 44 | + sudo apt-get update |
| 45 | + sudo add-apt-repository ppa:jonathonf/gcc |
| 46 | + sudo apt-get update |
| 47 | + sudo apt-get install gcc-7 g++-7 |
| 48 | + sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 60 --slave /usr/bin/g++ g++ /usr/bin/g++-7 --slave /usr/bin/gcov gcov /usr/bin/gcov-7 --slave /usr/bin/gcov-tool gcov-tool /usr/bin/gcov-tool-7 --slave /usr/bin/gcc-ar gcc-ar /usr/bin/gcc-ar-7 --slave /usr/bin/gcc-nm gcc-nm /usr/bin/gcc-nm-7 --slave /usr/bin/gcc-ranlib gcc-ranlib /usr/bin/gcc-ranlib-7 |
| 49 | + gcc --version |
| 50 | + g++ --version |
| 51 | +
|
| 52 | +install_classy_vision: &install_classy_vision |
| 53 | + - run: |
| 54 | + name: Install ClassyVision |
| 55 | + working_directory: ~/ |
| 56 | + command: | |
| 57 | + pip uninstall -y classy_vision |
| 58 | + pip install classy-vision@https://github.com/facebookresearch/ClassyVision/tarball/master |
| 59 | +
|
| 60 | +setupcuda: &setupcuda |
| 61 | + run: |
| 62 | + name: Setup CUDA and NVIDIA driver |
| 63 | + working_directory: ~/ |
| 64 | + command: | |
| 65 | + # download and install nvidia drivers, cuda, etc |
| 66 | + wget --no-verbose --no-clobber -P ~/nvidia-downloads 'https://s3.amazonaws.com/ossci-linux/nvidia_driver/NVIDIA-Linux-x86_64-430.40.run' |
| 67 | + wget --no-verbose --no-clobber -P ~/nvidia-downloads http://developer.download.nvidia.com/compute/cuda/10.2/Prod/local_installers/cuda_10.2.89_440.33.01_linux.run |
| 68 | + sudo /bin/bash ~/nvidia-downloads/NVIDIA-Linux-x86_64-430.40.run --no-drm -q --ui=none |
| 69 | + sudo sh ~/nvidia-downloads/cuda_10.2.89_440.33.01_linux.run --silent |
| 70 | + echo "Done installing CUDA." |
| 71 | + nvidia-smi |
| 72 | +
|
| 73 | +setup_venv: &setup_venv |
| 74 | + - run: |
| 75 | + name: Setup Virtual Environment |
| 76 | + command: | |
| 77 | + python -m venv ~/vissl_venv |
| 78 | + echo ". ~/vissl_venv/bin/activate" >> $BASH_ENV |
| 79 | + . ~/vissl_venv/bin/activate |
| 80 | + python --version |
| 81 | + which python |
| 82 | + which pip |
| 83 | + pip install --upgrade pip |
| 84 | + pip install -U setuptools |
| 85 | +
|
| 86 | +pip_list: &pip_list |
| 87 | + - run: |
| 88 | + name: Pip list |
| 89 | + command: | |
| 90 | + pip list |
| 91 | +
|
| 92 | +install_vissl_dep: &install_vissl_dep |
| 93 | + - run: |
| 94 | + name: Install Dependencies |
| 95 | + working_directory: ~/vissl |
| 96 | + command: | |
| 97 | + pip install --progress-bar off torch==1.5.0 torchvision==0.6.0 opencv-python==3.4.2.17 |
| 98 | + pip install --progress-bar off -r requirements.txt |
| 99 | +
|
| 100 | +install_apex_gpu: &install_apex_gpu |
| 101 | + - run: |
| 102 | + name: Install Apex |
| 103 | + working_directory: ~/vissl |
| 104 | + environment: |
| 105 | + CUDA_VER: "10.2" |
| 106 | + TORCH_CUDA_ARCH_LIST: "5.0;5.2;5.3" |
| 107 | + command: | |
| 108 | + bash ./docker/common/install_apex.sh |
| 109 | +
|
| 110 | +install_apex_cpu: &install_apex_cpu |
| 111 | + - run: |
| 112 | + name: Install Apex for CPU |
| 113 | + working_directory: ~/vissl |
| 114 | + command: | |
| 115 | + pip install -v --no-cache-dir apex@https://github.com/NVIDIA/apex/tarball/1f2aa9156547377a023932a1512752c392d9bbdf |
| 116 | +
|
| 117 | +install_vissl: &install_vissl |
| 118 | + - run: |
| 119 | + name: Install VISSL |
| 120 | + command: | |
| 121 | + pip install -U --progress-bar off -e .[dev] |
| 122 | +
|
| 123 | +run_unittests: &run_unittests |
| 124 | + - run: |
| 125 | + name: Run CPU Unit Tests |
| 126 | + command: | |
| 127 | + python -m unittest discover -v -s tests |
| 128 | +
|
| 129 | +# ------------------------------------------------------------------------------------- |
| 130 | +# Jobs to run (cpu and gpu) |
| 131 | +# ------------------------------------------------------------------------------------- |
| 132 | +jobs: |
| 133 | + cpu_tests: |
| 134 | + <<: *cpu |
| 135 | + |
| 136 | + working_directory: ~/vissl |
| 137 | + |
| 138 | + steps: |
| 139 | + - checkout |
| 140 | + - <<: *install_python |
| 141 | + - <<: *setup_venv |
| 142 | + |
| 143 | + # Cache the vissl_venv directory that contains dependencies |
| 144 | + - restore_cache: |
| 145 | + keys: |
| 146 | + - v2-cpu-dependencies-{{ checksum "requirements.txt" }}-{{ checksum "setup.py" }} |
| 147 | + |
| 148 | + - <<: *install_vissl_dep |
| 149 | + - <<: *install_classy_vision |
| 150 | + - <<: *install_apex_cpu |
| 151 | + - <<: *pip_list |
| 152 | + |
| 153 | + - save_cache: |
| 154 | + paths: |
| 155 | + - ~/vissl_venv |
| 156 | + key: v2-cpu-dependencies-{{ checksum "requirements.txt" }}-{{ checksum "setup.py" }} |
| 157 | + |
| 158 | + - <<: *install_vissl |
| 159 | + |
| 160 | + - run: |
| 161 | + name: isort |
| 162 | + command: | |
| 163 | + isort -y -sp . |
| 164 | + - run: |
| 165 | + name: black |
| 166 | + command: | |
| 167 | + black . |
| 168 | + - run: |
| 169 | + name: flake8 |
| 170 | + command: | |
| 171 | + flake8 --max-line-length 88 --ignore E501,E203,E266,W503,E741 . |
| 172 | +
|
| 173 | + - <<: *run_unittests |
| 174 | + |
| 175 | + gpu_tests: |
| 176 | + <<: *gpu |
| 177 | + |
| 178 | + working_directory: ~/vissl |
| 179 | + |
| 180 | + steps: |
| 181 | + - checkout |
| 182 | + - <<: *setupcuda |
| 183 | + - <<: *install_python |
| 184 | + - <<: *setup_venv |
| 185 | + |
| 186 | + # Download and cache dependencies |
| 187 | + - restore_cache: |
| 188 | + keys: |
| 189 | + - v2-gpu-dependencies-{{ checksum "requirements.txt" }}-{{ checksum "setup.py" }}-{{ checksum "docker/common/install_apex.sh" }} |
| 190 | + |
| 191 | + - <<: *install_vissl_dep |
| 192 | + - <<: *install_classy_vision |
| 193 | + - <<: *update_gcc7 |
| 194 | + - <<: *install_apex_gpu |
| 195 | + - <<: *pip_list |
| 196 | + |
| 197 | + - run: |
| 198 | + name: Check CUDA Available |
| 199 | + command: python -c "import torch; assert torch.cuda.is_available(), 'CUDA not available'" |
| 200 | + |
| 201 | + - save_cache: |
| 202 | + paths: |
| 203 | + - ~/vissl_venv |
| 204 | + key: v2-gpu-dependencies-{{ checksum "requirements.txt" }}-{{ checksum "setup.py" }}-{{ checksum "docker/common/install_apex.sh" }} |
| 205 | + |
| 206 | + - <<: *install_vissl |
| 207 | + |
| 208 | + - run: |
| 209 | + name: Run GPU tests |
| 210 | + command: bash ./dev/run_quick_tests.sh |
| 211 | + |
| 212 | +# ------------------------------------------------------------------------------------- |
| 213 | +# Workflows |
| 214 | +# ------------------------------------------------------------------------------------- |
| 215 | +workflows: |
| 216 | + version: 2 |
| 217 | + build_and_test: |
| 218 | + jobs: |
| 219 | + - cpu_tests |
| 220 | + - gpu_tests |
0 commit comments