Skip to content

Commit 5b70a5c

Browse files
committed
add CI
Signed-off-by: Tyler Burt <195370667+tburt-nv@users.noreply.github.com>
1 parent 6a70878 commit 5b70a5c

File tree

4 files changed

+200
-0
lines changed

4 files changed

+200
-0
lines changed

.github/workflows/build.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env python3
2+
3+
import os
4+
from utils import run_command, setup_trt_rtx, TRTRTX_INSTALL_DIR, BUILD_DIR
5+
6+
def install_dependencies():
7+
"""Install required system packages."""
8+
print("Installing dependencies...")
9+
# Only install if cache miss
10+
if os.environ.get('CACHE_DEB_HIT') != 'true':
11+
run_command("apt-get update")
12+
run_command("apt-get install -y cmake wget")
13+
14+
def build_samples():
15+
"""Build C++ samples."""
16+
print("Building C++ samples...")
17+
run_command(f"cmake -B {BUILD_DIR} -S samples -DTRTRTX_INSTALL_DIR={TRTRTX_INSTALL_DIR}")
18+
run_command(f"cmake --build {BUILD_DIR}")
19+
20+
def main():
21+
# Setup system
22+
install_dependencies()
23+
24+
# Setup TensorRT RTX
25+
setup_trt_rtx()
26+
27+
# Build samples
28+
build_samples()
29+
30+
print("Build completed successfully!")
31+
32+
if __name__ == "__main__":
33+
main()

.github/workflows/ci.yaml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: CI Build and Test
2+
on: push
3+
env:
4+
TRT_RTX_BASE_URL: https://developer.nvidia.com/downloads/trt/rtx_sdk/secure/1.1
5+
TRT_RTX_FILENAME: TensorRT-RTX-1.1.1.26.Linux.x86_64-gnu.cuda-12.9.tar.gz
6+
TRTRTX_INSTALL_DIR: /opt/tensorrt_rtx
7+
BUILD_DIR: build
8+
jobs:
9+
build:
10+
runs-on: ubuntu-24.04
11+
container: nvcr.io/nvidia/cuda:12.9.1-devel-ubuntu22.04
12+
steps:
13+
- uses: actions/checkout@v5
14+
15+
- name: Cache Debian packages
16+
id: cache-deb
17+
uses: actions/cache@v4
18+
with:
19+
path: /var/cache/apt/archives/
20+
key: ${{ runner.os }}-apt-build
21+
22+
- name: Install lsb_release
23+
run: apt-get update && apt-get install -y python3
24+
25+
- name: Cache TensorRT RTX
26+
id: cache-trt-rtx
27+
uses: actions/cache@v4
28+
with:
29+
path: ${{ env.TRTRTX_INSTALL_DIR }}
30+
key: tensorrt-rtx-${{ runner.os }}-${{ env.TRT_RTX_FILENAME }}
31+
32+
- name: Run build script
33+
env:
34+
CACHE_DEB_HIT: ${{ steps.cache-deb.outputs.cache-hit }}
35+
CACHE_TRT_RTX_HIT: ${{ steps.cache-trt-rtx.outputs.cache-hit }}
36+
run: python3 .github/workflows/build.py
37+
38+
- name: Upload build artifacts
39+
uses: actions/upload-artifact@v4
40+
with:
41+
name: build-artifacts
42+
path: |
43+
{{ $env.BUILD_DIR }}/
44+
45+
test:
46+
# Disable while testing
47+
if: false
48+
needs: build
49+
runs-on: [linux-amd64-gpu-rtx2080-latest-1]
50+
container:
51+
image: nvcr.io/nvidia/ai-workbench/python-cuda129:1.0.1
52+
options: --gpus all
53+
steps:
54+
- uses: actions/checkout@v5
55+
56+
- name: Set up Python
57+
uses: actions/setup-python@v6
58+
with:
59+
cache: 'pip'
60+
61+
- name: Cache TensorRT RTX
62+
id: cache-trt-rtx
63+
uses: actions/cache@v4
64+
with:
65+
path: ${{ env.TRTRTX_INSTALL_DIR }}
66+
key: tensorrt-rtx-${{ runner.os }}-${{ env.TRT_RTX_FILENAME }}
67+
68+
- name: Download build artifacts
69+
uses: actions/download-artifact@v4
70+
with:
71+
name: build-artifacts
72+
73+
- name: Run test script
74+
env:
75+
CACHE_TRT_RTX_HIT: ${{ steps.cache-trt-rtx.outputs.cache-hit }}
76+
run: python3 .github/workflows/test.py

