Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
198 changes: 165 additions & 33 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,27 @@ cpu: &cpu
image: ubuntu-2004:202107-02
resource_class: medium

gpu: &gpu
cuda111: &cuda111
machine:
# NOTE: use a cuda version that's supported by all our pytorch versions
image: ubuntu-1604-cuda-11.1:202012-01
resource_class: gpu.nvidia.small

cuda114: &cuda114
machine:
image: ubuntu-2004-cuda-11.4:202110-01
resource_class: gpu.nvidia.small

windows-cpu: &windows_cpu
machine:
resource_class: windows.medium
image: windows-server-2019-vs2019:stable
shell: powershell.exe
resource_class: windows.medium
shell: powershell.exe

# windows-gpu: &windows_gpu
# machine:
# resource_class: windows.gpu.nvidia.medium
# image: windows-server-2019-nvidia:stable
# resource_class: windows.gpu.nvidia.medium

version_parameters: &version_parameters
parameters:
Expand All @@ -36,7 +41,7 @@ version_parameters: &version_parameters
# use test wheels index to have access to RC wheels
# https://download.pytorch.org/whl/test/torch_test.html
default: "https://download.pytorch.org/whl/torch_stable.html"
python_version: # NOTE: only affect linux
python_version: # NOTE: only affects linux
type: string
default: '3.8.6'

Expand All @@ -60,6 +65,37 @@ version_parameters: &version_parameters
# sudo /bin/bash ./NVIDIA-Linux-x86_64-430.40.run -s --no-drm
# nvidia-smi

setupcuda113: &setupcuda113
run:
name: Setup CUDA 11.3
working_directory: ~/
command: |
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-ubuntu2004.pin
sudo mv cuda-ubuntu2004.pin /etc/apt/preferences.d/cuda-repository-pin-600
sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/3bf863cc.pub
sudo add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/ /"
sudo apt-get update
sudo apt-get -y install cuda-11-3
sudo update-alternatives --install /usr/local/cuda cuda /usr/local/cuda-11.3 50
echo "Done installing CUDA 11.3"
sudo apt autoremove
sudo apt-get clean
nvidia-smi
sudo update-alternatives --display cuda

removecuda114: &removecuda114
run:
name: Remove CUDA 11.4
working_directory: ~/
command: |
echo "Remove CUDA 11.4"
sudo update-alternatives --remove cuda /usr/local/cuda-11.4
sudo apt-get -y remove --purge cuda-11-4
sudo apt autoremove
sudo apt-get clean
echo "Done removing CUDA 11.4"
sudo update-alternatives --display cuda

add_ssh_keys: &add_ssh_keys
# https://circleci.com/docs/2.0/add-ssh-key/
- add_ssh_keys:
Expand All @@ -71,10 +107,10 @@ install_python: &install_python
name: Install Python
working_directory: ~/
command: |
# upgrade pyenv
cd /opt/circleci/.pyenv/plugins/python-build/../.. && git pull && cd -
pyenv install -s $PYTHON_VERSION
pyenv global $PYTHON_VERSION
cd /opt/circleci/.pyenv/plugins/python-build/../.. && git pull && cd
pyenv install -l
pyenv install -s ${PYTHON_VERSION}
pyenv global ${PYTHON_VERSION}
python --version
which python
pip install --upgrade pip
Expand All @@ -85,7 +121,7 @@ setup_venv: &setup_venv
working_directory: ~/
command: |
python -m venv ~/venv
echo ". ~/venv/bin/activate" >> $BASH_ENV
echo ". ~/venv/bin/activate" >> ${BASH_ENV}
. ~/venv/bin/activate
python --version
which python
Expand Down Expand Up @@ -115,14 +151,30 @@ install_linux_dep: &install_linux_dep
# Don't use pytest-xdist: cuda tests are unstable under multi-process workers.
# Don't use opencv 4.7.0.68: https://github.com/opencv/opencv-python/issues/765
pip install --progress-bar off ninja opencv-python-headless!=4.7.0.68 pytest tensorboard pycocotools onnx
pip install --progress-bar off torch==$PYTORCH_VERSION -f $PYTORCH_INDEX
if [[ "$TORCHVISION_VERSION" == "master" ]]; then
pip install git+https://github.com/pytorch/vision.git
pip install -v --progress-bar off omegaconf
if [[ "${PYTORCH_VERSION}" == "master" ]]; then
echo "Installing torch/torchvision from ${PYTORCH_INDEX}"
# Remove first, in case it's in the CI cache
pip uninstall -y torch torchvision
pip install -v --progress-bar off --pre torch torchvision --extra-index-url ${PYTORCH_INDEX}
else
pip install --progress-bar off torchvision==$TORCHVISION_VERSION -f $PYTORCH_INDEX
LABEL_VERSION=$(echo "${PYTORCH_VERSION}" | cut -d "+" -f 2 -s)
echo "Installing torch==${PYTORCH_VERSION} and torchvision==${TORCHVISION_VERSION} from ${PYTORCH_INDEX} and label version ${LABEL_VERSION}"
if [[ "${LABEL_VERSION}" == "cu113" ]]; then
pip install -v --progress-bar off torch==${PYTORCH_VERSION} torchvision==${TORCHVISION_VERSION} --extra-index-url ${PYTORCH_INDEX}
else
pip install -v --progress-bar off torch==${PYTORCH_VERSION} torchvision==${TORCHVISION_VERSION} -f ${PYTORCH_INDEX}
fi
fi

