Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automate the release artifacts build: from release/2.4 branch #2987

Closed
wants to merge 32 commits into from
Closed
Show file tree
Hide file tree
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
35 changes: 35 additions & 0 deletions .github/scripts/generate-release-matrix.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env python3

import argparse
import json
import sys

RELEASE_CUDA_VERSION = ["cu124"]
RELEASE_PYTHON_VERSION = ["3.8", "3.9", "3.10", "3.11"]


def main(args: list[str]) -> None:
parser = argparse.ArgumentParser()
parser.add_argument(
"--matrix",
help="test matrix",
type=str,
default="",
)
options = parser.parse_args(args)
matrix_dict = json.loads(options.matrix)
includes = matrix_dict["include"]
filtered_includes = []
for item in includes:
if (
item["desired_cuda"] in RELEASE_CUDA_VERSION
and item["python_version"] in RELEASE_PYTHON_VERSION
):
filtered_includes.append(item)
filtered_matrix_dict = {}
filtered_matrix_dict["include"] = filtered_includes
print(json.dumps(filtered_matrix_dict))


if __name__ == "__main__":
main(sys.argv[1:])
79 changes: 69 additions & 10 deletions .github/workflows/docker_builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true

jobs:
build:
permissions:
packages: write
permissions:
packages: write
id-token: write
contents: read

jobs:
build-pre-cxx11:
runs-on: linux.4xlarge.nvidia.gpu

outputs:
docker_url: ${{ env.DOCKER_REGISTRY }}/${{ steps.fix_slashes.outputs.container_name }}
# Define key environment variables
# Container name is of the form torch_tensorrt:<branch_name>
env:
Expand All @@ -34,6 +37,7 @@ jobs:
- name: Fix Slashes Repo Name
id: fix_slashes
run: |
set -x
export container_name=$(echo ${{ env.CONTAINER_NAME }} | sed 's|/|_|g')
echo "container_name=$container_name" >> $GITHUB_OUTPUT

Expand All @@ -44,21 +48,22 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Automatically detect TensorRT default versions for Torch-TRT build
- name: Build Docker image
- name: Build PRE_CXX11_ABI Docker image
env:
DOCKER_TAG: ${{ env.DOCKER_REGISTRY }}/${{ steps.fix_slashes.outputs.container_name }}
run: |
set -x
python3 -m pip install pyyaml
TRT_VERSION=$(python3 -c "import versions; versions.tensorrt_version()")
echo "TRT VERSION = ${TRT_VERSION}"

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

- name: Push Docker image
- name: Push PRE_CXX11_ABI Docker image
env:
DOCKER_URL: ${{ env.DOCKER_REGISTRY }}/${{ steps.fix_slashes.outputs.container_name }}
run: docker push $DOCKER_URL
run: |
set -x
docker push $DOCKER_URL

# Clean up all untagged containers in registry
- name: Container Registry Cleanup
Expand All @@ -68,3 +73,57 @@ jobs:
package-type: container
min-versions-to-keep: 0
delete-only-untagged-versions: True

build-cxx11:
runs-on: linux.4xlarge.nvidia.gpu
outputs:
docker_url: ${{ env.DOCKER_REGISTRY }}/${{ steps.fix_slashes.outputs.container_name }}
# Define key environment variables
# Container name is of the form torch_tensorrt_cxx11:<branch_name>
env:
DOCKER_REGISTRY: ghcr.io/pytorch/tensorrt
CONTAINER_NAME: torch_tensorrt_cxx11:${{ github.ref_name }}

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Fix Slashes Repo Name
id: fix_slashes
run: |
set -x
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@v2
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build CXX11_ABI Docker image
env:
DOCKER_TAG: ${{ env.DOCKER_REGISTRY }}/${{ steps.fix_slashes.outputs.container_name }}
run: |
set -x
python3 -m pip install pyyaml
TRT_VERSION=$(python3 -c "import versions; versions.tensorrt_version()")
echo "TRT VERSION = ${TRT_VERSION}"
DOCKER_BUILDKIT=1 docker build --build-arg TENSORRT_VERSION=$TRT_VERSION --build-arg USE_CXX11_ABI=True -f docker/Dockerfile --tag $DOCKER_TAG .

- name: Push CXX11_ABI Docker image
env:
DOCKER_URL: ${{ env.DOCKER_REGISTRY }}/${{ steps.fix_slashes.outputs.container_name }}
run: |
set -x
docker push $DOCKER_URL

