Skip to content

Commit 786d15c

Browse files
committed
Upload build-wheels-cuda-linux.yml
1 parent b0ea709 commit 786d15c

File tree

1 file changed

+123
-0
lines changed

1 file changed

+123
-0
lines changed
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
name: Build Wheels for Linux # Workflow name
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:12.4.1-cudnn-devel-ubuntu22.04
14+
container: nvidia/cuda:12.6.3-cudnn-devel-ubuntu22.04
15+
strategy:
16+
matrix: # Define the build matrix directly here
17+
os: ["ubuntu-22.04"]
18+
pyver: ["3.10", "3.11", "3.12"] # Python versions
19+
# cuda: ["12.4.1"]
20+
cuda: ["12.6.3"]
21+
releasetag: ["AVX2"] # Controls CMAKE_ARGS for CPU features (even in CUDA build)
22+
cudaarch: ["all"] # Controls target CUDA architectures for nvcc
23+
24+
defaults:
25+
run:
26+
shell: bash
27+
28+
env:
29+
CUDAVER: ${{ matrix.cuda }}
30+
AVXVER: ${{ matrix.releasetag }}
31+
CUDAARCHVER: ${{ matrix.cudaarch }}
32+
33+
steps:
34+
- name: Install dependencies
35+
run: |
36+
apt update
37+
apt install -y build-essential cmake curl git libgomp1 libcurl4-openssl-dev
38+
39+
- uses: actions/checkout@v4 # Checkout code
40+
with:
41+
submodules: "recursive"
42+
43+
# from astral-sh/setup-uv
44+
- name: Install the latest version of uv and set the python version
45+
uses: astral-sh/setup-uv@v6
46+
with:
47+
python-version: ${{ matrix.pyver }}
48+
activate-environment: true
49+
enable-cache: true
50+
51+
- run: nvcc -V
52+
53+
- name: Build Wheel With Cmake # Main build step: configures and builds the wheel
54+
run: |
55+
echo "VERBOSE=1" >> $GITHUB_ENV # Enable verbose build output for troubleshooting
56+
57+
echo "CUDA_HOME=/usr/local/cuda/" >> $GITHUB_ENV
58+
echo "CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda/" >> $GITHUB_ENV
59+
echo "CUDA_PATH = ${PATH}" >> $GITHUB_ENV
60+
echo "LD_LIBRARY_PATH = '${PATH}:${LD_LIBRARY_PATH}'"
61+
62+
# Add project-specific and feature flags
63+
CMAKE_ARGS="-DGGML_CUDA=on -DCMAKE_CUDA_ARCHITECTURES='80-real;86-real;89-real'"
64+
CMAKE_ARGS="-DGGML_CUDA_FORCE_MMQ=ON ${CMAKE_ARGS}"
65+
CMAKE_ARGS="${CMAKE_ARGS} -DLLAMA_CURL=ON -DLLAVA_BUILD=OFF"
66+
67+
if [ "${AVXVER}" = "AVX" ]; then
68+
CMAKE_ARGS="${CMAKE_ARGS} -DGGML_AVX2=off -DGGML_FMA=off -DGGML_F16C=off"
69+
fi
70+
if [ "${AVXVER}" = "AVX2" ]; then
71+
CMAKE_ARGS="${CMAKE_ARGS} -DGGML_AVX2=on -DGGML_FMA=off -DGGML_F16C=off"
72+
fi
73+
# if [ "${AVXVER}" = "AVX512" ]; then
74+
# CMAKE_ARGS="${CMAKE_ARGS} -DGGML_AVX512=on"
75+
# fi
76+
# if [ "${AVXVER}" = "basic" ]; then
77+
# CMAKE_ARGS = "${CMAKE_ARGS} -DGGML_AVX=off -DGGML_AVX2=off -DGGML_FMA=off -DGGML_F16C=off"
78+
# fi
79+
80+
# Export CMAKE_ARGS environment variable so the python -m build command can use it
81+
echo ${CMAKE_ARGS}
82+
echo "CMAKE_ARGS=${CMAKE_ARGS}" >> $GITHUB_ENV
83+
84+
# Run the Python build command to generate the wheel
85+
uv pip install build setuptools wheel packaging
86+
uv pip install -U torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu126
87+
CMAKE_ARGS=${CMAKE_ARGS} uv build --wheel
88+
89+
# --- Post-build steps to get info for release tag ---
90+
91+
# Find the generated wheel file in the 'dist' directory using bash
92+
# Assumes only one wheel is generated per build configuration run
93+
wheel_file=$(ls dist/*.whl | head -n 1)
94+
95+
# Extract the package version (e.g., 1.2.3) from the wheel filename
96+
# Filename format is typically: package_name-version-tag-specificators.whl
97+
# Using basename and cut to split by '-' and get the second field
98+
tag_ver=$(basename "$wheel_file" | cut -d'-' -f 2)
99+
echo "TAG_VERSION=$tag_ver" >> $GITHUB_ENV # Store version in env for release step
100+
101+
# Extract the short CUDA version (e.g., 126) from the full version (e.g., 12.6.3) from the matrix variable
102+
cuda_ver_short=$(echo "${CUDAVER}" | cut -d'.' -f 1,2 | sed 's/\.//g')
103+
echo "CUDA_VERSION=$cuda_ver_short" >> $GITHUB_ENV # Store short CUDA version in env
104+
105+
106+
- name: Get Current Date # Step to get current date for the release tag
107+
id: get-date
108+
run: |
109+
# Get date in YYYYMMDD format using bash date command
110+
currentDate=$(date +%Y%m%d)
111+
# Store the date in environment variable for the release step
112+
echo "BUILD_DATE=$currentDate" >> $GITHUB_ENV
113+
114+
- uses: softprops/action-gh-release@v2 # Action to create a GitHub Release
115+
with:
116+
files: dist/* # Upload the generated wheel files from the dist directory
117+
# Define the release tag name using the collected environment variables
118+
# Format: v<package_version>-cu<short_cuda_version>-<avx_tag>-linux-<build_date>
119+
tag_name: v${{ env.TAG_VERSION }}-cu${{ env.CUDA_VERSION }}-${{ env.AVXVER }}-linux-${{ env.BUILD_DATE }} # Release tag format for Linux
120+
# Note: This action will create a new release tag if it doesn't exist,
121+
# or upload assets to an existing tag. Be mindful of potential tag name conflicts.
122+
env:
123+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Use the secret provided by GitHub Actions for authentication

0 commit comments

Comments
 (0)