• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1name: docker-builds
2
3on:
4  workflow_dispatch:
5  pull_request:
6    paths:
7      - .ci/docker/**
8      - .github/workflows/docker-builds.yml
9      - .lintrunner.toml
10  push:
11    branches:
12      - main
13      - release/*
14      - landchecks/*
15    paths:
16      - .ci/docker/**
17      - .github/workflows/docker-builds.yml
18      - .lintrunner.toml
19  schedule:
20    - cron: 1 3 * * 3
21
22concurrency:
23  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}-${{ github.event_name == 'workflow_dispatch' }}
24  cancel-in-progress: true
25
26env:
27  ALPINE_IMAGE: 308535385114.dkr.ecr.us-east-1.amazonaws.com/tool/alpine
28  AWS_DEFAULT_REGION: us-east-1
29
30permissions: read-all
31
32jobs:
33  docker-build:
34    environment: ${{ (github.ref == 'refs/heads/main' || startsWith(github.event.ref, 'refs/tags/v')) && 'docker-build' || '' }}
35    timeout-minutes: 240
36    strategy:
37      fail-fast: false
38      matrix:
39        runner: [linux.12xlarge]
40        docker-image-name: [
41          pytorch-linux-focal-cuda12.4-cudnn9-py3-gcc9,
42          pytorch-linux-focal-cuda12.4-cudnn9-py3-gcc9-inductor-benchmarks,
43          pytorch-linux-focal-cuda12.4-cudnn9-py3.12-gcc9-inductor-benchmarks,
44          pytorch-linux-focal-cuda12.1-cudnn9-py3-gcc9,
45          pytorch-linux-focal-cuda12.1-cudnn9-py3-gcc9-inductor-benchmarks,
46          pytorch-linux-focal-cuda12.1-cudnn9-py3.12-gcc9-inductor-benchmarks,
47          pytorch-linux-focal-cuda11.8-cudnn9-py3-gcc9,
48          pytorch-linux-focal-py3.8-clang10,
49          pytorch-linux-focal-py3.11-clang10,
50          pytorch-linux-focal-py3.12-clang10,
51          pytorch-linux-focal-rocm-n-1-py3,
52          pytorch-linux-focal-rocm-n-py3,
53          pytorch-linux-jammy-cuda11.8-cudnn9-py3.8-clang12,
54          pytorch-linux-focal-py3-clang9-android-ndk-r21e,
55          pytorch-linux-jammy-py3.8-gcc11,
56          pytorch-linux-jammy-py3.8-gcc11-inductor-benchmarks,
57          pytorch-linux-jammy-xpu-2024.0-py3,
58          pytorch-linux-jammy-py3-clang15-asan,
59          pytorch-linux-focal-py3-clang10-onnx,
60          pytorch-linux-focal-linter,
61          pytorch-linux-jammy-cuda11.8-cudnn9-py3.9-linter,
62          pytorch-linux-jammy-py3-clang12-executorch
63          ]
64        include:
65          - docker-image-name: pytorch-linux-jammy-aarch64-py3.10-gcc11
66            runner: linux.arm64.2xlarge
67    runs-on: [self-hosted, "${{ matrix.runner }}"]
68    env:
69      DOCKER_IMAGE_BASE: 308535385114.dkr.ecr.us-east-1.amazonaws.com/pytorch/${{ matrix.docker-image-name }}
70    steps:
71      - name: Clean workspace
72        shell: bash
73        run: |
74          echo "${GITHUB_WORKSPACE}"
75          sudo rm -rf "${GITHUB_WORKSPACE}"
76          mkdir "${GITHUB_WORKSPACE}"
77
78      # [see note: pytorch repo ref]
79      # deep clone (fetch-depth 0) required for git merge-base
80      - name: Checkout PyTorch
81        uses: pytorch/pytorch/.github/actions/checkout-pytorch@release/2.4
82
83      - name: Setup Linux
84        uses: ./.github/actions/setup-linux
85
86      - name: Build docker image
87        id: build-docker-image
88        uses: pytorch/test-infra/.github/actions/calculate-docker-image@release/2.4
89        with:
90          docker-image-name: ${{ matrix.docker-image-name }}
91          always-rebuild: true
92          push: true
93
94      - name: Pull docker image
95        uses: pytorch/test-infra/.github/actions/pull-docker-image@release/2.4
96        with:
97          docker-image: ${{ steps.build-docker-image.outputs.docker-image }}
98
99      - uses: nick-fields/retry@3e91a01664abd3c5cd539100d10d33b9c5b68482
100        name: Push to https://https://ghcr.io/
101        id: push-to-ghcr-io
102        if: ${{ github.event_name == 'push' }}
103        env:
104          ECR_DOCKER_IMAGE: ${{ steps.build-docker-image.outputs.docker-image }}
105          GHCR_PAT: ${{ secrets.GHCR_PAT }}
106          IMAGE_NAME: ${{ matrix.docker-image-name }}
107        with:
108          shell: bash
109          timeout_minutes: 15
110          max_attempts: 5
111          retry_wait_seconds: 90
112          command: |
113            ghcr_image="ghcr.io/pytorch/ci-image"
114            tag=${ECR_DOCKER_IMAGE##*:}
115            # Push docker image to the ghcr.io
116            echo $GHCR_PAT | docker login ghcr.io -u pytorch --password-stdin
117            docker tag "${ECR_DOCKER_IMAGE}" "${ghcr_image}:${IMAGE_NAME}-${tag}"
118            docker push "${ghcr_image}:${IMAGE_NAME}-${tag}"
119
120      - name: Chown workspace
121        uses: ./.github/actions/chown-workspace
122        with:
123          ALPINE_IMAGE: 308535385114.dkr.ecr.us-east-1.amazonaws.com/${{ (matrix.runner == 'linux.arm64.2xlarge') && 'arm64v8' || 'tool' }}/alpine
124        if: always()
125
126      - name: Teardown Linux
127        uses: pytorch/test-infra/.github/actions/teardown-linux@release/2.4
128        if: always()
129