Skip to content

Commit b67b37a

Browse files
Update CI workflows and devcontainer configs for CUDA 12.9 and Ubuntu 24.04 (#723)
- Update Docker/devcontainer configs and CI build logic - Refactor container build workflow to dynamically discover devcontainer configs - Replace old devcontainer configs with new CUDA 12.9/Ubuntu 24.04 variants - Add generate.py script for devcontainer config generation - Update TensorRT version default to 10.13 - Update LLVM toolchain alternatives for LLVM 20 - Improve CI format checking with merge base detection
1 parent 8b76ed8 commit b67b37a

35 files changed

Lines changed: 2056 additions & 782 deletions

File tree

.github/workflows/mlir-tensorrt-ci.yml

Lines changed: 65 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -12,112 +12,101 @@ on:
1212
paths: ["mlir-tensorrt/**"]
1313

1414
env:
15-
DEFAULT_IMAGE: ghcr.io/nvidia/tensorrt-incubator/mlir-tensorrt:cuda12.5-ubuntu-llvm17
15+
DEFAULT_IMAGE: ghcr.io/nvidia/tensorrt-incubator/mlir-tensorrt:cuda12.9-ubuntu24.04-0.1
1616
REGISTRY: ghcr.io
1717

1818
jobs:
19+
format-check:
20+
name: Lint Check
21+
runs-on: ubuntu-latest
22+
container:
23+
image: ghcr.io/nvidia/tensorrt-incubator/mlir-tensorrt:cuda12.9-ubuntu24.04-0.1
24+
steps:
25+
- uses: actions/checkout@v5
26+
with:
27+
fetch-depth: 5
28+
- name: Run checks
29+
run: |
30+
# Fetch base branch for merge-base calculation
31+
cd "${GITHUB_WORKSPACE}"
32+
git config --global --add safe.directory "${GITHUB_WORKSPACE}"
33+
BASE_REF="${{ github.base_ref || 'main' }}"
34+
git fetch origin "${BASE_REF}"
35+
BASE_COMMIT=$(git merge-base HEAD "origin/${BASE_REF}")
36+
37+
# Check Python formatting with black
38+
uv tool install black
39+
uvx black --check --extend-exclude='.*\.pyi' mlir-tensorrt/compiler/ mlir-tensorrt/integrations
40+
41+
# Check C++ formatting with clang-format
42+
CLANG_FORMAT_DIFF=$(git clang-format-20 "${BASE_COMMIT}" --diff -q)
43+
if [ -n "${CLANG_FORMAT_DIFF}" ]; then
44+
echo "${CLANG_FORMAT_DIFF}"
45+
echo "Error: C++ files are not properly formatted. Run 'git clang-format ${BASE_COMMIT}' to fix."
46+
exit 1
47+
fi
48+
1949
mlir-tensorrt-test-pr:
2050
if: github.event_name != 'pull_request' || github.event.pull_request.draft == false
2151
runs-on: tripy-self-hosted
22-
52+
container:
53+
image: ghcr.io/nvidia/tensorrt-incubator/mlir-tensorrt:cuda12.9-ubuntu24.04-0.1
54+
options: >-
55+
--gpus all
56+
--shm-size=1g
2357
steps:
2458
# Value of `github.workspace` is /home/runner/work/{repo_name}/{repo-name}
2559
# i.e. /home/runner/work/TensorRT-Incubator/TensorRT-Incubator in our case.
2660
# After this action, repo is cloned inside above path.
27-
- uses: actions/checkout@v4
61+
- uses: actions/checkout@v5
2862
with:
2963
fetch-depth: 5
3064

31-
# Run initial format check
32-
- name: Run python format and clang check
33-
uses: addnab/docker-run-action@v3
34-
if: ${{ github.event_name == 'pull_request' }}
35-
with:
36-
image: ${{ env.DEFAULT_IMAGE }}
37-
options: -v ${{ github.workspace }}:/tensorrt-incubator
38-
registry: ${{ env.REGISTRY }}
39-
username: ${{ github.actor }}
40-
password: ${{ secrets.GITHUB_TOKEN }}
41-
# This step does two things
42-
# 1. Check if Python files follow black format
43-
# 2. Check if C++ files follow clang format
44-
# NOTE: We are placed at the root directory ('/') inside the container.
45-
run: |
46-
cd tensorrt-incubator
47-
git config --global --add safe.directory /tensorrt-incubator
48-
cat > run_format_check.sh <<EOF
49-
#!/bin/bash
50-
set -e
51-
python3 -m black --check --extend-exclude='.*\.pyi' mlir-tensorrt/compiler/
52-
python3 -m black --check --extend-exclude='.*\.pyi' mlir-tensorrt/integrations/python/
53-
git clang-format HEAD~1 --diff
54-
EOF
55-
56-
bash run_format_check.sh
57-
5865
# Create cache folders
5966
- name: Create cache folder
6067
run: |
61-
mkdir -p ${{ github.workspace }}/ccache
62-
mkdir -p ${{ github.workspace }}/.cache.cpm
68+
mkdir -p ${{ github.workspace }}/mlir-tensorrt/ccache
69+
mkdir -p ${{ github.workspace }}/mlir-tensorrt/.cache.cpm
6370
6471
# Restore cache, if exists.
6572
- name: Restore cache
6673
id: restore-cache
6774
uses: actions/cache/restore@v4
6875
with:
69-
key: ${{ runner.os }}-mlir-tensorrt-cache-${{ hashFiles('mlir-tensorrt/**/*.cpp', 'mlir-tensorrt/**/*.h', 'mlir-tensorrt/build_tools/**/*') }}
76+
key: ${{ runner.os }}-mlir-tensorrt-cache-${{ hashFiles('mlir-tensorrt/**/*.cpp', 'mlir-tensorrt/**/*.h') }}
7077
restore-keys: |
7178
${{ runner.os }}-mlir-tensorrt-cache-
7279
path: |
73-
${{ github.workspace }}/ccache
74-
${{ github.workspace }}/.cache.cpm/*
75-
!${{ github.workspace }}/.cache.cpm/tensorrt
80+
${{ github.workspace }}/mlir-tensorrt/ccache
81+
${{ github.workspace }}/mlir-tensorrt/.cache.cpm/*
82+
!${{ github.workspace }}/mlir-tensorrt/.cache.cpm/tensorrt
7683
77-
# TensorRT 10 tests
78-
- name: TensorRT 10 build
79-
uses: addnab/docker-run-action@v3
80-
with:
81-
image: ${{ env.DEFAULT_IMAGE }}
82-
options: -v ${{ github.workspace }}/mlir-tensorrt:/mlir-tensorrt -v ${{ github.workspace }}/ccache:/ccache -v ${{ github.workspace }}/.cache.cpm:/.cache.cpm --gpus all
83-
registry: ${{ env.REGISTRY }}
84-
username: ${{ github.actor }}
85-
password: ${{ secrets.GITHUB_TOKEN }}
86-
run: |
87-
cd mlir-tensorrt
88-
./build_tools/scripts/cicd_build.sh --build_only
84+
- name: Build only
85+
env:
86+
CMAKE_PRESET: "github-cicd"
87+
ENABLE_ASAN: "OFF"
88+
CCACHE_DIR: ${{ github.workspace }}/mlir-tensorrt/ccache
89+
CPM_SOURCE_CACHE: ${{ github.workspace }}/mlir-tensorrt/.cache.cpm
90+
run: |
91+
cd mlir-tensorrt
92+
./build_tools/scripts/cicd-build.sh --build_only
8993
9094
- name: Save cache
9195
id: save-cache
9296
uses: actions/cache/save@v4
9397
with:
94-
key: ${{ runner.os }}-mlir-tensorrt-cache-${{ hashFiles('mlir-tensorrt/**/*.cpp', 'mlir-tensorrt/**/*.h', 'mlir-tensorrt/build_tools/**/*') }}
98+
key: ${{ runner.os }}-mlir-tensorrt-cache-${{ hashFiles('mlir-tensorrt/**/*.cpp', 'mlir-tensorrt/**/*.h') }}
9599
path: |
96-
${{ github.workspace }}/ccache
97-
${{ github.workspace }}/.cache.cpm/*
98-
!${{ github.workspace }}/.cache.cpm/tensorrt
100+
${{ github.workspace }}/mlir-tensorrt/ccache
101+
${{ github.workspace }}/mlir-tensorrt/.cache.cpm/*
102+
!${{ github.workspace }}/mlir-tensorrt/.cache.cpm/tensorrt
99103
100-
- name: TensorRT 10 test
101-
uses: addnab/docker-run-action@v3
102-
with:
103-
image: ${{ env.DEFAULT_IMAGE }}
104-
options: -v ${{ github.workspace }}/mlir-tensorrt:/mlir-tensorrt -v ${{ github.workspace }}/ccache:/ccache -v ${{ github.workspace }}/.cache.cpm:/.cache.cpm --gpus all
105-
registry: ${{ env.REGISTRY }}
106-
username: ${{ github.actor }}
107-
password: ${{ secrets.GITHUB_TOKEN }}
108-
run: |
109-
cd mlir-tensorrt
110-
./build_tools/scripts/cicd_build.sh
111-
112-
# TensorRT 10 & ASAN
113-
- name: TensorRT 10 ASAN test
114-
uses: addnab/docker-run-action@v3
115-
with:
116-
image: ${{ env.DEFAULT_IMAGE }}
117-
options: -v ${{ github.workspace }}/mlir-tensorrt:/mlir-tensorrt -v ${{ github.workspace }}/ccache:/ccache -v ${{ github.workspace }}/.cache.cpm:/.cache.cpm --gpus all
118-
registry: ${{ env.REGISTRY }}
119-
username: ${{ github.actor }}
120-
password: ${{ secrets.GITHUB_TOKEN }}
121-
run: |
122-
cd mlir-tensorrt
123-
ENABLE_ASAN=ON ./build_tools/scripts/cicd_build.sh
104+
- name: Build and test
105+
env:
106+
CMAKE_PRESET: "github-cicd"
107+
ENABLE_ASAN: "OFF"
108+
CCACHE_DIR: ${{ github.workspace }}/mlir-tensorrt/ccache
109+
CPM_SOURCE_CACHE: ${{ github.workspace }}/mlir-tensorrt/.cache.cpm
110+
run: |
111+
cd mlir-tensorrt
112+
./build_tools/scripts/cicd-build.sh
Lines changed: 86 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,84 @@
11
name: Post-merge container update mlir-tensorrt
22

3-
# This workflow uses actions that are not certified by GitHub.
4-
# They are provided by a third-party and are governed by
5-
# separate terms of service, privacy policy, and support
6-
# documentation.
3+
# This workflow builds and pushes Docker dev containers for mlir-tensorrt
4+
# based on the build.json configurations in .devcontainer directories.
75

86
on:
97
push:
10-
branches: [ "main" ]
11-
paths: ['mlir-tensorrt/build_tools/docker/Dockerfile',
12-
'mlir-tensorrt/python/requirements-dev.txt',
13-
'mlir-tensorrt/python/requirements.txt']
8+
branches: ["main"]
9+
paths:
10+
- "mlir-tensorrt/.devcontainer/**/devcontainer.json"
11+
- "mlir-tensorrt/.devcontainer/generate.py"
12+
- "mlir-tensorrt/build_tools/docker/*"
1413

1514
env:
16-
# Use docker.io for Docker Hub if empty
1715
REGISTRY: ghcr.io
18-
# github.repository as <account>/<repo>
19-
IMAGE_NAME: ${{ github.repository }}
20-
TAG_UBUNTU: ghcr.io/nvidia/tensorrt-incubator/mlir-tensorrt:cuda12.5-ubuntu-llvm17
21-
TAG_ROCKY_LINUX: ghcr.io/nvidia/tensorrt-incubator/mlir-tensorrt:cuda12.5-rockylinux8-gcc11
16+
IMAGE_PREFIX: ghcr.io/nvidia/tensorrt-incubator/mlir-tensorrt
17+
VERSION_SUFFIX: "0.1"
2218

2319
jobs:
24-
build:
20+
# First job: discover all build.json files and create a matrix
21+
discover-containers:
2522
runs-on: ubuntu-latest
23+
outputs:
24+
matrix: ${{ steps.set-matrix.outputs.matrix }}
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v4
28+
29+
- name: Discover container configurations
30+
id: set-matrix
31+
run: |
32+
# Find all build.json files under mlir-tensorrt/.devcontainer
33+
configs=()
34+
for file in mlir-tensorrt/.devcontainer/*/devcontainer.json; do
35+
# Skip files where the directory contains the suffix "-prebuilt"
36+
if [[ -f "$file" && ! "$(dirname "$file")" =~ -prebuilt$ ]]; then
37+
# Extract configuration from build.json
38+
name=$(jq -r '.name' "$file")
39+
base_image=$(jq -r '.build.args.BASE_IMAGE' "$file")
40+
linux_distro=$(jq -r '.build.args.LINUX_DISTRO' "$file")
41+
llvm_version=$(jq -r '.build.args.LLVM_VERSION' "$file")
42+
dockerfile=$(jq -r '.build.dockerfile' "$file" | sed 's|\${localWorkspaceFolder}|mlir-tensorrt|g')
43+
44+
# Create JSON object for this configuration (compact, single-line)
45+
config=$(jq -cn \
46+
--arg name "$name" \
47+
--arg base_image "$base_image" \
48+
--arg linux_distro "$linux_distro" \
49+
--arg llvm_version "$llvm_version" \
50+
--arg dockerfile "$dockerfile" \
51+
--arg build_json "$file" \
52+
'{name: $name, base_image: $base_image, linux_distro: $linux_distro, llvm_version: $llvm_version, dockerfile: $dockerfile, build_json: $build_json}')
53+
configs+=("$config")
54+
fi
55+
done
56+
57+
# Create the matrix JSON (compact output for GITHUB_OUTPUT compatibility)
58+
if [[ ${#configs[@]} -eq 0 ]]; then
59+
echo "No build.json files found"
60+
echo "matrix={\"include\":[]}" >> $GITHUB_OUTPUT
61+
else
62+
matrix=$(printf '%s\n' "${configs[@]}" | jq -sc '{include: .}')
63+
echo "matrix=$matrix" >> $GITHUB_OUTPUT
64+
fi
65+
66+
- name: Display matrix
67+
run: |
68+
echo "Container build matrix:"
69+
echo '${{ steps.set-matrix.outputs.matrix }}' | jq .
70+
71+
# Second job: build and push containers based on the matrix
72+
build-and-push:
73+
needs: discover-containers
74+
if: ${{ needs.discover-containers.outputs.matrix != '{"include":[]}' && fromJson(needs.discover-containers.outputs.matrix).include[0] != null }}
75+
runs-on: ubuntu-latest
76+
strategy:
77+
fail-fast: false
78+
matrix: ${{ fromJson(needs.discover-containers.outputs.matrix) }}
2679
permissions:
2780
contents: read
2881
packages: write
29-
# This is used to complete the identity challenge
30-
# with sigstore/fulcio when running outside of PRs.
3182
id-token: write
3283

3384
steps:
@@ -48,93 +99,42 @@ jobs:
4899
sudo apt-get autoremove -y
49100
sudo apt-get autoclean -y
50101
102+
- name: Checkout repository
103+
uses: actions/checkout@v5
104+
51105
- name: Show disk usage
52106
run: df . -h
53107

54-
- name: Checkout repository
55-
uses: actions/checkout@v4
56-
57-
# Install the cosign tool
58-
# https://github.com/sigstore/cosign-installer
59-
- name: Install cosign
60-
uses: sigstore/cosign-installer@59acb6260d9c0ba8f4a2f9d9b48431a222b68e20 #v3.5.0
61-
with:
62-
cosign-release: 'v2.2.4'
108+
- name: Set up QEMU
109+
uses: docker/setup-qemu-action@v3
63110

64-
# Set up BuildKit Docker container builder to be able to build
65-
# multi-platform images and export cache
66-
# https://github.com/docker/setup-buildx-action
67111
- name: Set up Docker Buildx
68-
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
112+
uses: docker/setup-buildx-action@v3
69113

70-
# Login against a Docker registry
71-
# https://github.com/docker/login-action
72114
- name: Log into registry ${{ env.REGISTRY }}
73-
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
115+
uses: docker/login-action@v3
74116
with:
75117
registry: ${{ env.REGISTRY }}
76118
username: ${{ github.actor }}
77119
password: ${{ secrets.GITHUB_TOKEN }}
78120

79-
# Extract metadata (tags, labels) for Docker
80-
# https://github.com/docker/metadata-action
81121
- name: Extract Docker metadata
82122
id: meta
83-
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
123+
uses: docker/metadata-action@v5
84124
with:
85-
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
125+
images: ${{ env.IMAGE_PREFIX }}
86126

87-
# Build and push Docker image with Buildx
88-
# https://github.com/docker/build-push-action
89-
- name: Build and push Docker image for Ubuntu
90-
id: build-and-push-ubuntu
91-
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
127+
- name: Build and push Docker image - ${{ matrix.name }}
128+
id: build-and-push
129+
uses: docker/build-push-action@v6
92130
with:
93-
context: mlir-tensorrt/
94-
file: mlir-tensorrt/build_tools/docker/Dockerfile
95-
build-args: |
96-
BASE_IMAGE=nvcr.io/nvidia/cuda:12.5.1-cudnn-devel-ubuntu22.04
97-
LINUX_DISTRO=ubuntu
131+
context: mlir-tensorrt/build_tools/docker
132+
file: ${{ matrix.dockerfile }}
98133
push: true
99-
tags: ${{ env.TAG_UBUNTU }}
134+
platforms: linux/amd64,linux/arm64
135+
tags: ${{ env.IMAGE_PREFIX }}:${{ matrix.name }}-${{ env.VERSION_SUFFIX }}
100136
labels: ${{ steps.meta.outputs.labels }}
101-
cache-from: type=gha
102-
cache-to: type=gha,mode=max
103-
104-
- name: Build and push Docker image for Rocky Linux
105-
id: build-and-push-rocky-linux
106-
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
107-
with:
108-
context: mlir-tensorrt/
109-
file: mlir-tensorrt/build_tools/docker/Dockerfile
110137
build-args: |
111-
BASE_IMAGE=nvcr.io/nvidia/cuda:12.5.1-cudnn-devel-rockylinux8
112-
LINUX_DISTRO=rockylinux
113-
push: true
114-
tags: ${{ env.TAG_ROCKY_LINUX }}
115-
labels: ${{ steps.meta.outputs.labels }}
116-
cache-from: type=gha
117-
cache-to: type=gha,mode=max
118-
119-
# Sign the resulting Docker image digest.
120-
# This will only write to the public Rekor transparency log when the Docker
121-
# repository is public to avoid leaking data. If you would like to publish
122-
# transparency data even for private images, pass --force to cosign below.
123-
# https://github.com/sigstore/cosign
124-
- name: Sign the published Docker image Ubuntu
125-
env:
126-
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
127-
TAGS: ${{ env.TAG_UBUNTU }}
128-
DIGEST: ${{ steps.build-and-push-ubuntu.outputs.digest }}
129-
# This step uses the identity token to provision an ephemeral certificate
130-
# against the sigstore community Fulcio instance.
131-
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}
132-
133-
- name: Sign the published Docker image Rocky Linux
134-
env:
135-
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
136-
TAGS: ${{ env.TAG_ROCKY_LINUX }}
137-
DIGEST: ${{ steps.build-and-push-rocky-linux.outputs.digest }}
138-
# This step uses the identity token to provision an ephemeral certificate
139-
# against the sigstore community Fulcio instance.
140-
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}
138+
BASE_IMAGE=${{ matrix.base_image }}
139+
LINUX_DISTRO=${{ matrix.linux_distro }}
140+
LLVM_VERSION=${{ matrix.llvm_version }}

0 commit comments

Comments
 (0)