|
| 1 | +@echo off |
| 2 | +setlocal EnableDelayedExpansion |
| 3 | + |
| 4 | +echo === RTXpy Conda Build (Windows) === |
| 5 | + |
| 6 | +REM --------------------------------------------------------------------------- |
| 7 | +REM Step 1: Install OptiX SDK headers |
| 8 | +REM --------------------------------------------------------------------------- |
| 9 | +if "%OPTIX_VERSION%"=="" set OPTIX_VERSION=7.7.0 |
| 10 | +set OPTIX_DIR=%SRC_DIR%\optix-sdk |
| 11 | + |
| 12 | +echo === Installing OptiX SDK headers (v%OPTIX_VERSION%) === |
| 13 | +git clone --depth 1 --branch "v%OPTIX_VERSION%" https://github.com/NVIDIA/optix-dev.git "%OPTIX_DIR%" |
| 14 | +if errorlevel 1 exit /b 1 |
| 15 | + |
| 16 | +if not exist "%OPTIX_DIR%\include\optix.h" ( |
| 17 | + echo ERROR: OptiX headers not found after clone |
| 18 | + exit /b 1 |
| 19 | +) |
| 20 | + |
| 21 | +set OptiX_INSTALL_DIR=%OPTIX_DIR% |
| 22 | +echo OptiX headers installed at: %OptiX_INSTALL_DIR% |
| 23 | + |
| 24 | +REM --------------------------------------------------------------------------- |
| 25 | +REM Step 2: Detect GPU architecture and compile PTX |
| 26 | +REM --------------------------------------------------------------------------- |
| 27 | +echo === Compiling PTX kernel === |
| 28 | + |
| 29 | +REM Try to detect GPU architecture, fall back to a compatible default |
| 30 | +if "%GPU_ARCH%"=="" ( |
| 31 | + for /f "tokens=*" %%a in ('nvidia-smi --query-gpu^=compute_cap --format^=csv^,noheader 2^>nul') do ( |
| 32 | + set GPU_ARCH_RAW=%%a |
| 33 | + set GPU_ARCH=!GPU_ARCH_RAW:.=! |
| 34 | + goto :arch_found |
| 35 | + ) |
| 36 | +) |
| 37 | +:arch_found |
| 38 | + |
| 39 | +REM Default to sm_75 (Turing) - minimum supported by CUDA 12+ |
| 40 | +REM PTX is forward-compatible, so this will JIT-compile on newer GPUs |
| 41 | +if "%GPU_ARCH%"=="" set GPU_ARCH=75 |
| 42 | + |
| 43 | +echo Target GPU architecture: sm_%GPU_ARCH% |
| 44 | + |
| 45 | +nvcc -ptx ^ |
| 46 | + -arch="sm_%GPU_ARCH%" ^ |
| 47 | + -I"%OptiX_INSTALL_DIR%\include" ^ |
| 48 | + -I"%SRC_DIR%\cuda" ^ |
| 49 | + --use_fast_math ^ |
| 50 | + -o "%SRC_DIR%\rtxpy\kernel.ptx" ^ |
| 51 | + "%SRC_DIR%\cuda\kernel.cu" |
| 52 | +if errorlevel 1 exit /b 1 |
| 53 | + |
| 54 | +echo PTX compiled successfully |
| 55 | + |
| 56 | +REM --------------------------------------------------------------------------- |
| 57 | +REM Step 3: Install otk-pyoptix from source |
| 58 | +REM --------------------------------------------------------------------------- |
| 59 | +echo === Installing otk-pyoptix === |
| 60 | +set OTK_PYOPTIX_DIR=%SRC_DIR%\otk-pyoptix |
| 61 | + |
| 62 | +git clone --depth 1 https://github.com/NVIDIA/otk-pyoptix.git "%OTK_PYOPTIX_DIR%" |
| 63 | +if errorlevel 1 exit /b 1 |
| 64 | + |
| 65 | +cd /d "%OTK_PYOPTIX_DIR%\optix" |
| 66 | +"%PYTHON%" -m pip install . --no-deps --no-build-isolation -vv |
| 67 | +if errorlevel 1 exit /b 1 |
| 68 | + |
| 69 | +REM --------------------------------------------------------------------------- |
| 70 | +REM Step 4: Install rtxpy |
| 71 | +REM --------------------------------------------------------------------------- |
| 72 | +echo === Installing rtxpy === |
| 73 | +cd /d "%SRC_DIR%" |
| 74 | + |
| 75 | +"%PYTHON%" -m pip install . --no-deps --no-build-isolation -vv |
| 76 | +if errorlevel 1 exit /b 1 |
| 77 | + |
| 78 | +echo === RTXpy build complete === |
0 commit comments