# Clean up all untagged containers in registry
- name: Container Registry Cleanup
uses: actions/delete-package-versions@v4
with:
package-name: "tensorrt/torch_tensorrt_cxx11"
package-type: container
min-versions-to-keep: 0
delete-only-untagged-versions: True
112 changes: 112 additions & 0 deletions .github/workflows/release-linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
name: Release Linux wheels and tarball artifacts

on:
push:
tags:
# NOTE: Binary build pipelines should only get triggered on release candidate builds
# Release candidate tags look like: v1.11.0-rc1
- v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+
workflow_dispatch:

permissions:
id-token: write
contents: read
packages: write

jobs:
release-cxx11-tarball-artifacts:
env:
PYTHON_VERSION: '3.10'
CU_VERSION: cu124
name: Release torch-tensorrt cxx11 tarball artifacts
runs-on: linux.4xlarge.nvidia.gpu
container:
# TODO: this should be changed to ghcr.io/pytorch/tensorrt/torch_tensorrt_cxx11:release_2.4
# once the PR is committed to release/2.4 branch
image: 'ghcr.io/pytorch/tensorrt/torch_tensorrt_cxx11:2987_merge'
options: '--gpus all'
timeout-minutes: 120
steps:
- name: Build CXX11-ABI Tarball
shell: bash -l {0}
run: |
set -euxo pipefail
cd /opt/torch_tensorrt
bazel build //:libtorchtrt --compilation_mode opt --config=default
mkdir release
# example: 2.4.0.dev20240610+cu124, we don't want the +cu124 part, so remove +cu124
PYTORCH_VERSION=$(python -c "import torch; print(torch.__version__)")
PYTORCH_VERSION=${PYTORCH_VERSION%+*}
TORCHTRT_VERSION=2.4.0
cp bazel-bin/libtorchtrt.tar.gz \
release/libtorchtrt-${TORCHTRT_VERSION}-tensorrt${TENSORRT_VERSION}-cuda${CU_VERSION}-libtorch${PYTORCH_VERSION}-x86_64-linux.tar.gz

# NB: Only upload to GitHub after passing smoke tests
- name: Upload tarball to GitHub
continue-on-error: true
uses: actions/upload-artifact@v3
with:
name: cxx11-tarball-${{ env.PYTHON_VERSION }}-${{ env.CU_VERSION }}
path: /opt/torch_tensorrt/release/

generate-matrix:
uses: pytorch/test-infra/.github/workflows/generate_binary_build_matrix.yml@main
with:
package-type: wheel
os: linux
test-infra-repository: pytorch/test-infra
test-infra-ref: main
with-rocm: false
with-cpu: false

generate-release-matrix:
needs: [generate-matrix]
outputs:
matrix: ${{ steps.generate.outputs.matrix }}
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- uses: actions/checkout@v3
with:
repository: pytorch/tensorrt
- name: Generate release matrix
id: generate
run: |
set -eou pipefail
MATRIX_BLOB=${{ toJSON(needs.generate-matrix.outputs.matrix) }}
MATRIX_BLOB="$(python3 .github/scripts/generate-release-matrix.py --matrix "${MATRIX_BLOB}")"
echo "${MATRIX_BLOB}"
echo "matrix=${MATRIX_BLOB}" >> "${GITHUB_OUTPUT}"

release-other-artifacts:
name: Release torch-tensorrt wheel and pre-cxx11 tarball artifacts
needs: [generate-release-matrix]
strategy:
fail-fast: false
matrix:
include:
- repository: pytorch/tensorrt
package-name: torch_tensorrt
pre-script: packaging/pre_build_script.sh
env-var-script: packaging/env_vars.txt
post-script: packaging/post_build_script.sh
smoke-test-script: packaging/smoke_test_script.sh
uses: ./.github/workflows/release-wheel-linux.yml
with:
repository: ${{ matrix.repository }}
ref: ""
test-infra-repository: pytorch/test-infra
test-infra-ref: main
build-matrix: ${{ needs.generate-release-matrix.outputs.matrix }}
pre-script: ${{ matrix.pre-script }}
env-var-script: ${{ matrix.env-var-script }}
post-script: ${{ matrix.post-script }}
package-name: ${{ matrix.package-name }}
smoke-test-script: ${{ matrix.smoke-test-script }}
trigger-event: ${{ github.event_name }}

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref_name }}-${{ inputs.repository }}-${{ github.event_name == 'workflow_dispatch' }}-${{ inputs.job-name }}
cancel-in-progress: true
Loading
Loading