From 2a82b52b8d4a0d75d133ffdabf894ef4af39fb3d Mon Sep 17 00:00:00 2001 From: Zaida Zhou <58739961+zhouzaida@users.noreply.github.com> Date: Wed, 14 Sep 2022 19:37:12 +0800 Subject: [PATCH] Update configs of circleci and github action (#2255) * Update configs of circleci and github action * fix base-revision * remove psutil from ci * fix ci * update circleci * update circleci * fix typo * fix typo * fix typo * fix ut * install mmengine from main branch * update github action * update github action * install git * install git * update ci * update ci of merged stage * fix typo * fix typo * fix onnx compilation error * fix onnx compilation error * use sudo to install packages * fix onnx installation * modify python version * update * install git in circleci * use sudo * install git * update * test on 2.x branch --- .circleci/config.yml | 192 +++------------- .circleci/docker/Dockerfile | 15 ++ .circleci/test.yml | 270 ++++++++++++++++++++++ .github/workflows/build.yml | 121 ---------- .github/workflows/merge_stage_test.yml | 299 +++++++++++++++++++++++++ .github/workflows/pr_stage_test.yml | 179 +++++++++++++++ requirements/test.txt | 8 +- 7 files changed, 795 insertions(+), 289 deletions(-) create mode 100644 .circleci/docker/Dockerfile create mode 100644 .circleci/test.yml delete mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/merge_stage_test.yml create mode 100644 .github/workflows/pr_stage_test.yml diff --git a/.circleci/config.yml b/.circleci/config.yml index 4fced2cd2..e13eabe9c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,170 +1,32 @@ version: 2.1 -jobs: - lint: - docker: - - image: cimg/python:3.7.4 - steps: - - checkout - - run: - name: Install pre-commit hook - command: | - pip install pre-commit - pre-commit install - - run: - name: Linting - command: pre-commit run --all-files - build_cpu: - parameters: - # The python version must match available image tags in - # https://circleci.com/developer/images/image/cimg/python - python: - type: string - default: "3.7.0" - torch: - type: string - torchvision: - type: string - machine: - image: ubuntu-2004:202010-01 - resource_class: large - steps: - - checkout - - run: - name: Install system dependencies - command: | - sudo apt-get update - sudo apt-get install -y ffmpeg libturbojpeg ninja-build - ffmpeg -version - - run: - # https://github.com/pytorch/vision/issues/2921 - name: Install dependency of torchvision when using pyenv - command: sudo apt-get install -y liblzma-dev - - run: - # python3.7 should be re-installed due to the issue https://github.com/pytorch/vision/issues/2921 - name: Select Python - command: | - pyenv uninstall -f << parameters.python >> - pyenv install << parameters.python >> - pyenv global << parameters.python >> - - run: - name: Upgrade pip - command: | - python -m pip install pip --upgrade - - run: - name: Install PyTorch - command: python -m pip install torch==<< parameters.torch >>+cpu torchvision==<< parameters.torchvision >>+cpu -f https://download.pytorch.org/whl/torch_stable.html - - run: - name: Install MMEngine - command: pip install git+ssh://git@github.com/open-mmlab/mmengine.git - - run: - name: Install psutil - command: python -m pip install psutil - - run: - name: Build and install - command: | - rm -rf .eggs - python setup.py check -m -s - python -m pip install -e . - no_output_timeout: 20m - environment: - MMCV_WITH_OPS: 1 - - run: - name: Install dependencies of unit test - command: | - python -m pip install -r requirements/test.txt - - run: - name: Run unittests and generate coverage report - command: | - python -m coverage run --branch --source mmcv -m pytest tests/ - python -m coverage xml - python -m coverage report -m +# this allows you to use CircleCI's dynamic configuration feature +setup: true + +# the path-filtering orb is required to continue a pipeline based on +# the path of an updated fileset +orbs: + path-filtering: circleci/path-filtering@0.1.2 - build_cu102: - machine: - image: ubuntu-1604-cuda-10.1:201909-23 # the actual version of cuda is 10.2 - resource_class: gpu.nvidia.small - steps: - - checkout - - run: - name: Set CUDA environment - command: | - echo 'export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH' >> $BASH_ENV - echo 'export PATH=/usr/local/cuda/bin:$PATH' >> $BASH_ENV - echo 'export CUDA_HOME=/usr/local/cuda' >> $BASH_ENV - source $BASH_ENV - nvidia-smi - nvcc --version - gcc --version - - run: - name: Install system dependencies - command: | - sudo apt-get update - sudo apt-get install -y libturbojpeg ninja-build - # the default version of ffmpeg is 2.8.7, which should be upgraded to 4+ - sudo add-apt-repository -y ppa:jonathonf/ffmpeg-4 - sudo apt-get update - sudo apt-get install -y ffmpeg - ffmpeg -version - sudo add-apt-repository --remove ppa:jonathonf/ffmpeg-4 -y - - run: - # https://github.com/pytorch/vision/issues/2921 - name: Install dependency of torchvision when using pyenv - command: sudo apt-get install -y liblzma-dev - - run: - # python3.7 should be re-installed due to the issue https://github.com/pytorch/vision/issues/2921 - name: Select python3.7 - command: | - pyenv uninstall -f 3.7.0 - pyenv install 3.7.0 - pyenv global 3.7.0 - - run: - name: Upgrade pip - command: | - python -m pip install pip --upgrade - - run: - name: Install PyTorch - command: python -m pip install torch==1.8.1+cu102 torchvision==0.9.1+cu102 -f https://download.pytorch.org/whl/torch_stable.html - - run: - name: Install MMEngine - command: pip install git+ssh://git@github.com/open-mmlab/mmengine.git - - run: - name: Install psutil - command: python -m pip install psutil - - run: - name: Build and install - command: | - rm -rf .eggs - python setup.py check -m -s - python -m pip install -e . - environment: - MMCV_WITH_OPS: 1 - MMCV_WITH_ORT: 1 - - run: - name: Install dependencies for unit test - command: | - python -m pip install -r requirements/test.txt - - run: - name: Run unittests and generate coverage report - command: | - python -m coverage run --branch --source mmcv -m pytest tests/ - python -m coverage xml - python -m coverage report -m workflows: - unit_tests: + # the always-run workflow is always triggered, regardless of the pipeline parameters. + always-run: jobs: - - lint - - build_cpu: - name: build_py3.8_pt1.9_cpu - torch: 1.9.0 - torchvision: 0.10.0 - python: "3.8.0" - requires: - - lint - - hold: - type: approval # <<< This key-value pair will set your workflow to a status of "On Hold" - requires: - - build_py3.8_pt1.9_cpu - - build_cu102: - requires: - - hold + # the path-filtering/filter job determines which pipeline + # parameters to update. + - path-filtering/filter: + name: check-updated-files + # 3-column, whitespace-delimited mapping. One mapping per + # line: + # + mapping: | + mmcv/.* lint_only false + requirements/.* lint_only false + tests/.* lint_only false + .circleci/.* lint_only false + base-revision: 2.x + # this is the path of the configuration we should trigger once + # path filtering and pipeline parameter value updates are + # complete. In this case, we are using the parent dynamic + # configuration itself. + config-path: .circleci/test.yml diff --git a/.circleci/docker/Dockerfile b/.circleci/docker/Dockerfile new file mode 100644 index 000000000..db5ab86e3 --- /dev/null +++ b/.circleci/docker/Dockerfile @@ -0,0 +1,15 @@ +ARG PYTORCH="1.8.1" +ARG CUDA="10.2" +ARG CUDNN="7" + +FROM pytorch/pytorch:${PYTORCH}-cuda${CUDA}-cudnn${CUDNN}-devel + +# Set MKL_THREADING_LAYER=GNU to fix issue: +# https://github.com/pytorch/pytorch/issues/37377 +ENV MKL_THREADING_LAYER GNU + +# To fix GPG key error when running apt-get update +RUN apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/3bf863cc.pub +RUN apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64/7fa2af80.pub + +RUN apt-get update && apt-get install -y ninja-build libglib2.0-0 libsm6 libxrender-dev libxext6 libgl1-mesa-glx ffmpeg libturbojpeg git diff --git a/.circleci/test.yml b/.circleci/test.yml new file mode 100644 index 000000000..f86b54ace --- /dev/null +++ b/.circleci/test.yml @@ -0,0 +1,270 @@ +version: 2.1 + +# the default pipeline parameters, which will be updated according to +# the results of the path-filtering orb +parameters: + lint_only: + type: boolean + default: true + +jobs: + lint: + docker: + - image: cimg/python:3.7.4 + steps: + - checkout + - run: + name: Install pre-commit hook + command: | + pip install pre-commit + pre-commit install + - run: + name: Linting + command: pre-commit run --all-files + build_without_torch: + parameters: + # The python version must match available image tags in + # https://circleci.com/developer/images/image/cimg/python + python: + type: string + default: "3.7.4" + docker: + - image: cimg/python:<< parameters.python >> + resource_class: large + steps: + - checkout + - run: + name: Install Libraries + command: | + sudo apt-get update + sudo apt-get install -y ninja-build libglib2.0-0 libsm6 libxrender-dev libxext6 libgl1-mesa-glx libjpeg-dev zlib1g-dev libtinfo-dev libncurses5 ffmpeg libturbojpeg + - run: + name: Upgrade pip + command: | + pip install pip --upgrade + pip --version + - run: + name: Install MMEngine from main branch + command: pip install git+https://github.com/open-mmlab/mmengine.git@main + - run: + name: Build MMCV from source + command: pip install -e . -v + environment: + MMCV_WITH_OPS: 0 + - run: + name: Install unit tests dependencies + command: pip install -r requirements/test.txt + - run: + name: Run unit tests + command: pytest tests/test_image tests/test_transforms tests/test_video tests/test_arraymisc.py tests/test_visualization.py tests/test_utils/test_env.py --ignore=tests/test_image/test_io.py + build_without_ops: + parameters: + # The python version must match available image tags in + # https://circleci.com/developer/images/image/cimg/python + python: + type: string + default: "3.7.4" + torch: + type: string + torchvision: + type: string + docker: + - image: cimg/python:<< parameters.python >> + resource_class: large + steps: + - checkout + - run: + name: Install Libraries + command: | + sudo apt-get update + sudo apt-get install -y ninja-build libglib2.0-0 libsm6 libxrender-dev libxext6 libgl1-mesa-glx libjpeg-dev zlib1g-dev libtinfo-dev libncurses5 ffmpeg libturbojpeg + - run: + name: Configure Python & pip + command: | + pip install --upgrade pip + pip install wheel + - run: + name: Install PyTorch + command: pip install torch==<< parameters.torch >>+cpu torchvision==<< parameters.torchvision >>+cpu -f https://download.pytorch.org/whl/torch_stable.html + - run: + name: Install MMEngine from main branch + command: pip install git+https://github.com/open-mmlab/mmengine.git@main + - run: + name: Create sdist and untar + command: | + sed -i "s/os.getenv('MMCV_WITH_OPS', '1')/os.getenv('MMCV_WITH_OPS', '0')/g" setup.py + python setup.py sdist + tar zxvf dist/mmcv* -C /tmp + rm -r mmcv + - run: + name: Build and install from sdist + command: | + pushd /tmp/mmcv* + pip install -e . -v + popd + - run: + name: Install unit tests dependencies + command: pip install -r requirements/test.txt + - run: + name: Run unit tests + command: pytest tests --ignore=tests/test_ops + build_cpu: + parameters: + # The python version must match available image tags in + # https://circleci.com/developer/images/image/cimg/python + python: + type: string + torch: + type: string + torchvision: + type: string + docker: + - image: cimg/python:<< parameters.python >> + resource_class: large + steps: + - checkout + - run: + name: Install Libraries + command: | + sudo apt-get update + sudo apt-get install -y ninja-build libglib2.0-0 libsm6 libxrender-dev libxext6 libgl1-mesa-glx libjpeg-dev zlib1g-dev libtinfo-dev libncurses5 ffmpeg libturbojpeg + - run: + name: Configure Python & pip + command: | + pip install --upgrade pip + pip install wheel + - run: + name: Install PyTorch + command: pip install torch==<< parameters.torch >>+cpu torchvision==<< parameters.torchvision >>+cpu -f https://download.pytorch.org/whl/torch_stable.html + - run: + name: Install MMEngine from main branch + command: pip install git+https://github.com/open-mmlab/mmengine.git@main + - run: + name: Install ninja to speed the compilation + command: pip install ninja + - run: + name: Create sdist and untar + command: | + python setup.py sdist + tar zxvf dist/mmcv* -C /tmp + rm -r mmcv + - run: + name: Build and install from sdist + command: | + pushd /tmp/mmcv* + pip install -e . -v + popd + - run: + name: Install unit tests dependencies + command: pip install -r requirements/test.txt + - run: + name: Run unittests + command: | + coverage run --branch --source mmcv -m pytest tests/ + coverage xml + coverage report -m + build_cuda: + parameters: + torch: + type: string + cuda: + type: enum + enum: ["10.1", "10.2", "11.1"] + cudnn: + type: integer + default: 7 + machine: + image: ubuntu-2004-cuda-11.4:202110-01 + docker_layer_caching: true + resource_class: gpu.nvidia.small + steps: + - checkout + - run: + name: Build Docker image + command: | + docker build .circleci/docker -t mmcv:gpu --build-arg PYTORCH=<< parameters.torch >> --build-arg CUDA=<< parameters.cuda >> --build-arg CUDNN=<< parameters.cudnn >> + docker run --gpus all -t -d -v /home/circleci/project:/mmcv -w /mmcv --name mmcv mmcv:gpu + - run: + name: Install MMEngine from main branch + command: docker exec mmcv pip install git+https://github.com/open-mmlab/mmengine.git@main + - run: + name: Build MMCV from source + command: docker exec mmcv pip install -e . -v + - run: + name: Install unit tests dependencies + command: docker exec mmcv pip install -r requirements/test.txt + - run: + name: Run unittests + command: docker exec mmcv python -m pytest tests/ +workflows: + pr_stage_lint: + when: << pipeline.parameters.lint_only >> + jobs: + - lint: + name: lint + filters: + branches: + ignore: + - 2.x + pr_stage_test: + when: + not: + << pipeline.parameters.lint_only >> + jobs: + - lint: + name: lint + filters: + branches: + ignore: + - 2.x + - build_without_torch: + name: build_without_torch + requires: + - lint + - build_without_ops: + name: build_without_ops + torch: 1.6.0 + torchvision: 0.7.0 + requires: + - build_without_torch + - build_cpu: + name: minimum_version_cpu + torch: 1.6.0 + torchvision: 0.7.0 + python: 3.6.9 # The lowest python 3.6.x version available on CircleCI images + requires: + - build_without_ops + - build_cpu: + name: maximum_version_cpu + torch: 1.12.1 + torchvision: 0.13.1 + python: 3.9.0 + requires: + - minimum_version_cpu + - hold: + type: approval + requires: + - maximum_version_cpu + - build_cuda: + name: mainstream_version_gpu + torch: 1.8.1 + # Use double quotation mark to explicitly specify its type + # as string instead of number + cuda: "10.2" + requires: + - hold + merge_stage_test: + when: + not: + << pipeline.parameters.lint_only >> + jobs: + - build_cuda: + name: minimum_version_gpu + torch: 1.6.0 + # Use double quotation mark to explicitly specify its type + # as string instead of number + cuda: "10.1" + filters: + branches: + only: + - 2.x diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 3db3b343a..000000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,121 +0,0 @@ -name: build - -on: - push: - paths-ignore: - - 'README.md' - - 'README_zh-CN.md' - - 'docs/**' - - 'examples/**' - - '.dev_scripts/**' - - 'docker/**' - - pull_request: - paths-ignore: - - 'README.md' - - 'README_zh-CN.md' - - 'docs/**' - - 'examples/**' - - '.dev_scripts/**' - - 'docker/**' - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -env: - MMCV_WITH_OPS: 1 - -jobs: - build_without_ops: - runs-on: ubuntu-18.04 - env: - MMCV_WITH_OPS: 0 - strategy: - matrix: - python-version: [3.7] - torch: [1.7.0, 1.8.0, 1.9.0] - include: - - torch: 1.7.0 - torchvision: 0.8.1 - - torch: 1.8.0 - torchvision: 0.9.0 - - torch: 1.9.0 - torchvision: 0.10.0 - steps: - - uses: actions/checkout@v2 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - name: Install system dependencies - run: sudo apt-get update && sudo apt-get install -y ffmpeg libturbojpeg openssh-client - - name: Install PyTorch - run: pip install torch==${{matrix.torch}}+cpu torchvision==${{matrix.torchvision}}+cpu -f https://download.pytorch.org/whl/torch_stable.html - - name: Install MMEngine - run: | - eval `ssh-agent -s` - ssh-add - <<< '${{ secrets.TEST_SSH_KEY }}' - pip install git+ssh://git@github.com/open-mmlab/mmengine.git - - name: Build and install - run: rm -rf .eggs && pip install -e . - - name: Validate the installation - run: python -c "import mmcv" - - name: Run unittests - run: | - pip install -r requirements/test.txt - pytest tests/ --ignore=tests/test_ops - - build_cpu: - runs-on: ubuntu-18.04 - strategy: - matrix: - python-version: [3.7] - torch: [1.5.1, 1.6.0, 1.7.0, 1.8.0, 1.9.0] - include: - - torch: 1.5.1 - torchvision: 0.6.1 - - torch: 1.6.0 - torchvision: 0.7.0 - - torch: 1.7.0 - torchvision: 0.8.1 - - torch: 1.8.0 - torchvision: 0.9.0 - - torch: 1.9.0 - torchvision: 0.10.0 - steps: - - uses: actions/checkout@v2 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - name: Install system dependencies - run: sudo apt-get update && sudo apt-get install -y ffmpeg libturbojpeg openssh-client - - name: Install PyTorch - run: pip install torch==${{matrix.torch}}+cpu torchvision==${{matrix.torchvision}}+cpu -f https://download.pytorch.org/whl/torch_stable.html - - name: Install MMEngine - run: | - eval `ssh-agent -s` - ssh-add - <<< '${{ secrets.TEST_SSH_KEY }}' - pip install git+ssh://git@github.com/open-mmlab/mmengine.git - # pstuil is an optional package to detect the number of CPU for compiling mmcv - - name: Install psutil - run: pip install psutil - - name: Create sdist and untar - run: | - python setup.py sdist - tar zxvf dist/mmcv* -C /tmp - rm -r mmcv - - name: Build and install from sdist - run: | - pushd /tmp/mmcv* - pip install -e . - popd - - name: Validate the installation - run: python -c "import mmcv" - - name: Run unittests and generate coverage report - run: | - pip install -r requirements/test.txt - coverage run --branch --source=mmcv -m pytest tests/ - coverage xml - coverage report -m diff --git a/.github/workflows/merge_stage_test.yml b/.github/workflows/merge_stage_test.yml new file mode 100644 index 000000000..a43919ea9 --- /dev/null +++ b/.github/workflows/merge_stage_test.yml @@ -0,0 +1,299 @@ +name: merge_stage_test + +on: + push: + paths-ignore: + - ".github/**.md" + - "docker/**" + - "docs/**" + - 'examples/**' + - '.dev_scripts/**' + - "README.md" + - "README_zh-CN.md" + - "CONTRIBUTING.md" + - ".pre-commit-config.yaml" + - ".pre-commit-config-zh-cn.yaml" + branches: + - 2.x + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build_without_torch: + runs-on: ubuntu-18.04 + env: + MMCV_WITH_OPS: 0 + strategy: + matrix: + python-version: [3.7] + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install system dependencies + run: sudo apt-get update && sudo apt-get install -y ffmpeg libturbojpeg + - name: Install MMEngine from main branch + run: pip install git+https://github.com/open-mmlab/mmengine.git@main + - name: Build MMCV from source + run: pip install -e . -v + - name: Install unit tests dependencies + run: pip install -r requirements/test.txt + - name: Run unit tests + run: pytest tests/test_image tests/test_transforms tests/test_video tests/test_arraymisc.py tests/test_visualization.py tests/test_utils/test_env.py --ignore=tests/test_image/test_io.py + build_without_ops: + runs-on: ubuntu-18.04 + env: + MMCV_WITH_OPS: 0 + strategy: + matrix: + python-version: [3.7] + torch: [1.7.0, 1.8.0, 1.9.0] + include: + - torch: 1.7.0 + torchvision: 0.8.1 + - torch: 1.8.0 + torchvision: 0.9.0 + - torch: 1.9.0 + torchvision: 0.10.0 + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install system dependencies + run: sudo apt-get update && sudo apt-get install -y ffmpeg libturbojpeg + - name: Install PyTorch + run: pip install torch==${{matrix.torch}}+cpu torchvision==${{matrix.torchvision}}+cpu -f https://download.pytorch.org/whl/torch_stable.html + - name: Install MMEngine from main branch + run: pip install git+https://github.com/open-mmlab/mmengine.git@main + - name: Build MMCV from source + run: pip install -e . -v + - name: Install unit tests dependencies + run: pip install -r requirements/test.txt + - name: Run unittests + run: pytest tests --ignore=tests/test_ops + build_cpu_py: + runs-on: ubuntu-18.04 + strategy: + matrix: + python-version: [3.6, 3.8, 3.9] + torch: [1.8.1] + include: + - torch: 1.8.1 + torchvision: 0.9.1 + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install system dependencies + run: sudo apt-get update && sudo apt-get install -y ffmpeg libturbojpeg + - name: Upgrade pip + run: pip install pip --upgrade + - name: Install PyTorch + run: pip install torch==${{matrix.torch}}+cpu torchvision==${{matrix.torchvision}}+cpu -f https://download.pytorch.org/whl/torch_stable.html + - name: Install MMEngine from main branch + run: pip install git+https://github.com/open-mmlab/mmengine.git@main + - name: Install ninja to speed the compilation + run: pip install ninja + - name: Build MMCV from source + run: pip install -e . -v + - name: Install unit tests dependencies + run: pip install -r requirements/test.txt + - name: Run unittests and generate coverage report + run: | + coverage run --branch --source mmcv -m pytest tests/ + coverage xml + coverage report -m + build_cpu_pt: + runs-on: ubuntu-18.04 + strategy: + matrix: + python-version: [3.7] + torch: [1.6.0, 1.7.1, 1.8.1, 1.9.1, 1.10.1, 1.11.0, 1.12.0] + include: + - torch: 1.6.0 + torchvision: 0.7.0 + - torch: 1.7.1 + torchvision: 0.8.2 + - torch: 1.8.1 + torchvision: 0.9.1 + - torch: 1.9.1 + torchvision: 0.10.1 + - torch: 1.10.1 + torchvision: 0.11.2 + - torch: 1.11.0 + torchvision: 0.12.0 + - torch: 1.12.0 + torchvision: 0.13.0 + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install system dependencies + run: sudo apt-get update && sudo apt-get install -y ffmpeg libturbojpeg + - name: Upgrade pip + run: pip install pip --upgrade + - name: Install PyTorch + run: pip install torch==${{matrix.torch}}+cpu torchvision==${{matrix.torchvision}}+cpu -f https://download.pytorch.org/whl/torch_stable.html + - name: Install MMEngine from main branch + run: pip install git+https://github.com/open-mmlab/mmengine.git@main + - name: Install ninja to speed the compilation + run: pip install ninja + - name: Build MMCV from source + run: pip install -e . -v + - name: Install unit tests dependencies + run: pip install -r requirements/test.txt + - name: Run unittests and generate coverage report + run: | + coverage run --branch --source mmcv -m pytest tests/ + coverage xml + coverage report -m + # Only upload coverage report for python3.7 && pytorch1.8.1 cpu + - name: Upload coverage to Codecov + if: ${{matrix.torch == '1.8.1' && matrix.python-version == '3.7'}} + uses: codecov/codecov-action@v1.0.14 + with: + file: ./coverage.xml + flags: unittests + env_vars: OS,PYTHON + name: codecov-umbrella + fail_ci_if_error: false + build_cu102: + runs-on: ubuntu-18.04 + container: + image: pytorch/pytorch:1.8.1-cuda10.2-cudnn7-devel + strategy: + matrix: + python-version: [3.8] + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Upgrade pip + run: pip install pip --upgrade + - name: Fetch GPG keys + run: | + apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/3bf863cc.pub + apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64/7fa2af80.pub + - name: Install system dependencies + run: apt-get update && apt-get install -y git ffmpeg libturbojpeg + - name: Install MMEngine from main branch + run: pip install git+https://github.com/open-mmlab/mmengine.git@main + - name: Install ninja to speed the compilation + run: pip install ninja + - name: Build MMCV from source + run: pip install -e . -v + - name: Install unit tests dependencies + run: pip install -r requirements/test.txt + - name: Run unittests and generate coverage report + run: | + coverage run --branch --source mmcv -m pytest tests/ + coverage xml + coverage report -m + build_windows_without_ops: + runs-on: ${{ matrix.os }} + env: + MMCV_WITH_OPS: 0 + strategy: + matrix: + os: [windows-2022] + python-version: [3.7] + steps: + - uses: actions/checkout@v2 + - name: Set up Python 3.7 + uses: actions/setup-python@v2 + with: + python-version: 3.7 + - name: Upgrade pip + run: pip install pip --upgrade + - name: Install PyTorch + run: pip install torch==1.8.1+cpu torchvision==0.9.1+cpu -f https://download.pytorch.org/whl/torch_stable.html + - name: Install MMEngine from main branch + run: pip install git+https://github.com/open-mmlab/mmengine.git@main + - name: Install ninja to speed the compilation + run: pip install ninja + - name: Build MMCV from source + run: pip install -e . + - name: Install unit tests dependencies + run: pip install -r requirements/test.txt + - name: Run unittests + run: pytest tests --ignore=tests/test_ops --ignore tests/test_image/test_io.py + build_windows: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [windows-2022] + python: [3.7] + torch: [1.8.1, 1.10.1] + include: + - torch: 1.8.1 + torchvision: 0.9.1 + - torch: 1.10.1 + torchvision: 0.11.2 + platform: [cpu, cu111] + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Upgrade pip + run: pip install pip --upgrade + - name: Install PyTorch + run: pip install torch==1.8.1+${{matrix.platform}} torchvision==0.9.1+${{matrix.platform}} -f https://download.pytorch.org/whl/lts/1.8/torch_lts.html + - name: Install MMEngine from main branch + run: pip install git+https://github.com/open-mmlab/mmengine.git@main + - name: Install ninja to speed the compilation + run: pip install ninja + - name: Build MMCV from source + run: pip install -e . + - name: Install unit tests dependencies + run: pip install -r requirements/test.txt + - name: Run unittests + run: pytest tests/ --ignore tests/test_image/test_io.py + build_macos: + runs-on: macos-latest + strategy: + matrix: + python-version: [3.7] + torch: [1.6.0, 1.8.1, 1.12.0] + include: + - torch: 1.6.0 + torchvision: 0.7.0 + - torch: 1.8.1 + torchvision: 0.9.1 + - torch: 1.12.0 + torchvision: 0.13.0 + steps: + - uses: actions/checkout@v2 + - name: Set up Python 3.7 + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install system dependencies + run: brew install ffmpeg jpeg-turbo + - name: Upgrade pip + run: pip install pip --upgrade + - name: Install PyTorch + run: pip install torch==${{ matrix.torch }} torchvision==${{ matrix.torchvision }} + - name: Install MMEngine from main branch + run: pip install git+https://github.com/open-mmlab/mmengine.git@main + - name: Install ninja to speed the compilation + run: pip install ninja + - name: Build MMCV from source + run: pip install -e . -v + - name: Install unit tests dependencies + run: pip install -r requirements/test.txt + - name: Run unittests + run: pytest tests/ diff --git a/.github/workflows/pr_stage_test.yml b/.github/workflows/pr_stage_test.yml new file mode 100644 index 000000000..21143c0b8 --- /dev/null +++ b/.github/workflows/pr_stage_test.yml @@ -0,0 +1,179 @@ +name: pr_stage_test + +on: + pull_request: + paths-ignore: + - ".github/**.md" + - "docker/**" + - "docs/**" + - 'examples/**' + - '.dev_scripts/**' + - "README.md" + - "README_zh-CN.md" + - "CONTRIBUTING.md" + - ".pre-commit-config.yaml" + - ".pre-commit-config-zh-cn.yaml" + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build_cpu: + runs-on: ubuntu-18.04 + strategy: + matrix: + python-version: [3.7] + include: + - torch: 1.8.1 + torchvision: 0.9.1 + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install system dependencies + run: sudo apt-get update && sudo apt-get install -y ffmpeg libturbojpeg + - name: Upgrade pip + run: pip install pip --upgrade + - name: Install PyTorch + run: pip install torch==${{matrix.torch}}+cpu torchvision==${{matrix.torchvision}}+cpu -f https://download.pytorch.org/whl/torch_stable.html + - name: Install MMEngine from main branch + run: pip install git+https://github.com/open-mmlab/mmengine.git@main + - name: Install ninja to speed the compilation + run: pip install ninja + - name: Build MMCV from source + run: pip install -e . -v + - name: Install unit tests dependencies + run: pip install -r requirements/test.txt + - name: Run unittests and generate coverage report + run: | + coverage run --branch --source mmcv -m pytest tests/ + coverage xml + coverage report -m + # Upload coverage report for python3.7 && pytorch1.8.1 cpu + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v1.0.14 + with: + file: ./coverage.xml + flags: unittests + env_vars: OS,PYTHON + name: codecov-umbrella + fail_ci_if_error: false + build_cu102: + runs-on: ubuntu-18.04 + container: + image: pytorch/pytorch:1.8.1-cuda10.2-cudnn7-devel + strategy: + matrix: + python-version: [3.8] + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Upgrade pip + run: pip install pip --upgrade + - name: Fetch GPG keys + run: | + apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/3bf863cc.pub + apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64/7fa2af80.pub + - name: Install system dependencies + run: apt-get update && apt-get install -y git ffmpeg libturbojpeg + - name: Install MMEngine from main branch + run: pip install git+https://github.com/open-mmlab/mmengine.git@main + - name: Install ninja to speed the compilation + run: pip install ninja + - name: Build MMCV from source + run: pip install -e . -v + - name: Install unit tests dependencies + run: pip install -r requirements/test.txt + - name: Run unittests and generate coverage report + run: | + coverage run --branch --source mmcv -m pytest tests/ + coverage xml + coverage report -m + build_windows_without_ops: + runs-on: ${{ matrix.os }} + env: + MMCV_WITH_OPS: 0 + strategy: + matrix: + os: [windows-2022] + python-version: [3.7] + steps: + - uses: actions/checkout@v2 + - name: Set up Python 3.7 + uses: actions/setup-python@v2 + with: + python-version: 3.7 + - name: Upgrade pip + run: pip install pip --upgrade + - name: Install PyTorch + run: pip install torch==1.8.1+cpu torchvision==0.9.1+cpu -f https://download.pytorch.org/whl/torch_stable.html + - name: Install MMEngine from main branch + run: pip install git+https://github.com/open-mmlab/mmengine.git@main + - name: Install ninja to speed the compilation + run: pip install ninja + - name: Build MMCV from source + run: pip install -e . + - name: Install unit tests dependencies + run: pip install -r requirements/test.txt + - name: Run unittests + run: pytest tests --ignore=tests/test_ops --ignore tests/test_image/test_io.py + build_windows: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [windows-2022] + python: [3.7] + platform: [cpu, cu111] + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Upgrade pip + run: pip install pip --upgrade + - name: Install PyTorch + run: pip install torch==1.8.1+${{matrix.platform}} torchvision==0.9.1+${{matrix.platform}} -f https://download.pytorch.org/whl/lts/1.8/torch_lts.html + - name: Install MMEngine from main branch + run: pip install git+https://github.com/open-mmlab/mmengine.git@main + - name: Install ninja to speed the compilation + run: pip install ninja + - name: Build MMCV from source + run: pip install -e . + - name: Install unit tests dependencies + run: pip install -r requirements/test.txt + - name: Run unittests + run: pytest tests/ --ignore tests/test_image/test_io.py + build_macos: + runs-on: macos-latest + strategy: + matrix: + python-version: [3.7] + steps: + - uses: actions/checkout@v2 + - name: Set up Python 3.7 + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install system dependencies + run: brew install ffmpeg jpeg-turbo + - name: Upgrade pip + run: pip install pip --upgrade + - name: Install PyTorch + run: pip install torch==1.8.1 torchvision==0.9.1 + - name: Install MMEngine from main branch + run: pip install git+https://github.com/open-mmlab/mmengine.git@main + - name: Install ninja to speed the compilation + run: pip install ninja + - name: Build MMCV from source + run: pip install -e . -v + - name: Install unit tests dependencies + run: pip install -r requirements/test.txt + - name: Run unittests + run: pytest tests/ diff --git a/requirements/test.txt b/requirements/test.txt index 9b7e0c021..1d124d153 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -1,8 +1,10 @@ coverage lmdb -onnx==1.7.0; python_version < '3.10' -onnxoptimizer; python_version < '3.10' -onnxruntime>=1.8.0; python_version < '3.10' +onnx<1.12.0; python_version < '3.7' +onnx>=1.12.0; python_version >= '3.7' +onnxoptimizer<0.3.0; python_version < '3.7' +onnxoptimizer>=0.3.0; python_version >= '3.7' +onnxruntime>=1.8.0 protobuf~=3.19.0 pytest PyTurboJPEG