python -c 'import torch; print("PyTorch Version:", torch.__version__)'
python -c 'import torchvision; print("TorchVision Version:", torchvision.__version__)'
python -c 'import torch; print("CUDA:", torch.cuda.is_available())'
echo "Python packages"
python -c "import sys; print(sys.executable)"
python --version
pip list
echo "GCC Compiler"
gcc --version

install_detectron2: &install_detectron2
Expand Down Expand Up @@ -170,7 +222,7 @@ jobs:
# Refresh the key when dependencies should be updated (e.g. when pytorch releases)
- restore_cache:
keys:
- cache-{{ arch }}-<< parameters.pytorch_version >>-{{ .Branch }}-20210827
- cache-{{ arch }}-<< parameters.pytorch_version >>-{{ .Branch }}-20990009

- <<: *install_python
- <<: *install_linux_dep
Expand All @@ -182,11 +234,35 @@ jobs:
paths:
- /opt/circleci/.pyenv
- ~/.torch
key: cache-{{ arch }}-<< parameters.pytorch_version >>-{{ .Branch }}-20210827
key: cache-{{ arch }}-<< parameters.pytorch_version >>-{{ .Branch }}-20990009

linux_cuda111_tests:
<<: *cuda111
<<: *version_parameters

working_directory: ~/detectron2

steps:
- checkout

- restore_cache:
keys:
- cache-{{ arch }}-<< parameters.pytorch_version >>-{{ .Branch }}-20990009

- <<: *install_python
- <<: *install_linux_dep
- <<: *install_detectron2
- <<: *run_unittests
- <<: *uninstall_tests

linux_gpu_tests:
<<: *gpu
- save_cache:
paths:
- /opt/circleci/.pyenv
- ~/.torch
key: cache-{{ arch }}-<< parameters.pytorch_version >>-{{ .Branch }}-20990009

linux_cuda113_tests:
<<: *cuda114
<<: *version_parameters

working_directory: ~/detectron2
Expand All @@ -196,8 +272,10 @@ jobs:

- restore_cache:
keys:
- cache-{{ arch }}-<< parameters.pytorch_version >>-{{ .Branch }}-20210827
- cache-{{ arch }}-<< parameters.pytorch_version >>-{{ .Branch }}-20990009

- <<: *setupcuda113
- <<: *removecuda114
Comment on lines +277 to +278
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't it remove 114 first then setup 113?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removing 11.4 first and installing 11.3 would result in uninstalling several shared components only to reinstall later, increasing installation time. Keeping the current order does not affect the end result and save some time

- <<: *install_python
- <<: *install_linux_dep
- <<: *install_detectron2
Expand All @@ -208,7 +286,8 @@ jobs:
paths:
- /opt/circleci/.pyenv
- ~/.torch
key: cache-{{ arch }}-<< parameters.pytorch_version >>-{{ .Branch }}-20210827
key: cache-{{ arch }}-<< parameters.pytorch_version >>-{{ .Branch }}-20990009

