Skip to content

Commit 590a9c2

Browse files
authored
Use matrix generate script for docker release workflows (pytorch#115949) (pytorch#116063)
* Use matrix generate script for docker release workflows (pytorch#115949) Enable both supported CUDA version builds for docker release. Rather then building only 1 version. Pull Request resolved: pytorch#115949 Approved by: https://github.com/huydhn * release 2.1.2 only changes, fix rebase * lint
1 parent a8e7c98 commit 590a9c2

File tree

5 files changed

+77
-10
lines changed

5 files changed

+77
-10
lines changed

.github/scripts/generate_binary_build_matrix.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@
1616
CUDA_ARCHES = ["11.8", "12.1"]
1717

1818

19+
CUDA_ARCHES_FULL_VERSION = {"11.8": "11.8.0", "12.1": "12.1.1"}
20+
21+
22+
CUDA_ARCHES_CUDNN_VERSION = {"11.8": "8", "12.1": "8"}
23+
24+
1925
ROCM_ARCHES = ["5.5", "5.6"]
2026

2127

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env python3
2+
3+
"""Generates a matrix for docker releases through github actions
4+
5+
Will output a condensed version of the matrix. Will include fllowing:
6+
* CUDA version short
7+
* CUDA full verison
8+
* CUDNN version short
9+
* Image type either runtime or devel
10+
* Platform linux/arm64,linux/amd64
11+
12+
"""
13+
14+
import json
15+
from typing import Dict, List
16+
17+
import generate_binary_build_matrix
18+
19+
DOCKER_IMAGE_TYPES = ["runtime", "devel"]
20+
21+
22+
def generate_docker_matrix() -> Dict[str, List[Dict[str, str]]]:
23+
ret: List[Dict[str, str]] = []
24+
for cuda, version in generate_binary_build_matrix.CUDA_ARCHES_FULL_VERSION.items():
25+
for image in DOCKER_IMAGE_TYPES:
26+
platform = (
27+
"linux/arm64,linux/amd64" if image == "runtime" else "linux/amd64"
28+
)
29+
ret.append(
30+
{
31+
"cuda": cuda,
32+
"cuda_full_version": version,
33+
"cudnn_version": generate_binary_build_matrix.CUDA_ARCHES_CUDNN_VERSION[
34+
cuda
35+
],
36+
"image_type": image,
37+
"platform": platform,
38+
}
39+
)
40+
return {"include": ret}
41+
42+
43+
if __name__ == "__main__":
44+
build_matrix = generate_docker_matrix()
45+
print(json.dumps(build_matrix))

.github/workflows/docker-release.yml

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,23 +39,39 @@ env:
3939
WITH_PUSH: ${{ inputs.channel == 'release' }}
4040

4141
jobs:
42+
generate-matrix:
43+
if: github.repository_owner == 'pytorch'
44+
runs-on: [self-hosted, linux.large]
45+
outputs:
46+
matrix: ${{ steps.generate-matrix.outputs.matrix }}
47+
steps:
48+
- name: Checkout PyTorch
49+
uses: pytorch/pytorch/.github/actions/checkout-pytorch@main
50+
with:
51+
fetch-depth: 1
52+
submodules: true
53+
- name: Get docker release matrix
54+
id: generate-matrix
55+
run: |
56+
MATRIX_BLOB="$(python3 .github/scripts/generate_docker_release_matrix.py)"
57+
echo "${MATRIX_BLOB}"
58+
echo "matrix=${MATRIX_BLOB}" >> "${GITHUB_OUTPUT}"
59+
4260
build:
4361
if: ${{ github.repository == 'pytorch/pytorch' }}
4462
runs-on: [self-hosted, linux.2xlarge]
4563
environment: ${{ (github.ref == 'refs/heads/main' || startsWith(github.event.ref, 'refs/tags/v')) && 'docker-build' || '' }}
4664
timeout-minutes: 240
65+
needs: generate-matrix
4766
strategy:
48-
matrix:
49-
include:
50-
# nvidia specific images don't exist for arm64 so only build the runtime image
51-
- image_type: runtime
52-
platform: linux/arm64,linux/amd64
53-
- image_type: devel
54-
platform: linux/amd64
67+
matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
68+
fail-fast: false
5569
env:
5670
BUILD_IMAGE_TYPE: ${{ matrix.image_type }}
5771
BUILD_PLATFORMS: ${{ matrix.platform }}
5872
CHANNEL: ${{ inputs.channel }}
73+
CUDA_VERSION: ${{ matrix.cuda_full_version }}
74+
CUDNN_VERSION: ${{ matrix.cudnn_version }}
5975
steps:
6076
- name: Setup SSH (Click me for login details)
6177
uses: pytorch/test-infra/.github/actions/setup-ssh@release/2.1

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ RUN --mount=type=cache,target=/opt/ccache \
6363

6464
FROM conda as conda-installs
6565
ARG PYTHON_VERSION=3.8
66-
ARG CUDA_VERSION=11.7
66+
ARG CUDA_VERSION=12.1
6767
ARG CUDA_CHANNEL=nvidia
6868
ARG INSTALL_CHANNEL=pytorch-nightly
6969
# Automatically set by buildx

docker.Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ $(warning WARNING: No docker user found using results from whoami)
88
DOCKER_ORG = $(shell whoami)
99
endif
1010

11-
CUDA_VERSION = 12.1.1
12-
CUDNN_VERSION = 8
11+
CUDA_VERSION ?= 12.1.1
12+
CUDNN_VERSION ?= 8
1313
BASE_RUNTIME = ubuntu:20.04
1414
BASE_DEVEL = nvidia/cuda:$(CUDA_VERSION)-cudnn$(CUDNN_VERSION)-devel-ubuntu20.04
1515
CMAKE_VARS ?=

0 commit comments

Comments
 (0)