.github/workflows/test.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/usr/bin/env python3
2+
3+
import os
4+
from pathlib import Path
5+
from utils import run_command, setup_trt_rtx, TRTRTX_INSTALL_DIR, BUILD_DIR
6+
7+
def install_python_deps():
8+
"""Install Python dependencies."""
9+
print("Installing Python dependencies...")
10+
11+
# Install TensorRT RTX wheel
12+
wheel_pattern = str(Path(TRTRTX_INSTALL_DIR) / "python" / "tensorrt_rtx-*-cp310-none-linux_x86_64.whl")
13+
run_command(f"pip3 install {wheel_pattern}")
14+
15+
# Install sample requirements
16+
run_command("pip3 install -r samples/helloWorld/python/requirements.txt")
17+
run_command("pip3 install -r samples/apiUsage/python/requirements.txt")
18+
run_command("pip3 install -r demo/flux1.dev/requirements.txt")
19+
run_command("pip3 install -r demo/tests/requirements-test.txt")
20+
21+
def run_cpp_tests():
22+
"""Run C++ sample tests."""
23+
print("Running C++ tests...")
24+
run_command(f"{BUILD_DIR}/helloWorld/cpp/helloWorld")
25+
run_command(f"{BUILD_DIR}/apiUsage/cpp/apiUsage")
26+
27+
def run_python_tests():
28+
"""Run Python sample tests."""
29+
print("Running Python tests...")
30+
# Set up environment for tests
31+
test_env = os.environ.copy()
32+
test_env["LD_LIBRARY_PATH"] = f"{TRTRTX_INSTALL_DIR}/lib:{test_env.get('LD_LIBRARY_PATH', '')}"
33+
34+
run_command("python3 samples/helloWorld/python/hello_world.py", env=test_env)
35+
run_command("python3 samples/apiUsage/python/api_usage.py", env=test_env)
36+
run_command("python3 -m pytest demo/tests -v", env=test_env)
37+
38+
def main():
39+
# Setup TensorRT RTX
40+
setup_trt_rtx()
41+
42+
# Install Python dependencies
43+
install_python_deps()
44+
45+
# Run tests
46+
run_cpp_tests()
47+
run_python_tests()
48+
49+
print("All tests completed successfully!")
50+
51+
if __name__ == "__main__":
52+
main()

.github/workflows/utils.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/env python3
2+
3+
import os
4+
import subprocess
5+
import sys
6+
from pathlib import Path
7+
8+
# Common environment variables
9+
TRT_RTX_BASE_URL = "https://developer.nvidia.com/downloads/trt/rtx_sdk/secure/1.1"
10+
TRT_RTX_FILENAME = "TensorRT-RTX-1.1.1.26.Linux.x86_64-gnu.cuda-12.9.tar.gz"
11+
TRTRTX_INSTALL_DIR = "/opt/tensorrt_rtx"
12+
BUILD_DIR = os.environ.get('BUILD_DIR', 'build')
13+
14+
def run_command(cmd, check=True, shell=False, env=None):
15+
"""Run a command and handle errors."""
16+
try:
17+
subprocess.run(cmd if shell else cmd.split(), check=check, shell=shell, env=env)
18+
except subprocess.CalledProcessError as e:
19+
print(f"Error running command: {cmd}")
20+
print(f"Exit code: {e.returncode}")
21+
sys.exit(e.returncode)
22+
23+
def setup_trt_rtx():
24+
"""Download and setup TensorRT RTX."""
25+
if os.environ.get('CACHE_TRT_RTX_HIT') != 'true':
26+
print("Cache miss for TensorRT RTX, downloading...")
27+
url = f"{TRT_RTX_BASE_URL}/{TRT_RTX_FILENAME}"
28+
29+
if os.path.exists(TRTRTX_INSTALL_DIR):
30+
print(f"Error: {TRTRTX_INSTALL_DIR} already exists. Remove it to proceed.")
31+
exit(1)
32+
33+
# Download and extract
34+
run_command(f"wget -O /tmp/trt.tar.gz {url}")
35+
os.makedirs(TRTRTX_INSTALL_DIR)
36+
run_command(f"tar --directory={TRTRTX_INSTALL_DIR} --strip-components=1 -xzf /tmp/trt.tar.gz")
37+
os.remove("/tmp/trt.tar.gz")
38+
else:
39+
print("Cache hit for TensorRT RTX")

0 commit comments

Comments
 (0)