Copy link
Contributor

Choose a reason for hiding this comment

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

There're a lot of duplication between linux_cuda111_tests, linux_cuda113_tests and linux_cuda117_tests, it would be nice to make it a bit more concise.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not really familiar with CircleCI. I've just winged based on sampels. Any ideas on how to templatize even more?
The - <<: construction is already an abstraction layer, but maybe we can group them in a larger template if CircleCI has such mechanism


windows_cpu_build:
<<: *windows_cpu
Expand All @@ -221,7 +300,7 @@ jobs:
# Cache the env directory that contains dependencies
- restore_cache:
keys:
- cache-{{ arch }}-<< parameters.pytorch_version >>-{{ .Branch }}-20210404
- cache-{{ arch }}-<< parameters.pytorch_version >>-{{ .Branch }}-20990009

- run:
name: Install Dependencies
Expand All @@ -231,12 +310,28 @@ jobs:
pip install opencv-python-headless pytest-xdist pycocotools tensorboard onnx
pip install -U git+https://github.com/facebookresearch/iopath
pip install -U git+https://github.com/facebookresearch/fvcore
pip install torch==$env:PYTORCH_VERSION torchvision==$env:TORCHVISION_VERSION -f $env:PYTORCH_INDEX
if($env:PYTORCH_VERSION -eq "master"){
Write-Output "Installing torch/torchvision from $env:PYTORCH_INDEX"
pip uninstall -y torch torchvision
pip install --progress-bar off --pre torch torchvision --extra-index-url $env:PYTORCH_INDEX
}else{
Write-Output "Installing torch==$env:PYTORCH_VERSION and torchvision==$env:TORCHVISION_VERSION from $env:PYTORCH_INDEX"
pip install --progress-bar off torch==$env:PYTORCH_VERSION torchvision==$env:TORCHVISION_VERSION -f $env:PYTORCH_INDEX
}
python -c 'import torch; print("PyTorch Version:", torch.__version__)'
python -c 'import torchvision; print("TorchVision Version:", torchvision.__version__)'
python -c 'import torch; print("CUDA:", torch.cuda.is_available())'
Write-Output "Python packages"
python -c "import sys; print(sys.executable)"
python --version
pip list
echo "OS Environment Variables"
dir env:

- save_cache:
paths:
- env
key: cache-{{ arch }}-<< parameters.pytorch_version >>-{{ .Branch }}-20210404
key: cache-{{ arch }}-<< parameters.pytorch_version >>-{{ .Branch }}-20990009

