From 717c10f73a3b0d658e25feab7f06a9f40449f792 Mon Sep 17 00:00:00 2001 From: Jianlin Shi Date: Wed, 27 Nov 2024 21:23:11 -0700 Subject: [PATCH 01/12] test --- .github/workflows/build-wheels-cuda.yaml | 47 +++++++++++++++++++++--- 1 file changed, 42 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-wheels-cuda.yaml b/.github/workflows/build-wheels-cuda.yaml index 647b171e84..86e23b9f0b 100644 --- a/.github/workflows/build-wheels-cuda.yaml +++ b/.github/workflows/build-wheels-cuda.yaml @@ -1,6 +1,23 @@ name: Build Wheels (CUDA) -on: workflow_dispatch +on: + workflow_dispatch: + inputs: + env_name: + description: "conda environmant name" + type: string + required: false + default: 'win_llamacppgpu' + target_folder: + description: 'Envs path (must be on D drive)' + type: string + required: false + default: 'D:\conda_envs_jianlins' + zip_vol_size: + description: 'Max 7zip volumn size' + type: string + required: false + default: '400m' permissions: contents: write @@ -20,9 +37,9 @@ jobs: id: set-matrix run: | $matrix = @{ - 'os' = @('ubuntu-latest', 'windows-2019') - 'pyver' = @("3.9", "3.10", "3.11", "3.12") - 'cuda' = @("12.1.1", "12.2.2", "12.3.2", "12.4.1", "12.5.0") + 'os' = @('windows-latest') + 'pyver' = @("3.10") + 'cuda' = @("11.8.0") 'releasetag' = @("basic") } @@ -61,7 +78,7 @@ jobs: - name: Setup Mamba uses: conda-incubator/setup-miniconda@v3.0.4 with: - activate-environment: "build" + activate-environment: ${{ github.event.inputs.target_folder }}\${{ github.event.inputs.env_name }} python-version: ${{ matrix.pyver }} miniforge-variant: Mambaforge miniforge-version: latest @@ -136,3 +153,23 @@ jobs: tag_name: ${{ github.ref_name }}-cu${{ env.CUDA_VERSION }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Check for 7-Zip installation + run: | + if (!(Test-Path "C:\Program Files\7-Zip\7z.exe")) { + choco install 7zip + } + + - name: Compress and split folder + run: | + pwd + 7z a -t7z -v${{ github.event.inputs.zip_vol_size }} zipped/${{ github.event.inputs.env_name }}.7z ${{ github.event.inputs.target_folder }}* + ls zipped + + + - name: Upload compressed parts as artifacts + uses: actions/upload-artifact@v4 + with: + name: ${{ github.event.inputs.env_name }} + path: zipped/*.7z.* + retention-days: 4 \ No newline at end of file From 5ae4d8df86f2a720888f8e78a28df627d5c3d448 Mon Sep 17 00:00:00 2001 From: Jianlin Shi Date: Wed, 27 Nov 2024 21:25:03 -0700 Subject: [PATCH 02/12] add new workflow to upload environment 7zip --- .github/workflows/build-cuda-env.yaml | 175 ++++++++++++++++++++++++++ 1 file changed, 175 insertions(+) create mode 100644 .github/workflows/build-cuda-env.yaml diff --git a/.github/workflows/build-cuda-env.yaml b/.github/workflows/build-cuda-env.yaml new file mode 100644 index 0000000000..1719ea72c3 --- /dev/null +++ b/.github/workflows/build-cuda-env.yaml @@ -0,0 +1,175 @@ +name: Build Conda Env (CUDA) + +on: + workflow_dispatch: + inputs: + env_name: + description: "conda environmant name" + type: string + required: false + default: 'win_llamacppgpu' + target_folder: + description: 'Envs path (must be on D drive)' + type: string + required: false + default: 'D:\conda_envs_jianlins' + zip_vol_size: + description: 'Max 7zip volumn size' + type: string + required: false + default: '400m' + +permissions: + contents: write + +jobs: + define_matrix: + name: Define Build Matrix + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + defaults: + run: + shell: pwsh + + steps: + - name: Define Job Output + id: set-matrix + run: | + $matrix = @{ + 'os' = @('windows-latest') + 'pyver' = @("3.10") + 'cuda' = @("11.8.0") + 'releasetag' = @("basic") + } + + $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 }} + + steps: + - name: Add MSBuild to PATH + if: runner.os == 'Windows' + uses: microsoft/setup-msbuild@v2 + with: + vs-version: '[16.11,16.12)' + + - uses: actions/checkout@v4 + with: + submodules: "recursive" + + - uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.pyver }} + cache: 'pip' + + - name: Setup Mamba + uses: conda-incubator/setup-miniconda@v3.0.4 + with: + activate-environment: ${{ github.event.inputs.target_folder }}\${{ github.event.inputs.env_name }} + python-version: ${{ matrix.pyver }} + miniforge-variant: Mambaforge + miniforge-version: latest + use-mamba: true + add-pip-as-python-dependency: true + auto-activate-base: false + + - name: VS Integration Cache + id: vs-integration-cache + if: runner.os == 'Windows' + uses: actions/cache@v4 + with: + path: ./MSBuildExtensions + key: cuda-${{ matrix.cuda }}-vs-integration + + - name: Get Visual Studio Integration + if: runner.os == 'Windows' && steps.vs-integration-cache.outputs.cache-hit != 'true' + run: | + if ($env:CUDAVER -eq '12.1.1') {$x = '12.1.0'} else {$x = $env:CUDAVER} + $links = (Invoke-RestMethod 'https://raw.githubusercontent.com/Jimver/cuda-toolkit/master/src/links/windows-links.ts').Trim().split().where({$_ -ne ''}) + for ($i=$q=0;$i -lt $links.count -and $q -lt 2;$i++) {if ($links[$i] -eq "'$x',") {$q++}} + Invoke-RestMethod $links[$i].Trim("'") -OutFile 'cudainstaller.zip' + & 'C:\Program Files\7-Zip\7z.exe' e cudainstaller.zip -oMSBuildExtensions -r *\MSBuildExtensions\* > $null + Remove-Item 'cudainstaller.zip' + + - name: Install Visual Studio Integration + if: runner.os == 'Windows' + run: | + $y = (gi '.\MSBuildExtensions').fullname + '\*' + (gi 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\*\BuildCustomizations').fullname.foreach({cp $y $_}) + $cupath = 'CUDA_PATH_V' + $env:CUDAVER.Remove($env:CUDAVER.LastIndexOf('.')).Replace('.','_') + echo "$cupath=$env:CONDA_PREFIX" >> $env:GITHUB_ENV + + - name: Install Dependencies + env: + MAMBA_DOWNLOAD_FAILFAST: "0" + MAMBA_NO_LOW_SPEED_LIMIT: "1" + run: | + $cudaVersion = $env:CUDAVER + mamba install -y 'cuda' -c nvidia/label/cuda-$cudaVersion + python -m pip install build wheel + + - name: Build Wheel + run: | + $cudaVersion = $env:CUDAVER.Remove($env:CUDAVER.LastIndexOf('.')).Replace('.','') + $env:CUDA_PATH = $env:CONDA_PREFIX + $env:CUDA_HOME = $env:CONDA_PREFIX + $env:CUDA_TOOLKIT_ROOT_DIR = $env:CONDA_PREFIX + if ($IsLinux) { + $env:LD_LIBRARY_PATH = $env:CONDA_PREFIX + '/lib:' + $env:LD_LIBRARY_PATH + } + $env:VERBOSE = '1' + $env:CMAKE_ARGS = '-DGGML_CUDA=on -DCMAKE_CUDA_ARCHITECTURES=all' + $env:CMAKE_ARGS = "-DGGML_CUDA_FORCE_MMQ=ON $env:CMAKE_ARGS" + # if ($env:AVXVER -eq 'AVX') { + $env:CMAKE_ARGS = $env:CMAKE_ARGS + ' -DGGML_AVX2=off -DGGML_FMA=off -DGGML_F16C=off' + # } + # if ($env:AVXVER -eq 'AVX512') { + # $env:CMAKE_ARGS = $env:CMAKE_ARGS + ' -DGGML_AVX512=on' + # } + # if ($env:AVXVER -eq 'basic') { + # $env:CMAKE_ARGS = $env:CMAKE_ARGS + ' -DGGML_AVX=off -DGGML_AVX2=off -DGGML_FMA=off -DGGML_F16C=off' + # } + python -m build --wheel + # write the build tag to the output + Write-Output "CUDA_VERSION=$cudaVersion" >> $env:GITHUB_ENV + + - uses: softprops/action-gh-release@v2 + with: + files: dist/* + # Set tag_name to -cu + tag_name: ${{ github.ref_name }}-cu${{ env.CUDA_VERSION }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Check for 7-Zip installation + run: | + if (!(Test-Path "C:\Program Files\7-Zip\7z.exe")) { + choco install 7zip + } + + - name: Compress and split folder + run: | + pwd + 7z a -t7z -v${{ github.event.inputs.zip_vol_size }} zipped/${{ github.event.inputs.env_name }}.7z ${{ github.event.inputs.target_folder }}* + ls zipped + + + - name: Upload compressed parts as artifacts + uses: actions/upload-artifact@v4 + with: + name: ${{ github.event.inputs.env_name }} + path: zipped/*.7z.* + retention-days: 4 \ No newline at end of file From 366c0e1c0a6cc4440423c44a49481c91ac8b979b Mon Sep 17 00:00:00 2001 From: Jianlin Shi Date: Wed, 27 Nov 2024 21:31:14 -0700 Subject: [PATCH 03/12] test --- .github/workflows/build-wheels-cuda.yaml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build-wheels-cuda.yaml b/.github/workflows/build-wheels-cuda.yaml index 86e23b9f0b..b3b31f0ef7 100644 --- a/.github/workflows/build-wheels-cuda.yaml +++ b/.github/workflows/build-wheels-cuda.yaml @@ -37,7 +37,7 @@ jobs: id: set-matrix run: | $matrix = @{ - 'os' = @('windows-latest') + 'os' = @('windows-2019') 'pyver' = @("3.10") 'cuda' = @("11.8.0") 'releasetag' = @("basic") @@ -78,7 +78,7 @@ jobs: - name: Setup Mamba uses: conda-incubator/setup-miniconda@v3.0.4 with: - activate-environment: ${{ github.event.inputs.target_folder }}\${{ github.event.inputs.env_name }} + activate-environment: ${{ github.event.inputs.target_folder }}\${{ github.event.inputs.env_name }} python-version: ${{ matrix.pyver }} miniforge-variant: Mambaforge miniforge-version: latest @@ -89,7 +89,7 @@ jobs: - name: VS Integration Cache id: vs-integration-cache if: runner.os == 'Windows' - uses: actions/cache@v4 + uses: actions/cache@v4.0.2 with: path: ./MSBuildExtensions key: cuda-${{ matrix.cuda }}-vs-integration @@ -111,16 +111,16 @@ jobs: (gi 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\*\BuildCustomizations').fullname.foreach({cp $y $_}) $cupath = 'CUDA_PATH_V' + $env:CUDAVER.Remove($env:CUDAVER.LastIndexOf('.')).Replace('.','_') echo "$cupath=$env:CONDA_PREFIX" >> $env:GITHUB_ENV - + - name: Install Dependencies env: MAMBA_DOWNLOAD_FAILFAST: "0" MAMBA_NO_LOW_SPEED_LIMIT: "1" + run: | $cudaVersion = $env:CUDAVER mamba install -y 'cuda' -c nvidia/label/cuda-$cudaVersion python -m pip install build wheel - - name: Build Wheel run: | $cudaVersion = $env:CUDAVER.Remove($env:CUDAVER.LastIndexOf('.')).Replace('.','') @@ -146,13 +146,13 @@ jobs: # write the build tag to the output Write-Output "CUDA_VERSION=$cudaVersion" >> $env:GITHUB_ENV - - uses: softprops/action-gh-release@v2 - with: - files: dist/* - # Set tag_name to -cu - tag_name: ${{ github.ref_name }}-cu${{ env.CUDA_VERSION }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # - uses: softprops/action-gh-release@v2 + # with: + # files: dist/* + # # Set tag_name to -cu + # tag_name: ${{ github.ref_name }}-cu${{ env.CUDA_VERSION }} + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Check for 7-Zip installation run: | From 136e4ab980a8d0a5b7b55e401792c430ffdb7fff Mon Sep 17 00:00:00 2001 From: Jianlin Shi Date: Wed, 27 Nov 2024 21:32:18 -0700 Subject: [PATCH 04/12] test --- .github/workflows/build-wheels-cuda.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-wheels-cuda.yaml b/.github/workflows/build-wheels-cuda.yaml index b3b31f0ef7..20ec17a72a 100644 --- a/.github/workflows/build-wheels-cuda.yaml +++ b/.github/workflows/build-wheels-cuda.yaml @@ -59,6 +59,7 @@ jobs: CUDAVER: ${{ matrix.cuda }} AVXVER: ${{ matrix.releasetag }} + steps: - name: Add MSBuild to PATH if: runner.os == 'Windows' From 3906f66ecffed55bca2f7aeee705abff24930f36 Mon Sep 17 00:00:00 2001 From: Jianlin Shi Date: Wed, 27 Nov 2024 21:34:59 -0700 Subject: [PATCH 05/12] test --- .github/workflows/build-cuda-env.yaml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build-cuda-env.yaml b/.github/workflows/build-cuda-env.yaml index 1719ea72c3..58ec3718cd 100644 --- a/.github/workflows/build-cuda-env.yaml +++ b/.github/workflows/build-cuda-env.yaml @@ -37,7 +37,7 @@ jobs: id: set-matrix run: | $matrix = @{ - 'os' = @('windows-latest') + 'os' = @('windows-2019') 'pyver' = @("3.10") 'cuda' = @("11.8.0") 'releasetag' = @("basic") @@ -146,13 +146,13 @@ jobs: # write the build tag to the output Write-Output "CUDA_VERSION=$cudaVersion" >> $env:GITHUB_ENV - - uses: softprops/action-gh-release@v2 - with: - files: dist/* - # Set tag_name to -cu - tag_name: ${{ github.ref_name }}-cu${{ env.CUDA_VERSION }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # - uses: softprops/action-gh-release@v2 + # with: + # files: dist/* + # # Set tag_name to -cu + # tag_name: ${{ github.ref_name }}-cu${{ env.CUDA_VERSION }} + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Check for 7-Zip installation run: | From 6589c2149fe998bfea7619262f993fc2d14811c1 Mon Sep 17 00:00:00 2001 From: Jianlin Shi Date: Wed, 27 Nov 2024 21:48:09 -0700 Subject: [PATCH 06/12] release --- .github/workflows/build-cuda-env.yaml | 42 +++++++++++++++++---------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build-cuda-env.yaml b/.github/workflows/build-cuda-env.yaml index 58ec3718cd..5b7b04d2e5 100644 --- a/.github/workflows/build-cuda-env.yaml +++ b/.github/workflows/build-cuda-env.yaml @@ -75,16 +75,26 @@ jobs: python-version: ${{ matrix.pyver }} cache: 'pip' - - name: Setup Mamba - uses: conda-incubator/setup-miniconda@v3.0.4 + - name: Install miniforge + uses: conda-incubator/setup-miniconda@v3 with: - activate-environment: ${{ github.event.inputs.target_folder }}\${{ github.event.inputs.env_name }} - python-version: ${{ matrix.pyver }} - miniforge-variant: Mambaforge - miniforge-version: latest - use-mamba: true + miniforge-version: latest + python-version: ${{ matrix.pyver }} + activate-environment: ${{ github.event.inputs.target_folder }}/${{ github.event.inputs.build_folder }} + environment-file: ${{ github.event.inputs.build_folder }}/environment.yml + auto-activate-base: false add-pip-as-python-dependency: true - auto-activate-base: false + + # - name: Setup Mamba + # uses: conda-incubator/setup-miniconda@v3.0.4 + # with: + # activate-environment: ${{ github.event.inputs.target_folder }}\${{ github.event.inputs.env_name }} + # python-version: ${{ matrix.pyver }} + # miniforge-variant: Mambaforge + # miniforge-version: latest + # use-mamba: true + # add-pip-as-python-dependency: true + # auto-activate-base: false - name: VS Integration Cache id: vs-integration-cache @@ -118,7 +128,7 @@ jobs: MAMBA_NO_LOW_SPEED_LIMIT: "1" run: | $cudaVersion = $env:CUDAVER - mamba install -y 'cuda' -c nvidia/label/cuda-$cudaVersion + conda install -y 'cuda' -c nvidia/label/cuda-$cudaVersion python -m pip install build wheel - name: Build Wheel @@ -146,13 +156,13 @@ jobs: # write the build tag to the output Write-Output "CUDA_VERSION=$cudaVersion" >> $env:GITHUB_ENV - # - uses: softprops/action-gh-release@v2 - # with: - # files: dist/* - # # Set tag_name to -cu - # tag_name: ${{ github.ref_name }}-cu${{ env.CUDA_VERSION }} - # env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - uses: softprops/action-gh-release@v2 + with: + files: dist/* + # Set tag_name to -cu + tag_name: ${{ github.ref_name }}-cu${{ env.CUDA_VERSION }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Check for 7-Zip installation run: | From 46509a2fe54b4511b3af979f7f806c924114f442 Mon Sep 17 00:00:00 2001 From: Jianlin Shi Date: Wed, 27 Nov 2024 21:50:50 -0700 Subject: [PATCH 07/12] update release --- .github/workflows/build-wheels-cuda.yaml | 66 +++++------------------- 1 file changed, 14 insertions(+), 52 deletions(-) diff --git a/.github/workflows/build-wheels-cuda.yaml b/.github/workflows/build-wheels-cuda.yaml index 20ec17a72a..9ed69c8eeb 100644 --- a/.github/workflows/build-wheels-cuda.yaml +++ b/.github/workflows/build-wheels-cuda.yaml @@ -1,23 +1,6 @@ name: Build Wheels (CUDA) -on: - workflow_dispatch: - inputs: - env_name: - description: "conda environmant name" - type: string - required: false - default: 'win_llamacppgpu' - target_folder: - description: 'Envs path (must be on D drive)' - type: string - required: false - default: 'D:\conda_envs_jianlins' - zip_vol_size: - description: 'Max 7zip volumn size' - type: string - required: false - default: '400m' +on: workflow_dispatch permissions: contents: write @@ -37,9 +20,9 @@ jobs: id: set-matrix run: | $matrix = @{ - 'os' = @('windows-2019') - 'pyver' = @("3.10") - 'cuda' = @("11.8.0") + 'os' = @('ubuntu-latest', 'windows-2019') + 'pyver' = @("3.10", "3.12") + 'cuda' = @("11.8.0", "12.2.2", "12.3.2", "12.4.1", "12.5.0") 'releasetag' = @("basic") } @@ -59,7 +42,6 @@ jobs: CUDAVER: ${{ matrix.cuda }} AVXVER: ${{ matrix.releasetag }} - steps: - name: Add MSBuild to PATH if: runner.os == 'Windows' @@ -79,7 +61,7 @@ jobs: - name: Setup Mamba uses: conda-incubator/setup-miniconda@v3.0.4 with: - activate-environment: ${{ github.event.inputs.target_folder }}\${{ github.event.inputs.env_name }} + activate-environment: "build" python-version: ${{ matrix.pyver }} miniforge-variant: Mambaforge miniforge-version: latest @@ -90,7 +72,7 @@ jobs: - name: VS Integration Cache id: vs-integration-cache if: runner.os == 'Windows' - uses: actions/cache@v4.0.2 + uses: actions/cache@v4 with: path: ./MSBuildExtensions key: cuda-${{ matrix.cuda }}-vs-integration @@ -112,16 +94,16 @@ jobs: (gi 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\*\BuildCustomizations').fullname.foreach({cp $y $_}) $cupath = 'CUDA_PATH_V' + $env:CUDAVER.Remove($env:CUDAVER.LastIndexOf('.')).Replace('.','_') echo "$cupath=$env:CONDA_PREFIX" >> $env:GITHUB_ENV - + - name: Install Dependencies env: MAMBA_DOWNLOAD_FAILFAST: "0" MAMBA_NO_LOW_SPEED_LIMIT: "1" - run: | $cudaVersion = $env:CUDAVER mamba install -y 'cuda' -c nvidia/label/cuda-$cudaVersion python -m pip install build wheel + - name: Build Wheel run: | $cudaVersion = $env:CUDAVER.Remove($env:CUDAVER.LastIndexOf('.')).Replace('.','') @@ -147,30 +129,10 @@ jobs: # write the build tag to the output Write-Output "CUDA_VERSION=$cudaVersion" >> $env:GITHUB_ENV - # - uses: softprops/action-gh-release@v2 - # with: - # files: dist/* - # # Set tag_name to -cu - # tag_name: ${{ github.ref_name }}-cu${{ env.CUDA_VERSION }} - # env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Check for 7-Zip installation - run: | - if (!(Test-Path "C:\Program Files\7-Zip\7z.exe")) { - choco install 7zip - } - - - name: Compress and split folder - run: | - pwd - 7z a -t7z -v${{ github.event.inputs.zip_vol_size }} zipped/${{ github.event.inputs.env_name }}.7z ${{ github.event.inputs.target_folder }}* - ls zipped - - - - name: Upload compressed parts as artifacts - uses: actions/upload-artifact@v4 + - uses: softprops/action-gh-release@v2 with: - name: ${{ github.event.inputs.env_name }} - path: zipped/*.7z.* - retention-days: 4 \ No newline at end of file + files: dist/* + # Set tag_name to -cu + tag_name: ${{ github.ref_name }}-cu${{ env.CUDA_VERSION }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From a3a61c144620442cac138c899c5bc38acf789c25 Mon Sep 17 00:00:00 2001 From: Jianlin Shi Date: Wed, 27 Nov 2024 23:41:03 -0700 Subject: [PATCH 08/12] test --- .github/workflows/build-wheels-cuda.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-wheels-cuda.yaml b/.github/workflows/build-wheels-cuda.yaml index 9ed69c8eeb..7bf58d095a 100644 --- a/.github/workflows/build-wheels-cuda.yaml +++ b/.github/workflows/build-wheels-cuda.yaml @@ -20,9 +20,9 @@ jobs: id: set-matrix run: | $matrix = @{ - 'os' = @('ubuntu-latest', 'windows-2019') + 'os' = @('windows-2019') 'pyver' = @("3.10", "3.12") - 'cuda' = @("11.8.0", "12.2.2", "12.3.2", "12.4.1", "12.5.0") + 'cuda' = @("11.8.0", "12.5.0") 'releasetag' = @("basic") } From f3690037a487dcf0bfca54b3f54886f3f9e14ca2 Mon Sep 17 00:00:00 2001 From: Jianlin Shi Date: Thu, 28 Nov 2024 01:32:19 -0700 Subject: [PATCH 09/12] try release --- .github/workflows/build-and-release.yaml | 237 ++++++++++++----------- 1 file changed, 127 insertions(+), 110 deletions(-) diff --git a/.github/workflows/build-and-release.yaml b/.github/workflows/build-and-release.yaml index bfa97decdd..6e705f1368 100644 --- a/.github/workflows/build-and-release.yaml +++ b/.github/workflows/build-and-release.yaml @@ -1,144 +1,161 @@ -name: Build Release - -on: workflow_dispatch +name: Build Conda Env (CUDA) + +on: + workflow_dispatch: + inputs: + env_name: + description: "conda environmant name" + type: string + required: false + default: 'win_llamacppgpu' + target_folder: + description: 'Envs path (must be on D drive)' + type: string + required: false + default: 'D:\conda_envs_jianlins' permissions: contents: write jobs: - build_wheels: - name: Build wheels on ${{ matrix.os }} - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-20.04, windows-2019, macos-12] + define_matrix: + name: Define Build Matrix + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + defaults: + run: + shell: pwsh steps: - - uses: actions/checkout@v4 - with: - submodules: "recursive" - - # Used to host cibuildwheel - - uses: actions/setup-python@v5 - with: - python-version: "3.9" - - - name: Install dependencies (Linux/MacOS) - if: runner.os != 'Windows' + - name: Define Job Output + id: set-matrix run: | - python -m pip install --upgrade pip - python -m pip install uv - RUST_LOG=trace python -m uv pip install -e .[all] --verbose - shell: bash + $matrix = @{ + 'os' = @('windows-2019') + 'pyver' = @("3.10", "3.12") + 'cuda' = @("11.8.0", "12.5.0") + 'releasetag' = @("cuda") + } - - name: Install dependencies (Windows) - if: runner.os == 'Windows' - env: - RUST_LOG: trace - run: | - python -m pip install --upgrade pip - python -m pip install uv - python -m uv pip install -e .[all] --verbose - shell: cmd + $matrixOut = ConvertTo-Json $matrix -Compress + Write-Output ('matrix=' + $matrixOut) >> $env:GITHUB_OUTPUT - - name: Build wheels - uses: pypa/cibuildwheel@v2.21.1 - env: - # disable repair - CIBW_REPAIR_WHEEL_COMMAND: "" - with: - package-dir: . - output-dir: wheelhouse + 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 }} - - uses: actions/upload-artifact@v4 + steps: + - name: Add MSBuild to PATH + if: runner.os == 'Windows' + uses: microsoft/setup-msbuild@v2 with: - name: wheels-${{ matrix.os }} - path: ./wheelhouse/*.whl + vs-version: '[16.11,16.12)' - build_wheels_arm64: - name: Build arm64 wheels - runs-on: ubuntu-latest - steps: - uses: actions/checkout@v4 with: submodules: "recursive" - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - with: - platforms: linux/arm64 - - - name: Build wheels - uses: pypa/cibuildwheel@v2.21.1 - env: - CIBW_SKIP: "*musllinux* pp*" - CIBW_REPAIR_WHEEL_COMMAND: "" - CIBW_ARCHS: "aarch64" - CIBW_BUILD: "cp38-* cp39-* cp310-* cp311-* cp312-*" - with: - output-dir: wheelhouse - - - name: Upload wheels as artifacts - uses: actions/upload-artifact@v4 + - uses: actions/setup-python@v5 with: - name: wheels_arm64 - path: ./wheelhouse/*.whl + python-version: ${{ matrix.pyver }} + cache: 'pip' - build_sdist: - name: Build source distribution - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 + - name: Install miniforge + uses: conda-incubator/setup-miniconda@v3 with: - submodules: "recursive" - - - uses: actions/setup-python@v5 + miniforge-version: latest + python-version: ${{ matrix.pyver }} + activate-environment: ${{ github.event.inputs.target_folder }}/${{ github.event.inputs.build_folder }} + environment-file: ${{ github.event.inputs.build_folder }}/environment.yml + auto-activate-base: false + add-pip-as-python-dependency: true + + # - name: Setup Mamba + # uses: conda-incubator/setup-miniconda@v3.0.4 + # with: + # activate-environment: ${{ github.event.inputs.target_folder }}\${{ github.event.inputs.env_name }} + # python-version: ${{ matrix.pyver }} + # miniforge-variant: Mambaforge + # miniforge-version: latest + # use-mamba: true + # add-pip-as-python-dependency: true + # auto-activate-base: false + + - name: VS Integration Cache + id: vs-integration-cache + if: runner.os == 'Windows' + uses: actions/cache@v4 with: - python-version: "3.9" + path: ./MSBuildExtensions + key: cuda-${{ matrix.cuda }}-vs-integration - - name: Install dependencies (Linux/MacOS) - if: runner.os != 'Windows' + - name: Get Visual Studio Integration + if: runner.os == 'Windows' && steps.vs-integration-cache.outputs.cache-hit != 'true' run: | - python -m pip install --upgrade pip - python -m pip install uv - RUST_LOG=trace python -m uv pip install -e .[all] --verbose - python -m uv pip install build - shell: bash - - - name: Install dependencies (Windows) + if ($env:CUDAVER -eq '12.1.1') {$x = '12.1.0'} else {$x = $env:CUDAVER} + $links = (Invoke-RestMethod 'https://raw.githubusercontent.com/Jimver/cuda-toolkit/master/src/links/windows-links.ts').Trim().split().where({$_ -ne ''}) + for ($i=$q=0;$i -lt $links.count -and $q -lt 2;$i++) {if ($links[$i] -eq "'$x',") {$q++}} + Invoke-RestMethod $links[$i].Trim("'") -OutFile 'cudainstaller.zip' + & 'C:\Program Files\7-Zip\7z.exe' e cudainstaller.zip -oMSBuildExtensions -r *\MSBuildExtensions\* > $null + Remove-Item 'cudainstaller.zip' + + - name: Install Visual Studio Integration if: runner.os == 'Windows' - env: - RUST_LOG: trace run: | - python -m pip install --upgrade pip - python -m pip install uv - python -m uv pip install -e .[all] --verbose - python -m uv pip install build - shell: cmd + $y = (gi '.\MSBuildExtensions').fullname + '\*' + (gi 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\*\BuildCustomizations').fullname.foreach({cp $y $_}) + $cupath = 'CUDA_PATH_V' + $env:CUDAVER.Remove($env:CUDAVER.LastIndexOf('.')).Replace('.','_') + echo "$cupath=$env:CONDA_PREFIX" >> $env:GITHUB_ENV - - name: Build source distribution + - name: Install Dependencies + env: + MAMBA_DOWNLOAD_FAILFAST: "0" + MAMBA_NO_LOW_SPEED_LIMIT: "1" run: | - python -m build --sdist - - - uses: actions/upload-artifact@v4 - with: - name: sdist - path: ./dist/*.tar.gz - - release: - name: Release - needs: [build_wheels, build_wheels_arm64, build_sdist] - runs-on: ubuntu-latest + $cudaVersion = $env:CUDAVER + conda install -y 'cuda' -c nvidia/label/cuda-$cudaVersion + python -m pip install build wheel - steps: - - uses: actions/download-artifact@v4 - with: - merge-multiple: true - path: dist + - name: Build Wheel + run: | + $cudaVersion = $env:CUDAVER.Remove($env:CUDAVER.LastIndexOf('.')).Replace('.','') + $env:CUDA_PATH = $env:CONDA_PREFIX + $env:CUDA_HOME = $env:CONDA_PREFIX + $env:CUDA_TOOLKIT_ROOT_DIR = $env:CONDA_PREFIX + if ($IsLinux) { + $env:LD_LIBRARY_PATH = $env:CONDA_PREFIX + '/lib:' + $env:LD_LIBRARY_PATH + } + $env:VERBOSE = '1' + $env:CMAKE_ARGS = '-DGGML_CUDA=on -DCMAKE_CUDA_ARCHITECTURES=all' + $env:CMAKE_ARGS = "-DGGML_CUDA_FORCE_MMQ=ON $env:CMAKE_ARGS" + # if ($env:AVXVER -eq 'AVX') { + $env:CMAKE_ARGS = $env:CMAKE_ARGS + ' -DGGML_AVX2=off -DGGML_FMA=off -DGGML_F16C=off' + # } + # if ($env:AVXVER -eq 'AVX512') { + # $env:CMAKE_ARGS = $env:CMAKE_ARGS + ' -DGGML_AVX512=on' + # } + # if ($env:AVXVER -eq 'basic') { + # $env:CMAKE_ARGS = $env:CMAKE_ARGS + ' -DGGML_AVX=off -DGGML_AVX2=off -DGGML_FMA=off -DGGML_F16C=off' + # } + python -m build --wheel + # write the build tag to the output + Write-Output "CUDA_VERSION=$cudaVersion" >> $env:GITHUB_ENV - uses: softprops/action-gh-release@v2 with: files: dist/* + # Set tag_name to -cu + tag_name: ${{ github.ref_name }}-cu${{ env.CUDA_VERSION }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + From 871f715c1bd253d1636eac122a5ae389fdf97e56 Mon Sep 17 00:00:00 2001 From: Jianlin Shi Date: Thu, 28 Nov 2024 01:32:41 -0700 Subject: [PATCH 10/12] test --- .github/workflows/build-and-release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-release.yaml b/.github/workflows/build-and-release.yaml index 6e705f1368..b5c6e643dd 100644 --- a/.github/workflows/build-and-release.yaml +++ b/.github/workflows/build-and-release.yaml @@ -1,4 +1,4 @@ -name: Build Conda Env (CUDA) +name: Build Release (CUDA) on: workflow_dispatch: From 4154f5b04a4d5c1fe5112587310fa15f8c634514 Mon Sep 17 00:00:00 2001 From: Jianlin Shi Date: Thu, 28 Nov 2024 01:48:56 -0700 Subject: [PATCH 11/12] test --- .github/workflows/build-and-release.yaml | 1 - .github/workflows/build-cuda-env.yaml | 1 - 2 files changed, 2 deletions(-) diff --git a/.github/workflows/build-and-release.yaml b/.github/workflows/build-and-release.yaml index b5c6e643dd..c21a66a320 100644 --- a/.github/workflows/build-and-release.yaml +++ b/.github/workflows/build-and-release.yaml @@ -76,7 +76,6 @@ jobs: miniforge-version: latest python-version: ${{ matrix.pyver }} activate-environment: ${{ github.event.inputs.target_folder }}/${{ github.event.inputs.build_folder }} - environment-file: ${{ github.event.inputs.build_folder }}/environment.yml auto-activate-base: false add-pip-as-python-dependency: true diff --git a/.github/workflows/build-cuda-env.yaml b/.github/workflows/build-cuda-env.yaml index 5b7b04d2e5..d07161f1a2 100644 --- a/.github/workflows/build-cuda-env.yaml +++ b/.github/workflows/build-cuda-env.yaml @@ -81,7 +81,6 @@ jobs: miniforge-version: latest python-version: ${{ matrix.pyver }} activate-environment: ${{ github.event.inputs.target_folder }}/${{ github.event.inputs.build_folder }} - environment-file: ${{ github.event.inputs.build_folder }}/environment.yml auto-activate-base: false add-pip-as-python-dependency: true From 04f251c315c39329d17520c973571c252880da12 Mon Sep 17 00:00:00 2001 From: Jianlin Shi Date: Thu, 28 Nov 2024 02:14:09 -0700 Subject: [PATCH 12/12] 12.5.0 failed --- .github/workflows/build-and-release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-release.yaml b/.github/workflows/build-and-release.yaml index c21a66a320..fd519a7ba5 100644 --- a/.github/workflows/build-and-release.yaml +++ b/.github/workflows/build-and-release.yaml @@ -34,7 +34,7 @@ jobs: $matrix = @{ 'os' = @('windows-2019') 'pyver' = @("3.10", "3.12") - 'cuda' = @("11.8.0", "12.5.0") + 'cuda' = @("11.8.0") 'releasetag' = @("cuda") }