Experimenting with removing cpp extension in favor of pyoptix #2
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
| name: GPU Test | |
| # GPU tests are triggered by adding the "GPU CI" label to a PR | |
| # This prevents expensive GPU runners from running on every commit | |
| on: | |
| pull_request: | |
| types: [labeled] | |
| jobs: | |
| gpu-test: | |
| name: GPU Test ${{ matrix.python-version }} | |
| # Only run when the "GPU CI" label is added | |
| if: github.event.label.name == 'GPU CI' | |
| # Use the GPU runner group - you need to create this in your org settings | |
| # Go to: Organization Settings > Actions > Runner groups > Create new runner group | |
| # Select "NVIDIA GPU-Optimized Image for Linux" when creating the runner | |
| runs-on: | |
| group: gpu-runners | |
| labels: linux-gpu | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python-version: ["3.11", "3.12", "3.13"] | |
| steps: | |
| - name: Checkout source | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Install Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Verify GPU and CUDA | |
| run: | | |
| echo "=== NVIDIA GPU Info ===" | |
| nvidia-smi | |
| echo "" | |
| echo "=== CUDA Version ===" | |
| nvcc --version || echo "nvcc not in PATH, checking CUDA_PATH..." | |
| echo "CUDA_PATH=${CUDA_PATH:-not set}" | |
| echo "" | |
| echo "=== Looking for OptiX SDK ===" | |
| # Common locations for OptiX SDK | |
| for dir in /opt/nvidia/OptiX* /usr/local/OptiX* "$HOME/OptiX*" /opt/optix*; do | |
| if [ -d "$dir" ]; then | |
| echo "Found OptiX at: $dir" | |
| export OptiX_INSTALL_DIR="$dir" | |
| fi | |
| done | |
| echo "OptiX_INSTALL_DIR=${OptiX_INSTALL_DIR:-not found}" | |
| - name: Install OptiX SDK | |
| run: | | |
| # Download and install OptiX SDK if not present | |
| # Note: OptiX SDK requires NVIDIA developer account for direct download | |
| # The NVIDIA GPU-Optimized image may have it pre-installed | |
| if [ -z "$OptiX_INSTALL_DIR" ]; then | |
| echo "OptiX SDK not found in common locations" | |
| echo "Checking if otk-pyoptix wheel is available..." | |
| fi | |
| - name: Install build dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y cmake | |
| - name: Install otk-pyoptix from source | |
| run: | | |
| # Clone and install otk-pyoptix | |
| git clone --depth 1 https://github.com/NVIDIA/otk-pyoptix.git /tmp/otk-pyoptix | |
| cd /tmp/otk-pyoptix/optix | |
| # Set OptiX path if found | |
| if [ -n "$OptiX_INSTALL_DIR" ]; then | |
| export OptiX_INSTALL_DIR | |
| fi | |
| pip install . | |
| - name: Install rtxpy with CUDA dependencies | |
| run: | | |
| python -m pip install -U pip | |
| python -m pip install -ve .[tests,cuda12] | |
| python -m pip list | |
| - name: Run GPU tests | |
| run: | | |
| python -m pytest -v rtxpy/tests | |
| - name: Test basic ray tracing | |
| run: | | |
| python -c " | |
| from rtxpy import RTX | |
| import numpy as np | |
| # Simple triangle mesh test | |
| verts = np.float32([0,0,0, 1,0,0, 0,1,0, 1,1,0]) | |
| triangles = np.int32([0,1,2, 2,1,3]) | |
| rays = np.float32([0.33,0.33,100, 0,0,0, -1,1000]) | |
| hits = np.float32([0,0,0,0]) | |
| optix = RTX() | |
| res = optix.build(0, verts, triangles) | |
| assert res == 0, f'Build failed with {res}' | |
| res = optix.trace(rays, hits, 1) | |
| assert res == 0, f'Trace failed with {res}' | |
| print(f'Hit result: t={hits[0]}, normal=({hits[1]}, {hits[2]}, {hits[3]})') | |
| assert hits[0] > 0, 'Expected a hit' | |
| print('GPU ray tracing test PASSED!') | |
| " |