| name: Build Linux Wheels |
| |
| on: |
| # TODO: These are only runnable from workflow_dispatch, we need to eventually add |
| # a cron |
| # TODO: Add an on_release trigger to build on tags |
| workflow_dispatch: |
| |
| jobs: |
| generate-build-matrix: |
| if: ${{ github.repository_owner == 'pytorch' }} |
| runs-on: ubuntu-18.04 |
| outputs: |
| matrix: ${{ steps.set-matrix.outputs.matrix }} |
| container: |
| image: python:3.9 |
| steps: |
| - name: Clone pytorch/pytorch |
| uses: zhouzhuojie/checkout@05b13c9a0d21f08f6d5e64a1d5042246d13619d9 |
| - name: Generating build matrix |
| id: set-matrix |
| run: | |
| # outputting for debugging purposes |
| MATRIX=$(python .github/scripts/generate_binary_build_matrix.py wheels) |
| echo "${MATRIX}" |
| echo "::set-output name=matrix::${MATRIX}" |
| build-wheel: |
| if: ${{ github.repository_owner == 'pytorch' }} |
| needs: generate-build-matrix |
| runs-on: linux.2xlarge |
| strategy: |
| matrix: ${{ fromJson(needs.generate-build-matrix.outputs.matrix) }} |
| fail-fast: false |
| container: |
| image: ${{ matrix.container_image }} |
| env: |
| DESIRED_PYTHON: ${{ matrix.python_version }} |
| # TODO: This is a legacy variable that we eventually want to get rid of in |
| # favor of GPU_ARCH_VERSION |
| DESIRED_CUDA: ${{ matrix.gpu_arch_version }} |
| GPU_ARCH_VERSION: ${{ matrix.GPU_ARCH_VERSION }} |
| GPU_ARCH_TYPE: ${{ matrix.gpu_arch_type }} |
| PYTORCH_BUILD_NUMBER: 1 |
| SKIP_ALL_TESTS: 1 |
| steps: |
| - name: Clean runner workspace |
| run: rm -rf "$GITHUB_WORKSPACE" |
| - name: Clone pytorch/pytorch |
| uses: zhouzhuojie/checkout@05b13c9a0d21f08f6d5e64a1d5042246d13619d9 |
| with: |
| path: pytorch |
| submodules: recursive |
| - name: Clone pytorch/builder |
| uses: zhouzhuojie/checkout@05b13c9a0d21f08f6d5e64a1d5042246d13619d9 |
| with: |
| repository: pytorch/builder |
| path: builder |
| - name: Generate version string |
| working-directory: pytorch/ |
| run: | |
| version=$(.github/scripts/generate_pytorch_version.py) |
| echo "Generated version: ${version}" |
| echo "PYTORCH_BUILD_VERSION=${version}" >> "$GITHUB_ENV" |
| - name: Set BUILD_SPLIT_CUDA |
| if: ${{ matrix.gpu_arch_type == 'cuda' && matrix.gpu_arch_version == '11.1' }} |
| run: | |
| echo "BUILD_SPLIT_CUDA=1" >> "$GITHUB_ENV" |
| # TODO: Remove this once we remove the need for the directories to be |
| # in specific locations |
| - name: Symlink repositories to root directory (for legacy scripts purposes) |
| run: | |
| ln -s "$PWD"/pytorch /pytorch |
| ln -s "$PWD"/builder /builder |
| # TODO: Bundle the correct build script in the base container image so |
| # that we don't have to do this type of specification |
| - name: Build PyTorch binary (CUDA specific) |
| if: ${{ matrix.gpu_arch_type == 'cuda' }} |
| run: | |
| /builder/manywheel/build.sh |
| - name: Build PyTorch binary (ROCM specific) |
| if: ${{ matrix.gpu_arch_type == 'rocm' }} |
| run: | |
| /builder/manywheel/build_rocm.sh |
| - name: Build PyTorch binary (CPU specific) |
| if: ${{ matrix.gpu_arch_type == 'cpu' }} |
| run: | |
| /builder/manywheel/build_cpu.sh |
| - uses: actions/upload-artifact@v2 |
| with: |
| name: pytorch-wheel-py${{ matrix.python_version }}-${{matrix.gpu_arch_type}}-${{ matrix.gpu_arch_version }} |
| path: /remote/**/*.whl |
| - name: Parse ref |
| id: parse-ref |
| run: .github/scripts/parse_ref.py |
| - name: Display and upload binary build size statistics (Click Me) |
| # temporary hack: set CIRCLE_* vars, until we update |
| # tools/stats/print_test_stats.py to natively support GitHub Actions |
| env: |
| SCRIBE_GRAPHQL_ACCESS_TOKEN: ${{ secrets.SCRIBE_GRAPHQL_ACCESS_TOKEN }} |
| CIRCLE_BRANCH: ${{ steps.parse-ref.outputs.branch }} |
| CIRCLE_PR_NUMBER: ${{ github.event.pull_request.number }} |
| CIRCLE_SHA1: ${{ github.event.pull_request.head.sha || github.sha }} |
| CIRCLE_TAG: ${{ steps.parse-ref.outputs.tag }} |
| CIRCLE_WORKFLOW_ID: '${{ github.run_id }}_${{ github.run_number }}' |
| run: | |
| COMMIT_TIME=$(git log --max-count=1 --format=%ct || echo 0) |
| export COMMIT_TIME |
| pip3 install requests==2.26 |
| python3 -m tools.stats.upload_binary_size_to_scuba || exit 0 |
| |
| concurrency: |
| group: build-linux-wheels-${{ github.event.pull_request.number || github.sha }}-${{ github.event_name == 'workflow_dispatch' }} |
| cancel-in-progress: true |