Skip to content

Commit 2b97b7e

Browse files
committed
workflow: Added workflows for compiling with CUDA 13.0.2 on Windows and Linux.
1 parent 61e2346 commit 2b97b7e

File tree

4 files changed

+470
-0
lines changed

4 files changed

+470
-0
lines changed
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
name: Build Wheels(CU130) for Linux(Basic)
2+
3+
on:
4+
workflow_dispatch: # Manual trigger
5+
6+
permissions:
7+
contents: write
8+
9+
jobs:
10+
build_wheels:
11+
name: Build Wheel ${{ matrix.os }} ${{ matrix.pyver }} ${{ matrix.cuda }} ${{ matrix.releasetag == 'wheels' && 'AVX2' || matrix.releasetag }}
12+
runs-on: ubuntu-22.04
13+
container: nvidia/cuda:13.0.2-cudnn-devel-ubuntu22.04
14+
strategy:
15+
matrix: # Define the build matrix directly here
16+
os: ["ubuntu-22.04"]
17+
pyver: ["3.10", "3.11", "3.12", "3.13"] # Python versions
18+
cuda: ["13.0.2"]
19+
releasetag: ["Basic"] # Controls CMAKE_ARGS for CPU features (even in CUDA build)
20+
cudaarch: ["all"] # Controls target CUDA architectures for nvcc
21+
22+
defaults:
23+
run:
24+
shell: bash
25+
26+
env:
27+
CUDAVER: ${{ matrix.cuda }}
28+
AVXVER: ${{ matrix.releasetag }}
29+
CUDAARCHVER: ${{ matrix.cudaarch }}
30+
31+
steps:
32+
- name: Install dependencies
33+
run: |
34+
apt update
35+
apt install -y build-essential ccache cmake curl git libgomp1 libjpeg-dev libssl-dev
36+
37+
- uses: actions/checkout@v5 # Checkout code
38+
with:
39+
submodules: "recursive"
40+
41+
# from astral-sh/setup-uv
42+
- name: Install the latest version of uv and set the python version
43+
uses: astral-sh/setup-uv@v6
44+
with:
45+
python-version: ${{ matrix.pyver }}
46+
activate-environment: true
47+
enable-cache: true
48+
49+
- run: nvcc -V
50+
51+
- name: Build Wheel With Cmake # Main build step: configures and builds the wheel
52+
env:
53+
LD_LIBRARY_PATH: "/usr/local/cuda/lib64:/usr/local/cuda/compat:/usr/lib/x86_64-linux-gnu:${LD_LIBRARY_PATH}"
54+
VERBOSE: 1 # Enable verbose build output
55+
CUDA_HOME: "/usr/local/cuda/" # Set CUDA_HOME
56+
CUDA_PATH: "${PATH}"
57+
CUDA_TOOLKIT_ROOT_DIR: "/usr/local/cuda/" # Set CUDA_TOOLKIT_ROOT_DIR
58+
run: |
59+
echo "VERBOSE=1" >> $GITHUB_ENV # Enable verbose build output for troubleshooting
60+
find /usr/ -name 'libcuda.so.*'
61+
echo $LD_LIBRARY_PATH
62+
63+
# Add project-specific and feature flags
64+
CMAKE_ARGS="-DGGML_CUDA=on -DCMAKE_CUDA_ARCHITECTURES='75-real;80-real;86-real;87-real;89-real;90-real;100-real;101-real;120-real'"
65+
CMAKE_ARGS="-DGGML_CUDA_FORCE_MMQ=on ${CMAKE_ARGS}"
66+
CMAKE_ARGS="${CMAKE_ARGS} -DLLAMA_CURL=off -DLLAMA_OPENSSL=on -DLLAMA_HTTPLIB=on"
67+
68+
# Basic options for compiling without AVX instructions
69+
if [ "${AVXVER}" = "Basic" ]; then
70+
CMAKE_ARGS="${CMAKE_ARGS} -DGGML_AVX=off -DGGML_AVX2=off -DGGML_AVX512=off -DGGML_FMA=off -DGGML_F16C=off"
71+
fi
72+
73+
# Export CMAKE_ARGS environment variable so the python -m build command can use it
74+
echo ${CMAKE_ARGS}
75+
echo "CMAKE_ARGS=${CMAKE_ARGS}" >> $GITHUB_ENV
76+
77+
# Run the Python build command to generate the wheel
78+
uv pip install build setuptools wheel packaging
79+
# uv pip install -U torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu130
80+
CMAKE_ARGS=${CMAKE_ARGS} uv build --wheel
81+
82+
# --- Post-build steps to get info for release tag ---
83+
84+
# Find the generated wheel file in the 'dist' directory using bash
85+
# Assumes only one wheel is generated per build configuration run
86+
wheel_file=$(ls dist/*.whl | head -n 1)
87+
88+
# Extract the package version (e.g., 1.2.3) from the wheel filename
89+
# Filename format is typically: package_name-version-tag-specificators.whl
90+
# Using basename and cut to split by '-' and get the second field
91+
tag_ver=$(basename "$wheel_file" | cut -d'-' -f 2)
92+
echo "TAG_VERSION=$tag_ver" >> $GITHUB_ENV # Store version in env for release step
93+
94+
# Extract the short CUDA version (e.g., 130) from the full version (e.g., 13.0.2) from the matrix variable
95+
cuda_ver_short=$(echo "${CUDAVER}" | cut -d'.' -f 1,2 | sed 's/\.//g')
96+
echo "CUDA_VERSION=$cuda_ver_short" >> $GITHUB_ENV # Store short CUDA version in env
97+
98+
99+
- name: Get Current Date # Step to get current date for the release tag
100+
id: get-date
101+
run: |
102+
# Get date in YYYYMMDD format using bash date command
103+
currentDate=$(date +%Y%m%d)
104+
# Store the date in environment variable for the release step
105+
echo "BUILD_DATE=$currentDate" >> $GITHUB_ENV
106+
107+
- uses: softprops/action-gh-release@v2.2.2 # Action to create a GitHub Release
108+
with:
109+
files: dist/* # Upload the generated wheel files from the dist directory
110+
# Define the release tag name using the collected environment variables
111+
# Format: v<package_version>-cu<short_cuda_version>-<avx_tag>-linux-<build_date>
112+
tag_name: v${{ env.TAG_VERSION }}-cu${{ env.CUDA_VERSION }}-${{ env.AVXVER }}-linux-${{ env.BUILD_DATE }} # Release tag format for Linux
113+
# Note: This action will create a new release tag if it doesn't exist,
114+
# or upload assets to an existing tag. Be mindful of potential tag name conflicts.
115+
env:
116+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Use the secret provided by GitHub Actions for authentication
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
name: Build Wheels(CU130) for Linux
2+
3+
on:
4+
workflow_dispatch: # Manual trigger
5+
6+
permissions:
7+
contents: write
8+
9+
jobs:
10+
build_wheels:
11+
name: Build Wheel ${{ matrix.os }} ${{ matrix.pyver }} ${{ matrix.cuda }} ${{ matrix.releasetag == 'wheels' && 'AVX2' || matrix.releasetag }}
12+
runs-on: ubuntu-22.04
13+
container: nvidia/cuda:13.0.2-cudnn-devel-ubuntu22.04
14+
strategy:
15+
matrix: # Define the build matrix directly here
16+
os: ["ubuntu-22.04"]
17+
pyver: ["3.10", "3.11", "3.12", "3.13"] # Python versions
18+
cuda: ["13.0.2"]
19+
releasetag: ["AVX2"] # Controls CMAKE_ARGS for CPU features (even in CUDA build)
20+
cudaarch: ["all"] # Controls target CUDA architectures for nvcc
21+
22+
defaults:
23+
run:
24+
shell: bash
25+
26+
env:
27+
CUDAVER: ${{ matrix.cuda }}
28+
AVXVER: ${{ matrix.releasetag }}
29+
CUDAARCHVER: ${{ matrix.cudaarch }}
30+
31+
steps:
32+
- name: Install dependencies
33+
run: |
34+
apt update
35+
apt install -y build-essential ccache cmake curl git libgomp1 libjpeg-dev libssl-dev
36+
37+
- uses: actions/checkout@v5 # Checkout code
38+
with:
39+
submodules: "recursive"
40+
41+
# from astral-sh/setup-uv
42+
- name: Install the latest version of uv and set the python version
43+
uses: astral-sh/setup-uv@v6
44+
with:
45+
python-version: ${{ matrix.pyver }}
46+
activate-environment: true
47+
enable-cache: true
48+
49+
- run: nvcc -V
50+
51+
- name: Build Wheel With Cmake # Main build step: configures and builds the wheel
52+
env:
53+
LD_LIBRARY_PATH: "/usr/local/cuda/lib64:/usr/local/cuda/compat:/usr/lib/x86_64-linux-gnu:${LD_LIBRARY_PATH}"
54+
VERBOSE: 1 # Enable verbose build output
55+
CUDA_HOME: "/usr/local/cuda/" # Set CUDA_HOME
56+
CUDA_PATH: "${PATH}"
57+
CUDA_TOOLKIT_ROOT_DIR: "/usr/local/cuda/" # Set CUDA_TOOLKIT_ROOT_DIR
58+
run: |
59+
echo "VERBOSE=1" >> $GITHUB_ENV # Enable verbose build output for troubleshooting
60+
find /usr/ -name 'libcuda.so.*'
61+
echo $LD_LIBRARY_PATH
62+
63+
# Add project-specific and feature flags
64+
CMAKE_ARGS="-DGGML_CUDA=on -DCMAKE_CUDA_ARCHITECTURES='75-real;80-real;86-real;87-real;89-real;90-real;100-real;101-real;120-real'"
65+
CMAKE_ARGS="-DGGML_CUDA_FORCE_MMQ=on ${CMAKE_ARGS}"
66+
CMAKE_ARGS="${CMAKE_ARGS} -DLLAMA_CURL=off -DLLAMA_OPENSSL=on -DLLAMA_HTTPLIB=on"
67+
68+
if [ "${AVXVER}" = "AVX" ]; then
69+
CMAKE_ARGS="${CMAKE_ARGS} -DGGML_AVX=on -DGGML_AVX2=off -DGGML_FMA=off -DGGML_F16C=off"
70+
fi
71+
if [ "${AVXVER}" = "AVX2" ]; then
72+
CMAKE_ARGS="${CMAKE_ARGS} -DGGML_AVX=on -DGGML_AVX2=on -DGGML_AVX512=off -DGGML_FMA=off -DGGML_F16C=off"
73+
fi
74+
if [ "${AVXVER}" = "AVXVNNI" ]; then
75+
CMAKE_ARGS="${CMAKE_ARGS} -DGGML_AVX=on -DGGML_AVX2=on -DGGML_AVX_VNNI=on -DGGML_FMA=on -DGGML_F16C=off"
76+
fi
77+
# if [ "${AVXVER}" = "AVX512" ]; then
78+
# CMAKE_ARGS="${CMAKE_ARGS} -DGGML_AVX512=on"
79+
# fi
80+
# Basic options for compiling without AVX instructions
81+
if [ "${AVXVER}" = "Basic" ]; then
82+
CMAKE_ARGS="${CMAKE_ARGS} -DGGML_AVX=off -DGGML_AVX2=off -DGGML_AVX512=off -DGGML_FMA=off -DGGML_F16C=off"
83+
fi
84+
85+
# Export CMAKE_ARGS environment variable so the python -m build command can use it
86+
echo ${CMAKE_ARGS}
87+
echo "CMAKE_ARGS=${CMAKE_ARGS}" >> $GITHUB_ENV
88+
89+
# Run the Python build command to generate the wheel
90+
uv pip install build setuptools wheel packaging
91+
# uv pip install -U torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu130
92+
CMAKE_ARGS=${CMAKE_ARGS} uv build --wheel
93+
94+
# --- Post-build steps to get info for release tag ---
95+
96+
# Find the generated wheel file in the 'dist' directory using bash
97+
# Assumes only one wheel is generated per build configuration run
98+
wheel_file=$(ls dist/*.whl | head -n 1)
99+
100+
# Extract the package version (e.g., 1.2.3) from the wheel filename
101+
# Filename format is typically: package_name-version-tag-specificators.whl
102+
# Using basename and cut to split by '-' and get the second field
103+
tag_ver=$(basename "$wheel_file" | cut -d'-' -f 2)
104+
echo "TAG_VERSION=$tag_ver" >> $GITHUB_ENV # Store version in env for release step
105+
106+
# Extract the short CUDA version (e.g., 130) from the full version (e.g., 13.0.2) from the matrix variable
107+
cuda_ver_short=$(echo "${CUDAVER}" | cut -d'.' -f 1,2 | sed 's/\.//g')
108+
echo "CUDA_VERSION=$cuda_ver_short" >> $GITHUB_ENV # Store short CUDA version in env
109+
110+
111+
- name: Get Current Date # Step to get current date for the release tag
112+
id: get-date
113+
run: |
114+
# Get date in YYYYMMDD format using bash date command
115+
currentDate=$(date +%Y%m%d)
116+
# Store the date in environment variable for the release step
117+
echo "BUILD_DATE=$currentDate" >> $GITHUB_ENV
118+
119+
- uses: softprops/action-gh-release@v2.2.2 # Action to create a GitHub Release
120+
with:
121+
files: dist/* # Upload the generated wheel files from the dist directory
122+
# Define the release tag name using the collected environment variables
123+
# Format: v<package_version>-cu<short_cuda_version>-<avx_tag>-linux-<build_date>
124+
tag_name: v${{ env.TAG_VERSION }}-cu${{ env.CUDA_VERSION }}-${{ env.AVXVER }}-linux-${{ env.BUILD_DATE }} # Release tag format for Linux
125+
# Note: This action will create a new release tag if it doesn't exist,
126+
# or upload assets to an existing tag. Be mindful of potential tag name conflicts.
127+
env:
128+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Use the secret provided by GitHub Actions for authentication
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
name: Build Wheels (CU130) for Windows(Basic)
2+
3+
on:
4+
workflow_dispatch:
5+
6+
permissions:
7+
contents: write
8+
9+
jobs:
10+
build_wheels:
11+
name: Build Wheel ${{ matrix.os }} ${{ matrix.pyver }} ${{ matrix.cuda }} ${{ matrix.releasetag }}
12+
runs-on: ${{ matrix.os }}
13+
strategy:
14+
matrix:
15+
os: ['windows-2022']
16+
pyver: ["3.10", "3.11", "3.12", "3.13"]
17+
cuda: ["13.0.2"]
18+
releasetag: ["Basic"]
19+
cudaarch: ["75-real;80-real;86-real;87-real;89-real;90-real;100-real;101-real;120-real"]
20+
defaults:
21+
run:
22+
shell: pwsh
23+
env:
24+
CUDAVER: ${{ matrix.cuda }}
25+
AVXVER: ${{ matrix.releasetag }}
26+
CUDAARCHVER: ${{ matrix.cudaarch }}
27+
# https://cmake.org/cmake/help/latest/prop_tgt/CUDA_ARCHITECTURES.html
28+
# https://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/#gpu-feature-list
29+
# e.g. "all" "89" "90" "100" "120"
30+
MAX_JOBS: 8
31+
32+
steps:
33+
- name: Add MSBuild to PATH
34+
if: runner.os == 'Windows'
35+
uses: microsoft/setup-msbuild@v2
36+
with:
37+
msbuild-architecture: x64
38+
39+
- uses: actions/checkout@v5
40+
with:
41+
submodules: "recursive"
42+
43+
# from kingbri1/flash-attention build-wheels.yml
44+
- name: Install CUDA ${{ matrix.cuda }}
45+
uses: N-Storm/cuda-toolkit@v0.2.29
46+
id: cuda-toolkit
47+
with:
48+
cuda: "${{ matrix.cuda }}"
49+
use-github-cache: false
50+
51+
# from astral-sh/setup-uv
52+
- name: Install the latest version of uv and set the python version
53+
uses: astral-sh/setup-uv@v6
54+
with:
55+
python-version: ${{ matrix.pyver }}
56+
activate-environment: true
57+
enable-cache: true
58+
59+
- name: Install Dependencies
60+
run: |
61+
git config --system core.longpaths true
62+
uv pip install --upgrade build setuptools wheel packaging
63+
64+
- name: Build Wheel
65+
run: |
66+
$cudaVersion = $env:CUDAVER.Remove($env:CUDAVER.LastIndexOf('.')).Replace('.','')
67+
$env:CUDA_HOME = $env:CUDA_PATH
68+
$env:CUDA_TOOLKIT_ROOT_DIR = $env:CUDA_PATH
69+
$env:VERBOSE = '1'
70+
$env:CMAKE_ARGS = '-DGGML_CUDA=on -DCMAKE_CUDA_ARCHITECTURES=' + $env:CUDAARCHVER + ' -DCMAKE_BUILD_PARALLEL_LEVEL=' + $env:MAX_JOBS
71+
$env:CMAKE_ARGS = "-DGGML_CUDA_FORCE_MMQ=on -DCUDA_SEPARABLE_COMPILATION=on $env:CMAKE_ARGS"
72+
$env:CMAKE_ARGS = "-DENABLE_CCACHE=on -DLLAMA_CURL=off -DLLAMA_HTTPLIB=on $env:CMAKE_ARGS"
73+
74+
# Basic options for compiling without AVX instructions
75+
if ($env:AVXVER -eq 'Basic') {
76+
$env:CMAKE_ARGS = $env:CMAKE_ARGS + ' -DGGML_AVX=off -DGGML_AVX2=off -DGGML_AVX512=off -DGGML_FMA=off -DGGML_F16C=off'
77+
}
78+
python -m build --wheel
79+
80+
# Check if wheel was built
81+
if (!(Test-Path '.\dist\*.whl')) {
82+
Write-Error "No wheel built in dist/ directory"
83+
exit 1
84+
}
85+
86+
# write the build tag to the output
87+
Write-Output "CUDA_VERSION=$cudaVersion" >> $env:GITHUB_ENV
88+
89+
$wheel = (gi '.\dist\*.whl')[0]
90+
$tagVer = $wheel.name.split('-')[1]
91+
Write-Output "TAG_VERSION=$tagVer" >> $env:GITHUB_ENV
92+
93+
- name: Get Current Date
94+
id: get-date
95+
run: |
96+
$currentDate = Get-Date -UFormat "%Y%m%d"
97+
Write-Output "BUILD_DATE=$currentDate" >> $env:GITHUB_ENV
98+
99+
- name: Create Release
100+
if: always() && env.TAG_VERSION != ''
101+
uses: softprops/action-gh-release@v2
102+
with:
103+
files: dist/*
104+
# Set tag_name to <tag>-cu<cuda_version>-<date>-win
105+
tag_name: v${{ env.TAG_VERSION }}-cu${{ env.CUDA_VERSION }}-${{ env.AVXVER }}-win-${{ env.BUILD_DATE }}
106+
env:
107+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)