ci : add ubuntu cuda build, build with one arch on windows #17007
Workflow file for this run
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: CI | |
| on: | |
| workflow_dispatch: # allows manual triggering | |
| inputs: | |
| create_release: | |
| description: 'Create new release' | |
| required: true | |
| type: boolean | |
| push: | |
| branches: | |
| - master | |
| paths: ['.github/workflows/build.yml', '**/CMakeLists.txt', '**/Makefile', '**/*.h', '**/*.hpp', '**/*.c', '**/*.cpp', '**/*.cu', '**/*.cuh', '**/*.swift', '**/*.m', '**/*.metal'] | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| paths: ['.github/workflows/build.yml', '**/CMakeLists.txt', '**/Makefile', '**/*.h', '**/*.hpp', '**/*.c', '**/*.cpp', '**/*.cu', '**/*.cuh', '**/*.swift', '**/*.m', '**/*.metal'] | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }} | |
| cancel-in-progress: true | |
| # Fine-grant permission | |
| # https://docs.github.com/en/actions/security-for-github-actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token | |
| permissions: | |
| contents: write # for creating release | |
| env: | |
| BRANCH_NAME: ${{ github.head_ref || github.ref_name }} | |
| GGML_NLOOP: 3 | |
| GGML_N_THREADS: 1 | |
| LLAMA_LOG_COLORS: 1 | |
| LLAMA_LOG_PREFIX: 1 | |
| LLAMA_LOG_TIMESTAMPS: 1 | |
| jobs: | |
| cuda-linux-container: | |
| runs-on: ubuntu-latest | |
| container: nvidia/cuda:12.6.2-devel-ubuntu24.04 | |
| steps: | |
| - name: Clone | |
| id: checkout | |
| uses: actions/checkout@v4 | |
| - name: Install dependencies | |
| env: | |
| DEBIAN_FRONTEND: noninteractive | |
| run: | | |
| apt update | |
| apt install -y cmake build-essential ninja-build libgomp1 | |
| - name: Build with CMake | |
| run: | | |
| cmake -S . -B build -G Ninja -DGGML_NATIVE=OFF -DGGML_CUDA=ON -DBUILD_SHARED_LIBS=ON-DCMAKE_CUDA_ARCHITECTURES=89-real .. | |
| cmake --build . --config Release | |
| windows-latest-cmake-cuda: | |
| runs-on: windows-latest | |
| if: false | |
| strategy: | |
| matrix: | |
| cuda: ['12.6.2'] | |
| build: ['cuda'] | |
| steps: | |
| - name: Clone | |
| id: checkout | |
| uses: actions/checkout@v4 | |
| - name: Install CUDA toolkit | |
| id: cuda-toolkit | |
| uses: Jimver/[email protected] | |
| with: | |
| cuda: ${{ matrix.cuda }} | |
| method: 'network' | |
| sub-packages: '["nvcc", "cudart", "cublas", "cublas_dev", "thrust", "visual_studio_integration"]' | |
| - name: Install Ninja | |
| id: install_ninja | |
| run: | | |
| choco install ninja | |
| - name: Build | |
| id: cmake_build | |
| shell: cmd | |
| run: | | |
| call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" | |
| cmake -S . -B build -G "Ninja Multi-Config" -DGGML_NATIVE=OFF -DGGML_CUDA=ON -DBUILD_SHARED_LIBS=ON -DGGML_RPC=ON -DCMAKE_CUDA_ARCHITECTURES=89-real | |
| cmake --build build --config Release -t ggml-cuda | |
| cmake --build build --config Release | |
| - name: Determine tag name | |
| id: tag | |
| shell: bash | |
| run: | | |
| BUILD_NUMBER="$(git rev-list --count HEAD)" | |
| SHORT_HASH="$(git rev-parse --short=7 HEAD)" | |
| if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then | |
| echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT | |
| else | |
| SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-') | |
| echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Pack artifacts | |
| id: pack_artifacts | |
| if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} | |
| run: | | |
| 7z a llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}-cu${{ matrix.cuda }}-x64.zip .\build\bin\Release\* | |
| - name: Upload artifacts | |
| if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| path: llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}-cu${{ matrix.cuda }}-x64.zip | |
| name: llama-bin-win-cu${{ matrix.cuda }}-x64.zip | |
| - name: Copy and pack Cuda runtime | |
| run: | | |
| echo "Cuda install location: ${{steps.cuda-toolkit.outputs.CUDA_PATH}}" | |
| $dst='.\build\bin\cudart\' | |
| robocopy "${{steps.cuda-toolkit.outputs.CUDA_PATH}}\bin" $dst cudart64_*.dll cublas64_*.dll cublasLt64_*.dll | |
| 7z a cudart-llama-bin-win-cu${{ matrix.cuda }}-x64.zip $dst\* | |
| - name: Upload Cuda runtime | |
| if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| path: cudart-llama-bin-win-cu${{ matrix.cuda }}-x64.zip | |
| name: cudart-llama-bin-win-cu${{ matrix.cuda }}-x64.zip |