Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 40 additions & 12 deletions .github/workflows/docker_builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ on:
- 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,
Expand All @@ -22,7 +28,15 @@ jobs:
permissions:
packages: write

runs-on: linux.4xlarge
# 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>
Expand All @@ -48,23 +62,37 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}

# Automatically detect TensorRT default versions for Torch-TRT build
- name: Build Docker image
env:
DOCKER_TAG: ${{ env.DOCKER_REGISTRY }}/${{ steps.fix_slashes.outputs.container_name }}
# 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: |
python3 -m pip install pyyaml
TRT_VERSION=$(python3 -c "import versions; versions.tensorrt_version()")
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"

DOCKER_BUILDKIT=1 docker build --build-arg TENSORRT_VERSION=$TRT_VERSION -f docker/Dockerfile --tag $DOCKER_TAG .

- name: Push Docker image
env:
DOCKER_URL: ${{ env.DOCKER_REGISTRY }}/${{ steps.fix_slashes.outputs.container_name }}
run: docker push $DOCKER_URL
# 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"
Expand Down
Loading