Skip to content

The open-source AI voice studio. Clone, dictate, create.

refactor: dedupe GPU packaging scripts and matrix the Linux release jobs

Mike Key4799de87a7b7
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 9d87bf2b..a0ceff79 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -345,10 +345,27 @@ jobs:
path: backend/dist/voicebox-server-cuda/
retention-days: 7
- build-cuda-linux:
+ build-gpu-linux:
runs-on: ubuntu-latest
permissions:
contents: write
+ strategy:
+ fail-fast: false
+ matrix:
+ include:
+ - backend: cuda
+ torch_index: https://download.pytorch.org/whl/cu128
+ torch_attr: cuda
+ libs_version: cu128-v1
+ torch_compat: ">=2.7.0,<2.11.0"
+ # Ampere through Blackwell; +PTX keeps forward-compat for newer arches.
+ arch_list: "8.0;8.6;8.9;9.0;12.0+PTX"
+ - backend: rocm
+ torch_index: https://download.pytorch.org/whl/rocm7.2
+ torch_attr: hip
+ libs_version: rocm7.2-v1
+ torch_compat: ">=2.12.0,<2.13.0"
+ arch_list: ""
steps:
- uses: actions/checkout@v4
@@ -365,12 +382,18 @@ jobs:
python-version: "3.12"
cache: "pip"
- - name: Install CUDA PyTorch (Linux) first so requirements see it satisfied
+ - name: Install GPU PyTorch (Linux) first so requirements see it satisfied
+ # The Linux GPU runtime ships inside the torch wheels (for ROCm:
+ # torch/lib/*.so + rocBLAS/hipBLASLt/aotriton kernel data — unlike
+ # Windows, which uses separate rocm_sdk wheels). Installing it before
+ # requirements.txt keeps pip from first pulling the default torch stack
+ # that requirements.txt's unqualified torch would otherwise resolve —
+ # avoiding wasted downloads and disk pressure.
run: |
python -m pip install --upgrade pip
pip install pyinstaller
pip install torch torchaudio \
- --index-url https://download.pytorch.org/whl/cu128
+ --index-url ${{ matrix.torch_index }}
- name: Install remaining Python dependencies
run: |
@@ -378,33 +401,33 @@ jobs:
pip install --no-deps chatterbox-tts
pip install --no-deps hume-tada
- - name: Verify CUDA support in torch
- run: python -c "import torch; assert torch.version.cuda, 'torch is not a CUDA build'; print('CUDA torch', torch.__version__)"
+ - name: Verify GPU support in torch
+ run: python -c "import torch; assert torch.version.${{ matrix.torch_attr }}, 'torch is not a ${{ matrix.backend }} build'; print(torch.__version__)"
- - name: Build CUDA server binary (onedir)
+ - name: Build GPU server binary (onedir)
working-directory: backend
env:
- TORCH_CUDA_ARCH_LIST: "8.0;8.6;8.9;9.0;12.0+PTX"
- run: python build_binary.py --cuda
+ TORCH_CUDA_ARCH_LIST: ${{ matrix.arch_list }}
+ run: python build_binary.py --${{ matrix.backend }}
- - name: Package into server core + CUDA libs archives
+ - name: Package into server core + GPU libs archives
run: |
- python scripts/package_cuda.py \
- backend/dist/voicebox-server-cuda/ \
+ python scripts/package_${{ matrix.backend }}.py \
+ backend/dist/voicebox-server-${{ matrix.backend }}/ \
--output release-assets/ \
--platform linux-x86_64 \
- --cuda-libs-version cu128-v1 \
- --torch-compat ">=2.7.0,<2.11.0"
+ --${{ matrix.backend }}-libs-version ${{ matrix.libs_version }} \
+ --torch-compat "${{ matrix.torch_compat }}"
- name: Upload archives to GitHub Release
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v2
with:
files: |
- release-assets/voicebox-server-cuda-linux-x86_64.tar.gz
- release-assets/voicebox-server-cuda-linux-x86_64.tar.gz.sha256
- release-assets/cuda-libs-linux-x86_64-cu128-v1.tar.gz
- release-assets/cuda-libs-linux-x86_64-cu128-v1.tar.gz.sha256
+ release-assets/voicebox-server-${{ matrix.backend }}-linux-x86_64.tar.gz
+ release-assets/voicebox-server-${{ matrix.backend }}-linux-x86_64.tar.gz.sha256
+ release-assets/${{ matrix.backend }}-libs-linux-x86_64-${{ matrix.libs_version }}.tar.gz
+ release-assets/${{ matrix.backend }}-libs-linux-x86_64-${{ matrix.libs_version }}.tar.gz.sha256
draft: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -470,71 +493,3 @@ jobs:
name: voicebox-server-rocm-windows
path: backend/dist/voicebox-server-rocm/
retention-days: 7
-
- build-rocm-linux:
- runs-on: ubuntu-latest
- permissions:
- contents: write
-
- steps:
- - uses: actions/checkout@v4
-
- - name: Free up disk space
- uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be
- with:
- tool-cache: true
- large-packages: false
-
- - name: Setup Python
- uses: actions/setup-python@v5
- with:
- python-version: "3.12"
- cache: "pip"
-
- - name: Install ROCm PyTorch (Linux) first so requirements see it satisfied
- # Unlike Windows, the Linux ROCm runtime ships inside the torch wheels
- # (torch/lib/*.so + rocBLAS/hipBLASLt/aotriton kernel data), so we pull
- # it from the PyTorch ROCm index instead of the AMD Radeon SDK wheels.
- # Installing it before requirements.txt keeps pip from first pulling the
- # default (CUDA) torch stack that requirements.txt's unqualified torch
- # would otherwise resolve — avoiding wasted downloads and disk pressure.
- run: |
- python -m pip install --upgrade pip
- pip install pyinstaller
- pip install torch torchaudio \
- --index-url https://download.pytorch.org/whl/rocm7.2
-
- - name: Install remaining Python dependencies
- run: |
- pip install -r backend/requirements.txt
- pip install --no-deps chatterbox-tts
- pip install --no-deps hume-tada
-
- - name: Verify ROCm support in torch
- run: python -c "import torch; assert torch.version.hip, 'torch is not a ROCm build'; print('ROCm torch', torch.__version__)"
-
- - name: Build ROCm server binary (onedir)
- working-directory: backend
- run: python build_binary.py --rocm
-
- - name: Package into server core + ROCm libs archives
- run: |
- python scripts/package_rocm.py \
- backend/dist/voicebox-server-rocm/ \
- --output release-assets/ \
- --platform linux-x86_64 \
- --rocm-libs-version rocm7.2-v1 \
- --torch-compat ">=2.12.0,<2.13.0"
-
- - name: Upload archives to GitHub Release
- if: startsWith(github.ref, 'refs/tags/')
- uses: softprops/action-gh-release@v2
- with:
- files: |
- release-assets/voicebox-server-rocm-linux-x86_64.tar.gz
- release-assets/voicebox-server-rocm-linux-x86_64.tar.gz.sha256
- release-assets/rocm-libs-linux-x86_64-rocm7.2-v1.tar.gz
- release-assets/rocm-libs-linux-x86_64-rocm7.2-v1.tar.gz.sha256
- draft: true
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
diff --git a/backend/utils/platform_detect.py b/backend/utils/platform_detect.py
index 7e157fcf..819cf51d 100644
--- a/backend/utils/platform_detect.py
+++ b/backend/utils/platform_detect.py
@@ -72,7 +72,7 @@ def is_amd_gpu_windows() -> bool:
# Platform tokens for which we actually build and publish downloadable GPU
# server assets. Anything else must not be offered a download (it would 404).
-SUPPORTED_GPU_ASSET_PLATFORMS = frozenset({"linux-x86_64", "windows-x86_64"})
+SUPPORTED_GPU_ASSET_PLATFORMS = ("linux-x86_64", "windows-x86_64")
@lru_cache(maxsize=1)
diff --git a/scripts/package_cuda.py b/scripts/package_cuda.py
index 46dd254d..62e97224 100644
--- a/scripts/package_cuda.py
+++ b/scripts/package_cuda.py
@@ -74,16 +74,20 @@ def is_nvidia_file(rel_path: str) -> bool:
if part == "nvidia":
return True
- # NVIDIA shared objects anywhere. Windows: cublas64_12.dll. Linux:
- # libcublas.so / libcublas.so.12 — a leading "lib" and a version suffix the
- # simple ".dll"/".so" split would otherwise miss.
- name = rel_lower.rsplit("/", 1)[-1]
+ # NVIDIA shared objects anywhere (e.g. _internal/torch/lib/cublas64_12.dll).
+ return matches_lib_prefix(rel_lower.rsplit("/", 1)[-1], NVIDIA_DLL_PREFIXES)
+
+
+def matches_lib_prefix(name: str, prefixes: tuple) -> bool:
+ """Whether a shared-library file name matches one of the GPU lib prefixes.
+
+ Handles Windows (cublas64_12.dll) and Linux (libcublas.so, libcublas.so.12)
+ naming — a leading "lib" and a version suffix the simple ".dll"/".so" split
+ would otherwise miss. Shared with package_rocm.py.
+ """
if name.endswith(".dll") or ".so" in name:
stem = name.split(".dll", 1)[0].split(".so", 1)[0].removeprefix("lib")
- for prefix in NVIDIA_DLL_PREFIXES:
- if stem.startswith(prefix):
- return True
-
+ return stem.startswith(prefixes)
return False
@@ -99,15 +103,6 @@ def sha256_file(path: Path) -> str:
return h.hexdigest()
-def platform_tag() -> str:
- """Platform token for release-asset names (mirrors backend server_asset_platform)."""
- import platform
-
- machine = platform.machine().lower()
- arch = "arm64" if machine in ("arm64", "aarch64") else "x86_64"
- return f"{platform.system().lower()}-{arch}"
-
-
def package(
onedir_path: Path,
output_dir: Path,
@@ -235,9 +230,9 @@ def main():
parser.add_argument(
"--platform",
type=str,
- default=None,
- help="Platform token for asset names, e.g. linux-x86_64 "
- "(default: auto-detect from the current host)",
+ required=True,
+ help="Platform token for asset names, e.g. linux-x86_64. Explicit so a "
+ "cross-platform CI runner can never mislabel an asset.",
)
args = parser.parse_args()
@@ -247,8 +242,7 @@ def main():
sys.exit(1)
output_dir = args.output or args.input.parent
- plat = args.platform or platform_tag()
- package(args.input, output_dir, args.cuda_libs_version, args.torch_compat, plat)
+ package(args.input, output_dir, args.cuda_libs_version, args.torch_compat, args.platform)
if __name__ == "__main__":
diff --git a/scripts/package_rocm.py b/scripts/package_rocm.py
index 90286610..ff7a5fcc 100644
--- a/scripts/package_rocm.py
+++ b/scripts/package_rocm.py
@@ -18,12 +18,14 @@ Usage:
"""
import argparse
-import hashlib
import json
import sys
import tarfile
from pathlib import Path
+sys.path.insert(0, str(Path(__file__).resolve().parent))
+from package_cuda import matches_lib_prefix, sha256_file # noqa: E402
+
# DLL/.so name prefixes that identify AMD ROCm/HIP runtime libraries. They may
# sit in torch/lib/ (torch's bundled HIP runtime) or inside the bundled ROCm SDK
# packages. Matched case-insensitively against the file's base name.
@@ -103,37 +105,9 @@ def is_rocm_file(rel_path: str) -> bool:
if any(marker in rel_lower for marker in ROCM_LIB_DIR_MARKERS):
return True
- # ROCm/HIP shared objects anywhere. Windows names them amdhip64.dll; Linux
- # names them libamdhip64.so / libaotriton_v2.so.0.11.2 — a leading "lib" and
- # a version suffix the simple ".dll"/".so" split would otherwise miss.
- if name.endswith(".dll") or ".so" in name:
- stem = name.split(".dll", 1)[0].split(".so", 1)[0].removeprefix("lib")
- for prefix in ROCM_DLL_PREFIXES:
- if stem.startswith(prefix):
- return True
-
- return False
-
-
-def sha256_file(path: Path) -> str:
- """Compute SHA-256 hex digest of a file."""
- h = hashlib.sha256()
- with open(path, "rb") as f:
- while True:
- chunk = f.read(1024 * 1024)
- if not chunk:
- break
- h.update(chunk)
- return h.hexdigest()
-
-
-def platform_tag() -> str:
- """Platform token for release-asset names (mirrors backend server_asset_platform)."""
- import platform
-
- machine = platform.machine().lower()
- arch = "arm64" if machine in ("arm64", "aarch64") else "x86_64"
- return f"{platform.system().lower()}-{arch}"
+ # ROCm/HIP shared objects anywhere (amdhip64.dll, libamdhip64.so,
+ # libaotriton_v2.so.0.11.2 — lib prefix and version suffix handled).
+ return matches_lib_prefix(name, ROCM_DLL_PREFIXES)
def package(
@@ -263,9 +237,9 @@ def main():
parser.add_argument(
"--platform",
type=str,
- default=None,
- help="Platform token for asset names, e.g. linux-x86_64 "
- "(default: auto-detect from the current host)",
+ required=True,
+ help="Platform token for asset names, e.g. linux-x86_64. Explicit so a "
+ "cross-platform CI runner can never mislabel an asset.",
)
args = parser.parse_args()
@@ -275,8 +249,7 @@ def main():
sys.exit(1)
output_dir = args.output or args.input.parent
- plat = args.platform or platform_tag()
- package(args.input, output_dir, args.rocm_libs_version, args.torch_compat, plat)
+ package(args.input, output_dir, args.rocm_libs_version, args.torch_compat, args.platform)
if __name__ == "__main__":