Repository navigation
101 lines (89 loc) · 3.75 KB
/
Copy pathdocker_builder.yml
File metadata and controls
101 lines (89 loc) · 3.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
name: 'Torch-TensorRT Docker Build'
# Apply workflow only to main, nightly, release branches
on:
push:
branches:
- main
- nightly
- release/*
paths-ignore:
- 'docs/**'
# TEMPORARY: remove before merging. Present only so this pull request can
# prove the docker build still works on the OSDC runner; the workflow is
# otherwise push-only, so the change would land untested.
pull_request:
paths:
- '.github/workflows/docker_builder.yml'
workflow_dispatch:
# If pushes to main are made in rapid succession,
# cancel existing docker builds and use newer commits
concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true
jobs:
build:
permissions:
packages: write
# BuildKit runs out of cluster on the OSDC BuildKit pool, so this runner only
# streams the build context and waits.
runs-on: mt-l-x86iavx512-16-128
container:
# Needs the docker CLI: docker/login-action shells out to it, and
# docker-build-remote-buildkit runs `docker buildx build`. The
# manylinux builder images have python and pip but no docker, so they
# cannot host this job.
image: ghcr.io/actions/actions-runner:latest
# Define key environment variables
# Container name is of the form torch_tensorrt:<branch_name>
env:
DOCKER_REGISTRY: ghcr.io/pytorch/tensorrt
CONTAINER_NAME: torch_tensorrt:${{ github.ref_name }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Fix Slashes Repo Name
id: fix_slashes
run: |
export container_name=$(echo ${{ env.CONTAINER_NAME }} | sed 's|/|_|g')
echo "container_name=$container_name" >> $GITHUB_OUTPUT
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Automatically detect TensorRT default versions for Torch-TRT build
# versions.py imports pyyaml, and this image has python3 but no pip (nor
# ensurepip). It is still the right image -- docker/login-action and the
# buildkit action both need the docker CLI, which the manylinux builder
# images do not have -- so bring an interpreter with uv instead.
- uses: astral-sh/setup-uv@94527f2e458b27549849d47d273a16bec83a01e9 # v7
- name: Detect the TensorRT version
id: trt
run: |
set -eu
TRT_VERSION=$(uv run --no-project --with pyyaml python -c "import versions; versions.tensorrt_version()")
echo "TRT VERSION = ${TRT_VERSION}"
echo "version=${TRT_VERSION}" >> "$GITHUB_OUTPUT"
# There is no docker daemon on an OSDC runner, so the build runs on the
# shared BuildKit pool and pushes straight to the registry. buildx forwards
# the registry auth written by the login step above.
- name: Build and push Docker image
uses: pytorch/test-infra/.github/actions/docker-build-remote-buildkit@main
with:
tags: ${{ env.DOCKER_REGISTRY }}/${{ steps.fix_slashes.outputs.container_name }}
file: docker/Dockerfile
build-args: TENSORRT_VERSION=${{ steps.trt.outputs.version }}
push: true
# Clean up all untagged containers in registry
- name: Container Registry Cleanup
# Not from a pull request: this deletes untagged versions from the shared
# registry, which is a side effect a test run should not have. Goes away
# with the temporary pull_request trigger.
if: github.event_name != 'pull_request'
uses: actions/delete-package-versions@v4
with:
package-name: "tensorrt/torch_tensorrt"
package-type: container
min-versions-to-keep: 0
delete-only-untagged-versions: True