- <<: *install_detectron2
# TODO: unittest fails for now
Expand All @@ -249,23 +344,60 @@ workflows:
name: linux_cpu_tests_pytorch1.10
pytorch_version: '1.10.0+cpu'
torchvision_version: '0.11.1+cpu'
- linux_gpu_tests:
name: linux_gpu_tests_pytorch1.8
- linux_cpu_tests:
name: linux_cpu_tests_pytorch1.11
python_version: '3.9.4'
pytorch_version: '1.11.0'
torchvision_version: '0.12.0'
pytorch_index: 'https://download.pytorch.org/whl/cpu'
- linux_cpu_tests:
name: linux_cpu_tests_pytorch1.12
python_version: '3.9.4'
pytorch_version: '1.12.1'
torchvision_version: '0.13.1'
pytorch_index: 'https://download.pytorch.org/whl/cpu'
- linux_cuda111_tests:
name: linux_cuda111_tests_pytorch1.8
pytorch_version: '1.8.1+cu111'
torchvision_version: '0.9.1+cu111'
- linux_gpu_tests:
name: linux_gpu_tests_pytorch1.9
- linux_cuda111_tests:
name: linux_cuda111_tests_pytorch1.9
pytorch_version: '1.9+cu111'
torchvision_version: '0.10+cu111'
- linux_gpu_tests:
name: linux_gpu_tests_pytorch1.10
pytorch_version: '1.10+cu111'
- linux_cuda111_tests:
name: linux_cuda111_tests_pytorch1.10
pytorch_version: '1.10.0+cu111'
torchvision_version: '0.11.1+cu111'
- linux_gpu_tests:
name: linux_gpu_tests_pytorch1.10_python39
pytorch_version: '1.10+cu111'
- linux_cuda111_tests:
name: linux_cuda111_tests_pytorch1.10_python39
pytorch_version: '1.10.0+cu111'
torchvision_version: '0.11.1+cu111'
python_version: '3.9.6'
- linux_cuda113_tests:
name: linux_cuda113_tests_pytorch1.11_python39
pytorch_version: '1.11.0+cu113'
torchvision_version: '0.12.0+cu113'
python_version: '3.9.4'
pytorch_index: 'https://download.pytorch.org/whl/cu113'
- linux_cuda113_tests:
name: linux_cuda113_tests_pytorch1.12_python39
pytorch_version: '1.12.1+cu113'
torchvision_version: '0.13.1+cu113'
python_version: '3.9.4'
pytorch_index: 'https://download.pytorch.org/whl/cu113'
- windows_cpu_build:
name: windows_cpu_build_pytorch1.10
pytorch_version: '1.10+cpu'
torchvision_version: '0.11.1+cpu'
- windows_cpu_build:
name: windows_cpu_build_pytorch_1.11
pytorch_version: '1.11.0+cpu'
torchvision_version: '0.12.0+cpu'
python_version: '3.7.3'
pytorch_index: 'https://download.pytorch.org/whl/cpu'
- windows_cpu_build:
name: windows_cpu_build_pytorch_1.12
pytorch_version: '1.12.1+cpu'
torchvision_version: '0.13.1+cpu'
python_version: '3.7.3'
pytorch_index: 'https://download.pytorch.org/whl/cpu'
32 changes: 28 additions & 4 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,18 @@ jobs:
strategy:
fail-fast: false
matrix:
torch: ["1.8", "1.9", "1.10"]
torch: ["1.8", "1.9", "1.10", "1.11.0", "1.12.1"]
include:
- torch: "1.8"
torchvision: 0.9
torchvision: "0.9"
- torch: "1.9"
torchvision: "0.10"
- torch: "1.10"
torchvision: "0.11.1"
- torch: "1.11.0"
torchvision: "0.12.0"
- torch: "1.12.1"
torchvision: "0.13.1"
env:
# point datasets to ~/.torch so it's cached by CI
DETECTRON2_DATASETS: ~/.torch/datasets
Expand All @@ -61,17 +65,37 @@ jobs:
path: |
${{ env.pythonLocation }}/lib/python3.8/site-packages
~/.torch
key: ${{ runner.os }}-torch${{ matrix.torch }}-${{ hashFiles('setup.py') }}-20220119
key: ${{ runner.os }}-torch${{ matrix.torch }}-${{ hashFiles('setup.py') }}-20990009

- name: Install dependencies
run: |
python -m pip install -U pip
python -m pip install ninja opencv-python-headless onnx pytest-xdist
python -m pip install torch==${{matrix.torch}} torchvision==${{matrix.torchvision}} -f https://download.pytorch.org/whl/torch_stable.html
if [[ "${{matrix.torch}}" == "master" ]]; then
echo "Installing torch/torchvision from ${{matrix.pytorch_index}}"
# Remove first, in case it's in the CI cache
pip uninstall -y torch torchvision
pip install -v --pre torch>1.11 torchvision>0.12 --progress-bar off -f ${{matrix.pytorch_index}}
else
echo "Installing torch==${{matrix.torch}} and torchvision==${{matrix.torchvision}}"
python -m pip install --progress-bar off torch==${{matrix.torch}} torchvision==${{matrix.torchvision}}
fi

# install from github to get latest; install iopath first since fvcore depends on it
python -m pip install -U 'git+https://github.com/facebookresearch/iopath'
python -m pip install -U 'git+https://github.com/facebookresearch/fvcore'

python -c 'import torch; print("PyTorch Version:", torch.__version__)'
python -c 'import torchvision; print("TorchVision Version:", torchvision.__version__)'
python -c 'import torch; print("CUDA:", torch.cuda.is_available())'
echo "Python packages"
pip list
echo "GCC Compiler"
gcc --version
echo "Environment Variables"
env


- name: Build and install
run: |
CC=clang CXX=clang++ python -m pip install -e .[all]
Expand Down
Loading