Build Wheels (CUDA) for Windows #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
| name: Build Wheels (CUDA) for Windows | |
| on: | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| define_matrix: | |
| name: Define Build Matrix | |
| runs-on: windows-2022 | |
| outputs: | |
| matrix: ${{ steps.set-matrix.outputs.matrix }} | |
| defaults: | |
| run: | |
| shell: pwsh | |
| steps: | |
| - name: Define Job Output | |
| id: set-matrix | |
| run: | | |
| $matrix = @{ | |
| 'os' = @('windows-2022') | |
| 'pyver' = @("3.13") | |
| 'cuda' = @("12.9.0") | |
| 'releasetag' = @("AVX2") | |
| 'cudaarch' = @("all") | |
| } | |
| $matrixOut = ConvertTo-Json $matrix -Compress | |
| Write-Output ('matrix=' + $matrixOut) >> $env:GITHUB_OUTPUT | |
| build_wheels: | |
| name: Build Wheel ${{ matrix.os }} ${{ matrix.pyver }} ${{ matrix.cuda }} ${{ matrix.releasetag == 'wheels' && 'AVX2' || matrix.releasetag }} | |
| needs: define_matrix | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: ${{ fromJSON(needs.define_matrix.outputs.matrix) }} | |
| defaults: | |
| run: | |
| shell: pwsh | |
| env: | |
| CUDAVER: ${{ matrix.cuda }} | |
| AVXVER: ${{ matrix.releasetag }} | |
| CUDAARCHVER: ${{ matrix.cudaarch }} | |
| # https://cmake.org/cmake/help/latest/prop_tgt/CUDA_ARCHITECTURES.html | |
| # https://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/#gpu-feature-list | |
| # RTX 5080 uses Blackwell architecture with sm_120 compute capability | |
| # Using "all" to let CMake auto-detect compatible architectures | |
| steps: | |
| - name: Add MSBuild to PATH | |
| if: runner.os == 'Windows' | |
| uses: microsoft/setup-msbuild@v2 | |
| with: | |
| msbuild-architecture: x64 | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: "recursive" | |
| # Install CUDA toolkit with support for 12.9.0 | |
| - name: Install CUDA ${{ matrix.cuda }} | |
| uses: Jimver/cuda-toolkit@v0.2.24 | |
| id: cuda-toolkit | |
| with: | |
| cuda: "${{ matrix.cuda }}" | |
| # Explicit method for CUDA 12.9 support with verbose logging | |
| method: 'network' | |
| log-file-suffix: 'cu${{ matrix.cuda }}-py${{ matrix.pyver }}.txt' | |
| # Install UV with Python 3.13 support | |
| - name: Install the latest version of uv and set the python version | |
| uses: astral-sh/setup-uv@v6 | |
| with: | |
| python-version: ${{ matrix.pyver }} | |
| activate-environment: true | |
| enable-cache: true | |
| - name: Install Dependencies | |
| run: | | |
| git config --system core.longpaths true | |
| uv pip install --upgrade build setuptools wheel packaging | |
| # Install additional dependencies for Python 3.13 compatibility | |
| uv pip install --upgrade cmake ninja | |
| - name: Build Wheel | |
| run: | | |
| $cudaVersion = $env:CUDAVER.Remove($env:CUDAVER.LastIndexOf('.')).Replace('.','') | |
| $env:CUDA_HOME = $env:CUDA_PATH | |
| $env:CUDA_TOOLKIT_ROOT_DIR = $env:CUDA_PATH | |
| # Enhanced environment variables for better compatibility | |
| $env:CUDACXX = "$env:CUDA_PATH\bin\nvcc.exe" | |
| $env:CUDA_NVCC_EXECUTABLE = "$env:CUDA_PATH\bin\nvcc.exe" | |
| if ($IsLinux) { | |
| $env:LD_LIBRARY_PATH = $env:CONDA_PREFIX + '/lib:' + $env:LD_LIBRARY_PATH | |
| } | |
| $env:VERBOSE = '1' | |
| $env:CMAKE_BUILD_TYPE = 'Release' | |
| # Updated CMAKE_ARGS for RTX 5080 - using "all" for compatibility | |
| # This will auto-detect and build for all compatible architectures including RTX 5080 | |
| $env:CMAKE_ARGS = '-DGGML_CUDA=on -DCMAKE_CUDA_ARCHITECTURES=' + $env:CUDAARCHVER | |
| $env:CMAKE_ARGS = "-DGGML_CUDA_FORCE_MMQ=ON $env:CMAKE_ARGS" | |
| $env:CMAKE_ARGS = "-DLLAMA_CURL=OFF $env:CMAKE_ARGS" | |
| $env:CMAKE_ARGS = "-DGGML_CUDA_FORCE_DMMV=ON $env:CMAKE_ARGS" | |
| $env:CMAKE_ARGS = "-DGGML_CUDA_FORCE_CUBLAS=ON $env:CMAKE_ARGS" | |
| # AMD 9800X3D optimizations (AVX2 support) | |
| if ($env:AVXVER -eq 'AVX') { | |
| $env:CMAKE_ARGS = $env:CMAKE_ARGS + ' -DGGML_AVX2=off -DGGML_FMA=off -DGGML_F16C=off' | |
| } | |
| if ($env:AVXVER -eq 'AVX2') { | |
| $env:CMAKE_ARGS = $env:CMAKE_ARGS + ' -DGGML_AVX2=on -DGGML_FMA=on -DGGML_F16C=on' | |
| } | |
| # Additional optimizations for modern hardware | |
| $env:CMAKE_ARGS = $env:CMAKE_ARGS + ' -DGGML_NATIVE=on' | |
| # Build with enhanced error handling | |
| try { | |
| python -m build --wheel | |
| } catch { | |
| Write-Error "Build failed: $_" | |
| exit 1 | |
| } | |
| # Set output variables | |
| Write-Output "CUDA_VERSION=$cudaVersion" >> $env:GITHUB_ENV | |
| $wheel = (Get-ChildItem '.\dist\*.whl')[0] | |
| if ($wheel) { | |
| $tagVer = $wheel.name.split('-')[1] | |
| Write-Output "TAG_VERSION=$tagVer" >> $env:GITHUB_ENV | |
| } else { | |
| Write-Error "No wheel file found in dist/" | |
| exit 1 | |
| } | |
| - name: Get Current Date | |
| id: get-date | |
| run: | | |
| $currentDate = Get-Date -UFormat "%Y%m%d" | |
| Write-Output "BUILD_DATE=$currentDate" >> $env:GITHUB_ENV | |
| - name: Upload Release Assets | |
| uses: softprops/action-gh-release@v2.2.2 | |
| with: | |
| files: dist/* | |
| # Updated tag format for CUDA 12.9 and Python 3.13 | |
| tag_name: v${{ env.TAG_VERSION }}-cu${{ env.CUDA_VERSION }}-${{ env.AVXVER }}-win-${{ env.BUILD_DATE }} | |
| body: | | |
| ## llama-cpp-python Build | |
| **Configuration:** | |
| - Python: ${{ matrix.pyver }} (matches your ComfyUI environment) | |
| - CUDA: ${{ matrix.cuda }} (compatible with PyTorch 2.8.0+cu129) | |
| - Architecture: all (auto-detect RTX 5080 Blackwell) | |
| - CPU Optimizations: ${{ matrix.releasetag }} (AMD 9800X3D optimized) | |
| - Platform: Windows | |
| **Compatible with:** | |
| - AMD 9800X3D (AVX2 + FMA + F16C optimized) | |
| - RTX 5080 (Blackwell architecture, sm_120) | |
| - PyTorch 2.8.0+cu129 (your exact ComfyUI version) | |
| - ComfyUI 0.3.51+ | |
| Built on: ${{ env.BUILD_DATE }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |