test(ci): build CUDA Pascal wheel archs #1
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: Test CUDA Pascal Wheel Archs | |
| on: | |
| push: | |
| branches: | |
| - test/cuda-pascal-archs-build | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| jobs: | |
| build: | |
| name: Build CUDA 12.5 wheel on ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: | |
| - ubuntu-22.04 | |
| - windows-2022 | |
| defaults: | |
| run: | |
| shell: pwsh | |
| env: | |
| CUDAVER: 12.5.1 | |
| steps: | |
| - name: Set up MSVC | |
| if: runner.os == 'Windows' | |
| uses: ilammy/msvc-dev-cmd@v1 | |
| with: | |
| arch: x64 | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.9" | |
| cache: pip | |
| - name: Setup Mamba | |
| uses: conda-incubator/setup-miniconda@v3.1.0 | |
| with: | |
| activate-environment: llamacpp | |
| python-version: "3.9" | |
| miniforge-version: latest | |
| add-pip-as-python-dependency: true | |
| auto-activate-base: false | |
| - name: Install dependencies | |
| env: | |
| MAMBA_DOWNLOAD_FAILFAST: "0" | |
| MAMBA_NO_LOW_SPEED_LIMIT: "1" | |
| run: | | |
| $cudaVersion = $env:CUDAVER | |
| $cudaChannel = "nvidia/label/cuda-$cudaVersion" | |
| if ($IsLinux) { | |
| mamba install -y --channel-priority flexible --override-channels -c $cudaChannel "${cudaChannel}::cuda-toolkit=$cudaVersion" "${cudaChannel}::cuda-nvcc_linux-64" "${cudaChannel}::cuda-cccl" "${cudaChannel}::cuda-cudart" "${cudaChannel}::cuda-cudart-dev" | |
| python -m pip install build wheel | |
| } elseif ($IsWindows) { | |
| mamba install -y --channel-priority flexible --override-channels -c $cudaChannel "${cudaChannel}::cuda-nvcc_win-64" "${cudaChannel}::cuda-cccl" "${cudaChannel}::cuda-libraries-dev=$cudaVersion" "${cudaChannel}::cuda-cudart" "${cudaChannel}::cuda-cudart-dev" | |
| python -m pip install build wheel ninja | |
| } else { | |
| throw 'Unsupported CUDA wheel build platform' | |
| } | |
| - name: Build wheel | |
| run: | | |
| $pathSeparator = if ($IsWindows) { ';' } else { ':' } | |
| if ($IsWindows) { | |
| $cudaRoot = Join-Path $env:CONDA_PREFIX 'Library' | |
| } elseif (Test-Path (Join-Path $env:CONDA_PREFIX 'targets/x86_64-linux/include/cuda_runtime.h')) { | |
| $cudaRoot = Join-Path $env:CONDA_PREFIX 'targets/x86_64-linux' | |
| } else { | |
| $cudaRoot = $env:CONDA_PREFIX | |
| } | |
| $env:CUDA_PATH = $cudaRoot | |
| $env:CUDA_HOME = $cudaRoot | |
| $env:CUDAToolkit_ROOT = $cudaRoot | |
| $env:CUDA_TOOLKIT_ROOT_DIR = $cudaRoot | |
| $cudaRootCmake = $cudaRoot.Replace('\', '/') | |
| $env:CMAKE_ARGS = "-DCUDAToolkit_ROOT=$cudaRootCmake -DCUDA_TOOLKIT_ROOT_DIR=$cudaRootCmake" | |
| if ($IsLinux) { | |
| if (Test-Path '/usr/bin/g++-12') { | |
| $env:CC = '/usr/bin/gcc-12' | |
| $env:CXX = '/usr/bin/g++-12' | |
| $env:CUDAHOSTCXX = '/usr/bin/g++-12' | |
| $env:CMAKE_ARGS = "$env:CMAKE_ARGS -DCMAKE_CUDA_HOST_COMPILER=$env:CUDAHOSTCXX" | |
| } | |
| $env:CPATH = "$cudaRoot/include$pathSeparator$env:CPATH" | |
| $env:CPLUS_INCLUDE_PATH = "$cudaRoot/include$pathSeparator$env:CPLUS_INCLUDE_PATH" | |
| $env:LIBRARY_PATH = "$cudaRoot/lib$pathSeparator$env:CONDA_PREFIX/lib$pathSeparator$env:LIBRARY_PATH" | |
| $env:LD_LIBRARY_PATH = "$cudaRoot/lib$pathSeparator$env:CONDA_PREFIX/lib$pathSeparator$env:LD_LIBRARY_PATH" | |
| } else { | |
| $ninjaPath = ((Get-Command ninja -ErrorAction Stop).Source).Replace('\', '/') | |
| $env:CMAKE_GENERATOR = 'Ninja' | |
| $env:CMAKE_MAKE_PROGRAM = $ninjaPath | |
| $env:PATH = "$(Join-Path $cudaRoot 'bin')$pathSeparator$env:PATH" | |
| } | |
| if ($IsWindows) { | |
| $nvccCandidates = @( | |
| (Join-Path $cudaRoot 'bin\nvcc.exe'), | |
| (Join-Path $env:CONDA_PREFIX 'Library\bin\nvcc.exe'), | |
| (Join-Path $env:CONDA_PREFIX 'bin\nvcc.exe') | |
| ) | |
| } else { | |
| $nvccCandidates = @( | |
| (Join-Path $env:CONDA_PREFIX 'bin/nvcc'), | |
| (Join-Path $env:CONDA_PREFIX 'targets/x86_64-linux/bin/nvcc') | |
| ) | |
| } | |
| $nvccPath = $nvccCandidates | Where-Object { Test-Path $_ } | Select-Object -First 1 | |
| if (-not $nvccPath) { | |
| throw 'Failed to find nvcc in the conda environment' | |
| } | |
| $env:CUDACXX = $nvccPath | |
| $env:PATH = "$(Split-Path $nvccPath)$pathSeparator$env:PATH" | |
| if ($IsWindows) { | |
| $nvccPathCmake = $nvccPath.Replace('\', '/') | |
| $env:CUDACXX = $nvccPathCmake | |
| $env:CMAKE_ARGS = "-DCMAKE_CUDA_COMPILER=$nvccPathCmake -DCMAKE_CUDA_COMPILER_ARG1=-allow-unsupported-compiler -DCMAKE_MAKE_PROGRAM=$env:CMAKE_MAKE_PROGRAM $env:CMAKE_ARGS" | |
| } | |
| $env:VERBOSE = '1' | |
| $env:CMAKE_ARGS = "-DGGML_CUDA_FORCE_MMQ=ON -DGGML_CUDA=on -DCMAKE_CUDA_ARCHITECTURES=60-real;61-real;70-real;75-real;80-real;86-real;89-real;90-real;90-virtual -DCMAKE_CUDA_FLAGS=-allow-unsupported-compiler -DCMAKE_CUDA_FLAGS_INIT=-allow-unsupported-compiler $env:CMAKE_ARGS" | |
| $env:CMAKE_ARGS = "$env:CMAKE_ARGS -DGGML_AVX2=off -DGGML_FMA=off -DGGML_F16C=off" | |
| & $nvccPath --version | |
| python -m build --wheel | |
| Get-ChildItem dist | Select-Object Name, Length |