-
Notifications
You must be signed in to change notification settings - Fork 9
[None] Add CI #15
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
Merged
Merged
[None] Add CI #15
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 3.9 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| #!/usr/bin/env python3 | ||
| # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| from utils import run_command, setup_trt_rtx, TRTRTX_INSTALL_DIR, BUILD_DIR | ||
|
|
||
| def build_samples(): | ||
| """Build C++ samples.""" | ||
| print("Building C++ samples...") | ||
| run_command(f"cmake -B {BUILD_DIR} -S samples -DTRTRTX_INSTALL_DIR={TRTRTX_INSTALL_DIR}") | ||
| run_command(f"cmake --build {BUILD_DIR}") | ||
|
|
||
| def main(): | ||
| # Setup TensorRT RTX | ||
| setup_trt_rtx() | ||
|
|
||
| # Build samples | ||
| build_samples() | ||
|
|
||
| print("Build completed successfully!") | ||
|
|
||
| if __name__ == "__main__": | ||
| main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| name: CI | ||
| on: push | ||
| env: | ||
| TRT_RTX_FILENAME: TensorRT-RTX-1.1.1.26.Linux.x86_64-gnu.cuda-12.9.tar.gz | ||
| TRTRTX_INSTALL_DIR: /opt/tensorrt_rtx | ||
| BUILD_DIR: build | ||
| UV_PROJECT: .github/workflows/ | ||
| jobs: | ||
| build-linux: | ||
| runs-on: ubuntu-24.04 | ||
| container: nvcr.io/nvidia/cuda:12.9.1-devel-ubuntu22.04 | ||
| steps: | ||
| - uses: actions/checkout@v5 | ||
|
|
||
| - name: Install uv | ||
| uses: astral-sh/setup-uv@v6 | ||
| with: | ||
| python-version: 3.9 | ||
|
|
||
| - name: Set up Python | ||
| run: uv python install | ||
|
|
||
| - name: Cache TensorRT RTX | ||
| id: cache-trt-rtx | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: ${{ env.TRTRTX_INSTALL_DIR }} | ||
| key: tensorrt-rtx-${{ runner.os }}-${{ env.TRT_RTX_FILENAME }} | ||
|
|
||
| - name: Run build script | ||
| env: | ||
| CACHE_DEB_HIT: ${{ steps.cache-deb.outputs.cache-hit }} | ||
| CACHE_TRT_RTX_HIT: ${{ steps.cache-trt-rtx.outputs.cache-hit }} | ||
| run: uv run --group build .github/workflows/build.py | ||
|
|
||
| - name: Upload build artifacts | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: linux-build-artifacts | ||
| path: ${{ env.BUILD_DIR }}/ | ||
|
|
||
| test-linux: | ||
| needs: build-linux | ||
| runs-on: [linux-amd64-gpu-rtx4090-latest-1] | ||
| container: | ||
| image: nvcr.io/nvidia/cuda:12.9.1-runtime-ubuntu22.04 | ||
| options: --gpus all | ||
| steps: | ||
| - uses: actions/checkout@v5 | ||
|
|
||
| - name: Install uv | ||
| uses: astral-sh/setup-uv@v6 | ||
| with: | ||
| version: "0.8.22" | ||
| python-version: "3.9" | ||
|
|
||
| - name: Set up Python | ||
| run: uv python install | ||
|
|
||
| - name: Cache TensorRT RTX | ||
| id: cache-trt-rtx | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: ${{ env.TRTRTX_INSTALL_DIR }} | ||
| key: tensorrt-rtx-${{ runner.os }}-${{ env.TRT_RTX_FILENAME }} | ||
|
|
||
| - name: Download build artifacts | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: linux-build-artifacts | ||
| path: ${{ env.BUILD_DIR }}/ | ||
|
|
||
| - name: Run test script | ||
| env: | ||
| CACHE_TRT_RTX_HIT: ${{ steps.cache-trt-rtx.outputs.cache-hit }} | ||
| run: uv run .github/workflows/test.py |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| [project] | ||
| name = "trt_rtx_ci" | ||
| version = "0.1.0" | ||
| requires-python = ">=3.9" | ||
| dependencies = [ | ||
| "requests==2.*" | ||
| ] | ||
|
|
||
| [dependency-groups] | ||
| build = [ | ||
| "cmake==3.*" | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| #!/usr/bin/env python3 | ||
| # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| import os | ||
| from pathlib import Path | ||
| from utils import run_command, setup_trt_rtx, TRTRTX_INSTALL_DIR, BUILD_DIR | ||
|
|
||
| def install_python_deps(): | ||
| """Install Python dependencies.""" | ||
| print("Installing Python dependencies...") | ||
|
|
||
| # Install TensorRT RTX wheel | ||
| wheel_dir = Path(TRTRTX_INSTALL_DIR) / "python" | ||
| wheel_file = next(wheel_dir.glob("tensorrt_rtx-*-cp39-none-linux_x86_64.whl")) | ||
| run_command(f"uv pip install {wheel_file}") | ||
|
|
||
| # Install sample requirements | ||
| run_command("uv pip install -r samples/helloWorld/python/requirements.txt") | ||
| run_command("uv pip install -r samples/apiUsage/python/requirements.txt") | ||
| run_command("uv pip install --index-strategy unsafe-best-match -r demo/flux1.dev/requirements.txt") | ||
| run_command("uv pip install -r demo/tests/requirements-test.txt") | ||
|
|
||
| def run_cpp_tests(): | ||
| """Run C++ sample tests.""" | ||
| print("Running C++ tests...") | ||
| BINARIES = [f"{BUILD_DIR}/helloWorld/cpp/helloWorld", f"{BUILD_DIR}/apiUsage/cpp/apiUsage"] | ||
| for binary in BINARIES: | ||
| # Add the executable permission if not on Windows | ||
| if os.name != 'nt': | ||
| os.chmod(binary, os.stat(binary).st_mode | 0o111) | ||
| run_command(binary) | ||
|
|
||
| def run_python_tests(): | ||
| """Run Python sample tests.""" | ||
| print("Running Python tests...") | ||
| # Set up environment for tests | ||
| test_env = os.environ.copy() | ||
| test_env["LD_LIBRARY_PATH"] = f"{TRTRTX_INSTALL_DIR}/lib:{test_env.get('LD_LIBRARY_PATH', '')}" | ||
|
|
||
| run_command("uv run samples/helloWorld/python/hello_world.py", env=test_env) | ||
| run_command("uv run samples/apiUsage/python/api_usage.py", env=test_env) | ||
| run_command("uv run pytest demo/tests -v", env=test_env) | ||
|
|
||
| def main(): | ||
| # Setup TensorRT RTX | ||
| setup_trt_rtx() | ||
|
|
||
| # Install Python dependencies | ||
| install_python_deps() | ||
|
|
||
| # Run tests | ||
| run_cpp_tests() | ||
| run_python_tests() | ||
|
|
||
| print("All tests completed successfully!") | ||
|
|
||
| if __name__ == "__main__": | ||
| main() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| import io | ||
| import os | ||
| import requests | ||
| import subprocess | ||
| import sys | ||
| import tarfile | ||
| from pathlib import Path | ||
|
|
||
| # Common environment variables | ||
| TRT_RTX_BASE_URL = "https://developer.nvidia.com/downloads/trt/rtx_sdk/secure/1.1" | ||
| TRT_RTX_FILENAME = os.environ.get("TRT_RTX_FILENAME","TensorRT-RTX-1.1.1.26.Linux.x86_64-gnu.cuda-12.9.tar.gz") | ||
| TRTRTX_INSTALL_DIR = os.environ.get("TRTRTX_INSTALL_DIR", "/opt/tensorrt_rtx") | ||
| BUILD_DIR = os.environ.get('BUILD_DIR', 'build') | ||
|
|
||
| def run_command(cmd, check=True, shell=False, env=None): | ||
| """Run a command and handle errors.""" | ||
| try: | ||
| subprocess.run(cmd if shell else cmd.split(), check=check, shell=shell, env=env) | ||
| except subprocess.CalledProcessError as e: | ||
| print(f"Error running command: {cmd}") | ||
| print(f"Exit code: {e.returncode}") | ||
| sys.exit(e.returncode) | ||
|
|
||
| def setup_trt_rtx(): | ||
| """Download and setup TensorRT RTX.""" | ||
| if os.environ.get('CACHE_TRT_RTX_HIT') != 'true': | ||
| print("Cache miss for TensorRT RTX, downloading...") | ||
| url = f"{TRT_RTX_BASE_URL}/{TRT_RTX_FILENAME}" | ||
|
|
||
| if os.path.exists(TRTRTX_INSTALL_DIR): | ||
| print(f"Error: {TRTRTX_INSTALL_DIR} already exists. Remove it or set CACHE_TRT_RTX_HIT=true to proceed.") | ||
| exit(1) | ||
|
|
||
| # Download the TRT RTX tar file | ||
| response = requests.get(url, stream=True) | ||
| response.raise_for_status() | ||
|
|
||
| # Create a file-like object from the response content | ||
| tar_bytes = io.BytesIO(response.content) | ||
|
|
||
| # Extract tar file, stripping the first directory component | ||
| os.makedirs(TRTRTX_INSTALL_DIR) | ||
| with tarfile.open(fileobj=tar_bytes, mode='r:gz') as tar: | ||
| members = [m for m in tar.getmembers() if len(Path(m.name).parts) > 1] | ||
| for member in members: | ||
| member.name = str(Path(*Path(member.name).parts[1:])) | ||
| tar.extract(member, TRTRTX_INSTALL_DIR) | ||
| else: | ||
| print("Cache hit for TensorRT RTX") |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.