From c934605e8328797ba868d3a42e108d499e841597 Mon Sep 17 00:00:00 2001 From: Zaida Zhou <58739961+zhouzaida@users.noreply.github.com> Date: Sun, 3 Oct 2021 10:29:05 +0800 Subject: [PATCH] Switch to the docker image provided by PyTorch (#1376) --- .github/workflows/build.yml | 109 +++++++++++------------------------- 1 file changed, 33 insertions(+), 76 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 697c3ba6c..c97088688 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -32,7 +32,6 @@ jobs: strategy: matrix: python-version: [3.7] - steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} @@ -41,8 +40,6 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install system dependencies run: sudo apt-get update && sudo apt-get install -y ffmpeg libturbojpeg - - name: Install utils - run: pip install psutil - name: Build and install run: rm -rf .eggs && pip install -e . - name: Validate the installation @@ -75,8 +72,6 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install system dependencies run: sudo apt-get update && sudo apt-get install -y ffmpeg libturbojpeg - - name: Install utils - run: pip install psutil - name: Install PyTorch run: pip install torch==${{matrix.torch}}+cpu torchvision==${{matrix.torchvision}}+cpu -f https://download.pytorch.org/whl/torch_stable.html - name: Build and install @@ -93,12 +88,8 @@ jobs: strategy: matrix: python-version: [3.7] - torch: [1.3.1, 1.4.0, 1.5.1, 1.6.0, 1.7.0, 1.8.0, 1.9.0] + torch: [1.5.1, 1.6.0, 1.7.0, 1.8.0, 1.9.0] include: - - torch: 1.3.1 - torchvision: 0.4.2 - - torch: 1.4.0 - torchvision: 0.5.0 - torch: 1.5.1 torchvision: 0.6.1 - torch: 1.6.0 @@ -117,13 +108,11 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install system dependencies run: sudo apt-get update && sudo apt-get install -y ffmpeg libturbojpeg - - name: Install utils - run: pip install psutil - - name: Install Pillow - run: pip install Pillow==6.2.2 - if: ${{matrix.torchvision == '0.4.2'}} - name: Install PyTorch run: pip install torch==${{matrix.torch}}+cpu torchvision==${{matrix.torchvision}}+cpu -f https://download.pytorch.org/whl/torch_stable.html + # pstuil is an optional package to detect the number of CPU for compiling mmcv + - name: Install psutil + run: pip install psutil - name: Build and install run: rm -rf .eggs && pip install -e . - name: Validate the installation @@ -137,10 +126,9 @@ jobs: build_cu101: runs-on: ubuntu-18.04 + container: + image: pytorch/pytorch:1.6.0-cuda10.1-cudnn7-devel env: - CUDA: 10.1.105-1 - CUDA_SHORT: 10.1 - UBUNTU_VERSION: ubuntu1804 FORCE_CUDA: 1 MMCV_CUDA_ARGS: -gencode=arch=compute_61,code=sm_61 strategy: @@ -167,48 +155,38 @@ jobs: - python-version: 3.9 torch: 1.8.0+cu101 torchvision: 0.9.0+cu101 - 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 CUDA - run: | - export INSTALLER=cuda-repo-${UBUNTU_VERSION}_${CUDA}_amd64.deb - wget http://developer.download.nvidia.com/compute/cuda/repos/${UBUNTU_VERSION}/x86_64/${INSTALLER} - sudo dpkg -i ${INSTALLER} - wget https://developer.download.nvidia.com/compute/cuda/repos/${UBUNTU_VERSION}/x86_64/7fa2af80.pub - sudo apt-key add 7fa2af80.pub - sudo apt update -qq - sudo apt install -y cuda-${CUDA_SHORT/./-} cuda-cufft-dev-${CUDA_SHORT/./-} - sudo apt clean - export CUDA_HOME=/usr/local/cuda-${CUDA_SHORT} - sudo cp /usr/local/cuda-10.2/include/* /usr/local/cuda/include - sudo cp -r /usr/local/cuda-10.2/lib64/* /usr/local/cuda/lib64/ - export LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${CUDA_HOME}/include:${LD_LIBRARY_PATH} - export PATH=${CUDA_HOME}/bin:${PATH} - sudo apt-get install -y ninja-build - - name: Install utils - run: pip install psutil + - name: Install python-dev + run: apt-get update && apt-get install -y python${{matrix.python-version}}-dev + if: ${{matrix.python-version != '3.9'}} - name: Install Pillow - run: pip install Pillow==6.2.2 + run: python -m pip install Pillow==6.2.2 if: ${{matrix.torchvision == '0.4.2'}} + # When we use a third-party container, we need to add python -m to call + # the user-installed pip when we use the pip command, otherwise it will + # call the system pip - name: Install PyTorch - run: pip install torch==${{matrix.torch}} torchvision==${{matrix.torchvision}} -f https://download.pytorch.org/whl/torch_stable.html + run: python -m pip install torch==${{matrix.torch}} torchvision==${{matrix.torchvision}} -f https://download.pytorch.org/whl/torch_stable.html - name: Install system dependencies - run: sudo apt-get update && sudo apt-get install -y ffmpeg libturbojpeg + run: apt-get update && apt-get install -y ffmpeg libturbojpeg ninja-build - name: Install dependencies for compiling onnx when python=3.9 - run: pip install protobuf && sudo apt-get install libprotobuf-dev protobuf-compiler + run: python -m pip install protobuf && apt-get -y install libprotobuf-dev protobuf-compiler cmake if: ${{matrix.python-version == '3.9'}} + # pstuil is an optional package to detect the number of CPU for compiling mmcv + - name: Install psutil + run: python -m pip install psutil - name: Build and install - run: rm -rf .eggs && pip install -e . + run: rm -rf .eggs && python -m pip install -e . - name: Validate the installation run: python -c "import mmcv" - name: Run unittests and generate coverage report run: | - pip install -r requirements/test.txt + python -m pip install -r requirements/test.txt coverage run --branch --source=mmcv -m pytest tests/ coverage xml coverage report -m @@ -225,10 +203,9 @@ jobs: build_cu102: runs-on: ubuntu-18.04 + container: + image: pytorch/pytorch:1.9.0-cuda10.2-cudnn7-devel env: - CUDA: 10.2.89-1 - CUDA_SHORT: 10.2 - UBUNTU_VERSION: ubuntu1804 FORCE_CUDA: 1 MMCV_CUDA_ARGS: -gencode=arch=compute_61,code=sm_61 strategy: @@ -244,44 +221,30 @@ jobs: - python-version: 3.8 torch: 1.9.0+cu102 torchvision: 0.10.0+cu102 - 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 CUDA - run: | - export INSTALLER=cuda-repo-${UBUNTU_VERSION}_${CUDA}_amd64.deb - wget http://developer.download.nvidia.com/compute/cuda/repos/${UBUNTU_VERSION}/x86_64/${INSTALLER} - sudo dpkg -i ${INSTALLER} - wget https://developer.download.nvidia.com/compute/cuda/repos/${UBUNTU_VERSION}/x86_64/7fa2af80.pub - sudo apt-key add 7fa2af80.pub - sudo apt update -qq - sudo apt install -y cuda-${CUDA_SHORT/./-} cuda-cufft-dev-${CUDA_SHORT/./-} - sudo apt clean - export CUDA_HOME=/usr/local/cuda-${CUDA_SHORT} - export LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${CUDA_HOME}/include:${LD_LIBRARY_PATH} - export PATH=${CUDA_HOME}/bin:${PATH} - sudo apt-get install -y ninja-build - - name: Install Pillow - run: pip install Pillow==6.2.2 - if: ${{matrix.torchvision == '0.4.2'}} - - name: Install PyTorch - run: pip install torch==${{matrix.torch}} torchvision==${{matrix.torchvision}} -f https://download.pytorch.org/whl/torch_stable.html + - name: Install python-dev + run: apt-get update && apt-get install -y python${{matrix.python-version}}-dev + - name: python -m Install PyTorch + run: python -m pip install torch==${{matrix.torch}} torchvision==${{matrix.torchvision}} -f https://download.pytorch.org/whl/torch_stable.html - name: Install system dependencies - run: sudo apt-get update && sudo apt-get install -y ffmpeg libturbojpeg + run: apt-get update && apt-get install -y ffmpeg libturbojpeg ninja-build + # pstuil is an optional package to detect the number of CPU for compiling mmcv + - name: Install psutil + run: python -m pip install psutil - name: Build and install - run: rm -rf .eggs && pip install -e . + run: rm -rf .eggs && python -m pip install -e . - name: Validate the installation run: python -c "import mmcv" - name: Run unittests and generate coverage report run: | - pip install -r requirements/test.txt + python -m pip install -r requirements/test.txt coverage run --branch --source=mmcv -m pytest tests/ coverage xml - coverage report -m build_windows_without_ops: runs-on: windows-latest @@ -303,9 +266,6 @@ jobs: uses: actions/setup-python@v2 with: python-version: 3.7 - - name: Install Pillow - run: pip install Pillow==6.2.2 - if: ${{matrix.torchvision == '0.4.2'}} - name: Install PyTorch run: pip install torch==${{matrix.torch}}+cpu torchvision==${{matrix.torchvision}}+cpu --no-cache-dir -f https://download.pytorch.org/whl/torch_stable.html - name: Build and install @@ -335,9 +295,6 @@ jobs: uses: actions/setup-python@v2 with: python-version: 3.7 - - name: Install Pillow - run: pip install Pillow==6.2.2 - if: ${{matrix.torchvision == '0.4.2'}} - name: Install PyTorch run: pip install torch==${{matrix.torch}}+cpu torchvision==${{matrix.torchvision}}+cpu --no-cache-dir -f https://download.pytorch.org/whl/torch_stable.html - name: Build and install