Construction de CTranslate2 avec CUDA pour arm64 : roue, paquets Debian, CI Gitea
This commit is contained in:
commit
402f97df2a
17 files changed
+533
No files matched your search
@@ -0,0 +1,53 @@
|
||||
# Construction sur le runner arm64 de mimir (étiquette suffixée -arm64 :
|
||||
# Gitea aiguille par étiquette, jamais par architecture). Le job tourne
|
||||
# dans l'image CUDA, sans GPU : la compilation n'en a pas besoin, la
|
||||
# validation GPU se fait à la main (tools/smoke-gpu.py).
|
||||
name: build
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
tags: ["v*"]
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-22.04-arm64
|
||||
container:
|
||||
image: nvidia/cuda:13.0.1-cudnn-devel-ubuntu22.04
|
||||
# Le runner borne chaque conteneur à 6 CPU (nproc en voit 20) et 24 Go.
|
||||
timeout-minutes: 120
|
||||
env:
|
||||
DEBIAN_FRONTEND: noninteractive
|
||||
JOBS: "6"
|
||||
steps:
|
||||
- name: outils de base (git pour le checkout)
|
||||
run: apt-get update -q && apt-get install -y -q --no-install-recommends git ca-certificates
|
||||
- uses: actions/checkout@v4
|
||||
- name: dépendances
|
||||
run: ./build.sh deps
|
||||
- name: sources amont
|
||||
run: ./build.sh source
|
||||
- name: paquets Debian
|
||||
run: ./build.sh deb
|
||||
- name: roue Python
|
||||
run: ./build.sh wheel
|
||||
- name: contrôles (sans GPU)
|
||||
run: ./build.sh check
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ctranslate2-cuda-arm64
|
||||
path: |
|
||||
dist/*.whl
|
||||
dist/*.deb
|
||||
retention-days: 30
|
||||
- name: publication dans les registres Gitea (tags v* seulement)
|
||||
if: startsWith(gitea.ref, 'refs/tags/v')
|
||||
env:
|
||||
GITEA_URL: ${{ gitea.server_url }}
|
||||
OWNER: ${{ gitea.repository_owner }}
|
||||
# Jeton personnel à portée write:package, posé dans les secrets du
|
||||
# dépôt ; le jeton automatique du job ne porte pas cette portée.
|
||||
PACKAGES_USER: ${{ secrets.PACKAGES_USER }}
|
||||
PACKAGES_TOKEN: ${{ secrets.PACKAGES_TOKEN }}
|
||||
run: ./tools/publish.sh
|
||||
@@ -0,0 +1,6 @@
|
||||
work/
|
||||
dist/
|
||||
*.whl
|
||||
*.deb
|
||||
*.changes
|
||||
*.buildinfo
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
# Environnement de construction reproductible : le même que la CI.
|
||||
# Usage (sur mimir ou toute machine arm64 avec Docker, GPU inutile) :
|
||||
# docker build -t ct2-cuda-arm64 .
|
||||
# docker run --rm -v "$PWD:/src" -e JOBS=20 ct2-cuda-arm64 all
|
||||
ARG CUDA_IMAGE=nvidia/cuda:13.0.1-cudnn-devel-ubuntu22.04
|
||||
FROM ${CUDA_IMAGE}
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
COPY build.sh versions.env /tmp/bootstrap/
|
||||
RUN /tmp/bootstrap/build.sh deps && rm -rf /var/lib/apt/lists/* /tmp/bootstrap
|
||||
WORKDIR /src
|
||||
ENTRYPOINT ["./build.sh"]
|
||||
CMD ["all"]
|
||||
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2026 Eric Lemesre
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -0,0 +1,90 @@
|
||||
# CTranslate2 avec CUDA pour Linux arm64
|
||||
|
||||
Roue Python et paquets Debian de [CTranslate2](https://github.com/OpenNMT/CTranslate2)
|
||||
compilés **avec le backend CUDA** pour Linux aarch64 : NVIDIA DGX Spark (GB10,
|
||||
sm_121), Grace Hopper (sm_90) et Jetson Orin (sm_87).
|
||||
|
||||
## Pourquoi
|
||||
|
||||
Le projet amont publie sur PyPI des roues `ctranslate2` pour aarch64 **sans CUDA**
|
||||
(sa chaîne de construction n'installe le toolkit que pour x86_64). Sur un DGX Spark,
|
||||
`faster-whisper` et `WhisperX` tournent donc en CPU alors que CUDA 13 est bien là.
|
||||
Ce dépôt reproduit la construction amont en y ajoutant CUDA, et publie le résultat.
|
||||
|
||||
## Installation
|
||||
|
||||
Roue Python (index de paquets Gitea, à côté de PyPI) :
|
||||
|
||||
```bash
|
||||
pip install ctranslate2 --extra-index-url https://git.lemesre.org/api/packages/<owner>/pypi/simple
|
||||
pip install faster-whisper # tire la roue ci-dessus
|
||||
```
|
||||
|
||||
Paquets Debian (bibliothèque C++ et en-têtes, pour un programme C++ ou une liaison
|
||||
FFI comme la crate Rust `ct2rs`) :
|
||||
|
||||
```bash
|
||||
sudo curl -fsSL https://git.lemesre.org/api/packages/<owner>/debian/repository.key -o /etc/apt/keyrings/gitea-<owner>.asc
|
||||
echo "deb [signed-by=/etc/apt/keyrings/gitea-<owner>.asc] https://git.lemesre.org/api/packages/<owner>/debian noble main" | sudo tee /etc/apt/sources.list.d/gitea-<owner>.list
|
||||
sudo apt update && sudo apt install libctranslate2-4 libctranslate2-dev
|
||||
```
|
||||
|
||||
Les bibliothèques CUDA **ne sont pas embarquées** : CTranslate2 les charge à
|
||||
l'exécution (`CUDA_DYNAMIC_LOADING`). Il faut cuBLAS 13 et cuDNN 9 trouvables,
|
||||
soit par le toolkit CUDA de la machine (`/usr/local/cuda`), soit par les paquets
|
||||
pip `nvidia-cublas` et `nvidia-cudnn-cu13` (ceux que `torch` cu130 installe déjà).
|
||||
Pilote NVIDIA 580 ou plus récent. Sans GPU, la même roue tourne en CPU.
|
||||
|
||||
Contrat des artefacts :
|
||||
|
||||
| Artefact | Étiquette | Cible |
|
||||
| --- | --- | --- |
|
||||
| `ctranslate2-4.6.0-cp3*-manylinux_2_35_aarch64.whl` | glibc ≥ 2.35 | Ubuntu 22.04, DGX OS / Ubuntu 24.04, JetPack 6 |
|
||||
| `libctranslate2-4_4.6.0-1~cuda13_arm64.deb`, `libctranslate2-dev_…deb` | jammy, noble | idem |
|
||||
|
||||
## Construction
|
||||
|
||||
Tout passe par `build.sh`, dans l'image CUDA (aucun GPU nécessaire) :
|
||||
|
||||
```bash
|
||||
docker build -t ct2-cuda-arm64 .
|
||||
docker run --rm -v "$PWD:/src" -e JOBS=20 ct2-cuda-arm64 all # ≈ 20 min sur 20 cœurs
|
||||
ls dist/
|
||||
```
|
||||
|
||||
Étapes séparées : `deps`, `source` (clone amont avec sous-modules), `deb`
|
||||
(`dpkg-buildpackage -b`, compile la bibliothèque), `wheel` (roue liée à la
|
||||
bibliothèque du paquet, réparée par `auditwheel`), `check` (symboles CUDA
|
||||
présents, `lintian`). Les versions sont épinglées dans `versions.env`.
|
||||
|
||||
Validation sur une machine avec GPU, après installation de la roue :
|
||||
|
||||
```bash
|
||||
python3 tools/smoke-gpu.py # compte les GPU vus par CTranslate2
|
||||
python3 tools/smoke-gpu.py reunion.wav # faster-whisper large-v3, langue forcée fr
|
||||
```
|
||||
|
||||
## Intégration continue
|
||||
|
||||
`.gitea/workflows/build.yml` tourne sur un runner Gitea Actions arm64
|
||||
(étiquette `ubuntu-22.04-arm64`) dans l'image CUDA, sans GPU. Chaque poussée
|
||||
construit et dépose les artefacts ; un tag `v*` les publie en plus dans les
|
||||
registres PyPI et Debian du propriétaire du dépôt.
|
||||
|
||||
Secrets attendus dans le dépôt : `PACKAGES_USER` et `PACKAGES_TOKEN` (jeton
|
||||
personnel Gitea à portée `write:package`). Le jeton automatique du job n'a pas
|
||||
cette portée.
|
||||
|
||||
Le runner borne un job à 6 CPU et 24 Go, deux heures au plus. `nproc` y
|
||||
annonce pourtant tous les cœurs de l'hôte : `JOBS=6` est fixé dans le workflow.
|
||||
|
||||
## Versions et maintenance
|
||||
|
||||
Une reconstruction par version amont de CTranslate2 et par version majeure de
|
||||
CUDA : modifier `versions.env` et `debian/changelog`, tagger `v<amont>-<révision>`.
|
||||
La liste `CUDA_ARCH_LIST` est explicite parce que la valeur amont `Common`
|
||||
ignore sm_121.
|
||||
|
||||
Ce dépôt ne fait que compiler et empaqueter : aucune modification du code
|
||||
amont. Licence MIT, comme CTranslate2 ; Ruy et cpu_features (sous-modules) sont
|
||||
sous Apache-2.0.
|
||||
@@ -0,0 +1,116 @@
|
||||
#!/usr/bin/env bash
|
||||
# Construction de CTranslate2 avec CUDA pour Linux aarch64 : paquets Debian
|
||||
# (libctranslate2-4, libctranslate2-dev) puis roue Python liée à la même
|
||||
# bibliothèque. Tourne dans l'image CUDA (CI, Dockerfile) ou sur un hôte
|
||||
# qui a nvcc. Étapes : deps | source | deb | wheel | check | all.
|
||||
set -euo pipefail
|
||||
|
||||
ROOT=$(cd "$(dirname "$0")" && pwd)
|
||||
# shellcheck source=versions.env
|
||||
. "$ROOT/versions.env"
|
||||
|
||||
JOBS=${JOBS:-$(nproc)} # en CI, borné à la part de CPU du conteneur
|
||||
WORK=${WORK:-$ROOT/work}
|
||||
DIST=${DIST:-$ROOT/dist}
|
||||
SRC=$WORK/CTranslate2
|
||||
STAGE=$WORK/stage # vue « prefix » de l'installation Debian
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
log() { printf '\n== %s\n' "$*" >&2; }
|
||||
|
||||
etape_deps() {
|
||||
log "dépendances de construction"
|
||||
if [ "$(id -u)" -ne 0 ]; then SUDO=sudo; else SUDO=; fi
|
||||
$SUDO apt-get update -q
|
||||
$SUDO apt-get install -y -q --no-install-recommends \
|
||||
build-essential cmake ninja-build git ca-certificates pkg-config \
|
||||
libopenblas-dev libgomp1 \
|
||||
debhelper devscripts fakeroot lintian \
|
||||
python3-dev python3-venv python3-pip patchelf
|
||||
command -v nvcc >/dev/null || export PATH=/usr/local/cuda/bin:$PATH
|
||||
nvcc --version | tail -1
|
||||
}
|
||||
|
||||
etape_source() {
|
||||
log "sources CTranslate2 v$CT2_VERSION (sous-modules inclus : ruy, cpu_features…)"
|
||||
mkdir -p "$WORK"
|
||||
if [ ! -d "$SRC/.git" ]; then
|
||||
git clone --recursive --depth 1 --branch "v$CT2_VERSION" "$CT2_UPSTREAM" "$SRC"
|
||||
fi
|
||||
git -C "$SRC" describe --tags
|
||||
rm -rf "$SRC/debian"
|
||||
cp -a "$ROOT/debian" "$SRC/debian"
|
||||
}
|
||||
|
||||
etape_deb() {
|
||||
log "paquets Debian (dpkg-buildpackage, $JOBS tâches)"
|
||||
command -v nvcc >/dev/null || export PATH=/usr/local/cuda/bin:$PATH
|
||||
cd "$SRC"
|
||||
export CUDA_ARCH_LIST
|
||||
# -b : binaires seulement (pas de tarball orig) ; -nc : ne pas nettoyer,
|
||||
# une relance reprend la compilation là où elle s'est arrêtée.
|
||||
dpkg-buildpackage -b -us -uc -nc -j"$JOBS"
|
||||
mkdir -p "$DIST"
|
||||
mv -f "$WORK"/*.deb "$DIST"/
|
||||
mv -f "$WORK"/*.buildinfo "$WORK"/*.changes "$DIST"/ 2>/dev/null || true
|
||||
ls -la "$DIST"
|
||||
}
|
||||
|
||||
etape_wheel() {
|
||||
log "roue Python liée à la bibliothèque du paquet"
|
||||
# setup.py cherche include/ et lib/ sous CTRANSLATE2_ROOT ; Debian installe
|
||||
# sous lib/aarch64-linux-gnu, d'où cette vue par liens symboliques.
|
||||
TMP=$SRC/debian/tmp/usr
|
||||
[ -e "$TMP/include/ctranslate2" ] || { echo "installation Debian absente : lancer l'étape deb" >&2; exit 1; }
|
||||
rm -rf "$STAGE" && mkdir -p "$STAGE"
|
||||
ln -s "$TMP/include" "$STAGE/include"
|
||||
ln -s "$TMP/lib/$(dpkg-architecture -qDEB_HOST_MULTIARCH)" "$STAGE/lib"
|
||||
|
||||
python3 -m venv "$WORK/venv"
|
||||
# shellcheck disable=SC1091
|
||||
. "$WORK/venv/bin/activate"
|
||||
pip install -q -U pip setuptools wheel pybind11 auditwheel
|
||||
rm -rf "$WORK/wheel-raw"
|
||||
CTRANSLATE2_ROOT=$STAGE pip wheel -q --no-deps --no-build-isolation "$SRC/python" -w "$WORK/wheel-raw"
|
||||
|
||||
# Étiquette manylinux d'après la glibc de l'image (2.35 → manylinux_2_35).
|
||||
GLIBC=$(ldd --version | head -1 | grep -oE '[0-9]+\.[0-9]+$' | tr . _)
|
||||
mkdir -p "$DIST"
|
||||
# Les bibliothèques CUDA ne sont PAS embarquées : CTranslate2 les charge
|
||||
# dynamiquement (CUDA_DYNAMIC_LOADING) depuis le toolkit ou les paquets
|
||||
# pip nvidia-*. Seules libctranslate2 et OpenBLAS entrent dans la roue.
|
||||
LD_LIBRARY_PATH=$STAGE/lib auditwheel repair \
|
||||
--plat "manylinux_${GLIBC}_aarch64" \
|
||||
--exclude 'libcuda.so.1' --exclude 'libcublas*' --exclude 'libcublasLt*' \
|
||||
--exclude 'libcudnn*' --exclude 'libcudart*' \
|
||||
-w "$DIST" "$WORK"/wheel-raw/*.whl
|
||||
ls -la "$DIST"/*.whl
|
||||
}
|
||||
|
||||
etape_check() {
|
||||
log "contrôles sans GPU"
|
||||
# shellcheck disable=SC1091
|
||||
. "$WORK/venv/bin/activate"
|
||||
pip install -q "$DIST"/ctranslate2-*.whl numpy pyyaml
|
||||
python3 - <<'PY'
|
||||
import ctranslate2, subprocess, glob, os
|
||||
print("ctranslate2", ctranslate2.__version__)
|
||||
lib = glob.glob(os.path.join(os.path.dirname(ctranslate2.__file__), "..", "ctranslate2.libs", "libctranslate2*"))[0]
|
||||
syms = subprocess.run(["nm", "-D", lib], capture_output=True, text=True).stdout
|
||||
assert "cublas" in syms.lower() or "cuda" in syms.lower(), "bibliothèque sans symboles CUDA"
|
||||
print("symboles CUDA présents dans", os.path.basename(lib))
|
||||
print("GPU visibles ici (0 attendu en CI) :", ctranslate2.get_cuda_device_count())
|
||||
PY
|
||||
dpkg-deb -I "$DIST"/libctranslate2-4_*.deb | sed -n '1,25p'
|
||||
lintian --no-tag-display-limit "$DIST"/*.deb || true
|
||||
}
|
||||
|
||||
case "${1:-all}" in
|
||||
deps) etape_deps ;;
|
||||
source) etape_source ;;
|
||||
deb) etape_deb ;;
|
||||
wheel) etape_wheel ;;
|
||||
check) etape_check ;;
|
||||
all) etape_deps; etape_source; etape_deb; etape_wheel; etape_check ;;
|
||||
*) echo "usage : $0 {deps|source|deb|wheel|check|all}" >&2; exit 2 ;;
|
||||
esac
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
ctranslate2 (4.6.0-1~cuda13) jammy; urgency=medium
|
||||
|
||||
* Build of upstream 4.6.0 with the CUDA 13 backend for Linux arm64
|
||||
(Jetson Orin 8.7, Grace Hopper 9.0, DGX Spark GB10 12.1), which the
|
||||
upstream project does not publish for this architecture.
|
||||
* CUDA libraries are loaded at run time (CUDA_DYNAMIC_LOADING): the
|
||||
package works on CPU without them.
|
||||
|
||||
-- Eric Lemesre <eric.lemesre@gmail.com> Wed, 24 Sep 2026 18:00:00 +0200
|
||||
Vendored
+40
@@ -0,0 +1,40 @@
|
||||
Source: ctranslate2
|
||||
Section: libs
|
||||
Priority: optional
|
||||
Maintainer: Eric Lemesre <eric.lemesre@gmail.com>
|
||||
Build-Depends: debhelper-compat (= 13),
|
||||
cmake (>= 3.15),
|
||||
ninja-build,
|
||||
libopenblas-dev
|
||||
Standards-Version: 4.6.2
|
||||
Homepage: https://github.com/OpenNMT/CTranslate2
|
||||
Rules-Requires-Root: no
|
||||
|
||||
Package: libctranslate2-4
|
||||
Architecture: arm64
|
||||
Multi-Arch: same
|
||||
Depends: ${shlibs:Depends}, ${misc:Depends}
|
||||
Recommends: libcublas-13-0, libcudnn9-cuda-13
|
||||
Description: fast inference engine for Transformer models (CUDA 13, arm64)
|
||||
CTranslate2 is a C++ and Python library for efficient inference with
|
||||
Transformer models (Whisper, NLLB, T5, Llama, ...), with weight quantization
|
||||
and CPU/GPU execution.
|
||||
.
|
||||
This build enables the CUDA backend for Linux arm64 (Jetson Orin, Grace
|
||||
Hopper, DGX Spark GB10), which the upstream project does not publish for
|
||||
this architecture. CUDA libraries are loaded at run time (cuBLAS 13,
|
||||
cuDNN 9) from the CUDA toolkit or from the nvidia-* pip packages; without
|
||||
them the library still works on CPU (OpenBLAS + Ruy).
|
||||
|
||||
Package: libctranslate2-dev
|
||||
Architecture: arm64
|
||||
Multi-Arch: same
|
||||
Section: libdevel
|
||||
Depends: libctranslate2-4 (= ${binary:Version}), ${misc:Depends}
|
||||
Description: fast inference engine for Transformer models - development files
|
||||
CTranslate2 is a C++ and Python library for efficient inference with
|
||||
Transformer models.
|
||||
.
|
||||
This package contains the headers and the unversioned shared library link
|
||||
needed to build programs against libctranslate2 (C++ or FFI bindings such
|
||||
as the Rust crate ct2rs).
|
||||
Vendored
+43
@@ -0,0 +1,43 @@
|
||||
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
|
||||
Upstream-Name: CTranslate2
|
||||
Upstream-Contact: OpenNMT <https://github.com/OpenNMT/CTranslate2>
|
||||
Source: https://github.com/OpenNMT/CTranslate2
|
||||
|
||||
Files: *
|
||||
Copyright: 2018-2026 SYSTRAN and the OpenNMT contributors
|
||||
License: MIT
|
||||
|
||||
Files: third_party/ruy/*
|
||||
Copyright: Google LLC
|
||||
License: Apache-2.0
|
||||
|
||||
Files: third_party/cpu_features/*
|
||||
Copyright: Google LLC
|
||||
License: Apache-2.0
|
||||
|
||||
Files: debian/*
|
||||
Copyright: 2026 Eric Lemesre
|
||||
License: MIT
|
||||
|
||||
License: MIT
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
.
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
License: Apache-2.0
|
||||
On Debian systems, the full text of the Apache License version 2.0 can be
|
||||
found in /usr/share/common-licenses/Apache-2.0.
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
usr/lib/*/libctranslate2.so.*
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
usr/include/ctranslate2
|
||||
usr/lib/*/libctranslate2.so
|
||||
usr/lib/*/cmake/CTranslate2
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
#!/usr/bin/make -f
|
||||
# Construction Debian de CTranslate2 avec le backend CUDA, arm64.
|
||||
# CUDA_ARCH_LIST vient de l'environnement (versions.env via build.sh) ;
|
||||
# repli sur la liste DGX Spark / Grace Hopper / Jetson Orin.
|
||||
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
|
||||
# -g sur du code CUDA : compilation lente et binaires énormes, sans usage ici.
|
||||
export DEB_CFLAGS_MAINT_STRIP = -g
|
||||
export DEB_CXXFLAGS_MAINT_STRIP = -g
|
||||
CUDA_ARCH_LIST ?= 8.7;9.0;12.1
|
||||
|
||||
%:
|
||||
dh $@ --buildsystem=cmake+ninja
|
||||
|
||||
override_dh_auto_configure:
|
||||
dh_auto_configure -- \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DBUILD_CLI=OFF \
|
||||
-DBUILD_TESTS=OFF \
|
||||
-DWITH_MKL=OFF \
|
||||
-DWITH_DNNL=OFF \
|
||||
-DWITH_OPENBLAS=ON \
|
||||
-DWITH_RUY=ON \
|
||||
-DOPENMP_RUNTIME=COMP \
|
||||
-DWITH_CUDA=ON \
|
||||
-DWITH_CUDNN=ON \
|
||||
-DCUDA_DYNAMIC_LOADING=ON \
|
||||
-DCUDA_ARCH_LIST="$(CUDA_ARCH_LIST)"
|
||||
|
||||
# Les bibliothèques CUDA sont chargées dynamiquement : aucune information
|
||||
# shlibs à leur sujet, dpkg-shlibdeps ne doit pas échouer dessus.
|
||||
override_dh_shlibdeps:
|
||||
dh_shlibdeps -- --ignore-missing-info
|
||||
|
||||
# dwz sur des fatbins CUDA : long et inutile.
|
||||
override_dh_dwz:
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
3.0 (quilt)
|
||||
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
# Le paquet est construit en binaire seulement (dpkg-buildpackage -b) depuis
|
||||
# le dépôt git amont avec ses sous-modules ; pas de tarball orig géré ici.
|
||||
Executable
+29
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env bash
|
||||
# Publie dist/ dans les registres de paquets Gitea du propriétaire :
|
||||
# - roue Python → registre PyPI (pip --extra-index-url …/pypi/simple)
|
||||
# - .deb → registre Debian (apt, distributions jammy et noble)
|
||||
# Variables : GITEA_URL, OWNER, PACKAGES_USER, PACKAGES_TOKEN (write:package).
|
||||
set -euo pipefail
|
||||
ROOT=$(cd "$(dirname "$0")/.." && pwd)
|
||||
DIST=${DIST:-$ROOT/dist}
|
||||
: "${GITEA_URL:?}" "${OWNER:?}" "${PACKAGES_USER:?}" "${PACKAGES_TOKEN:?}"
|
||||
|
||||
if [ -x "$ROOT/work/venv/bin/pip" ]; then PIP=$ROOT/work/venv/bin/pip; TWINE=$ROOT/work/venv/bin/twine
|
||||
else PIP="python3 -m pip"; TWINE=twine; fi
|
||||
$PIP install -q twine
|
||||
|
||||
echo "== PyPI : $GITEA_URL/api/packages/$OWNER/pypi"
|
||||
TWINE_USERNAME=$PACKAGES_USER TWINE_PASSWORD=$PACKAGES_TOKEN \
|
||||
$TWINE upload --non-interactive --skip-existing \
|
||||
--repository-url "$GITEA_URL/api/packages/$OWNER/pypi" "$DIST"/*.whl
|
||||
|
||||
for deb in "$DIST"/*.deb; do
|
||||
for distribution in jammy noble; do
|
||||
echo "== Debian : $(basename "$deb") → $distribution/main"
|
||||
# 409 = déjà présent : on ne casse pas une relance pour cela.
|
||||
code=$(curl -sS -o /dev/null -w '%{http_code}' --user "$PACKAGES_USER:$PACKAGES_TOKEN" \
|
||||
--upload-file "$deb" \
|
||||
"$GITEA_URL/api/packages/$OWNER/debian/pool/$distribution/main/upload")
|
||||
case "$code" in 201|409) echo " $code" ;; *) echo " échec HTTP $code" >&2; exit 1 ;; esac
|
||||
done
|
||||
done
|
||||
Executable
+62
@@ -0,0 +1,62 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Validation sur une machine AVEC GPU : la roue voit-elle le GPU, et
|
||||
faster-whisper transcrit-il en français dessus ?
|
||||
|
||||
pip install faster-whisper --extra-index-url https://git.lemesre.org/api/packages/<owner>/pypi/simple
|
||||
python3 tools/smoke-gpu.py [audio.wav]
|
||||
|
||||
Sans argument, seul le comptage des GPU est fait. cuBLAS 13 et cuDNN 9
|
||||
doivent être trouvables (toolkit CUDA système, ou paquets pip nvidia-*
|
||||
dont le script ajoute les dossiers lib à LD_LIBRARY_PATH s'ils existent).
|
||||
"""
|
||||
import ctypes
|
||||
import importlib
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
|
||||
|
||||
def dossiers_nvidia_pip() -> list[str]:
|
||||
dossiers = []
|
||||
for module in ("nvidia.cublas", "nvidia.cudnn", "nvidia.cuda_runtime"):
|
||||
try:
|
||||
m = importlib.import_module(module)
|
||||
except ImportError:
|
||||
continue
|
||||
lib = os.path.join(os.path.dirname(m.__file__), "lib")
|
||||
if os.path.isdir(lib):
|
||||
dossiers.append(lib)
|
||||
return dossiers
|
||||
|
||||
|
||||
def main() -> int:
|
||||
for d in dossiers_nvidia_pip():
|
||||
for f in sorted(os.listdir(d)):
|
||||
if f.startswith(("libcublas", "libcudnn")) and ".so" in f:
|
||||
try:
|
||||
ctypes.CDLL(os.path.join(d, f))
|
||||
except OSError:
|
||||
pass
|
||||
import ctranslate2
|
||||
n = ctranslate2.get_cuda_device_count()
|
||||
print(f"ctranslate2 {ctranslate2.__version__} — GPU CUDA visibles : {n}")
|
||||
if n == 0:
|
||||
print("aucun GPU : la roue est CPU ou CUDA est introuvable", file=sys.stderr)
|
||||
return 1
|
||||
print("types de calcul GPU :", sorted(ctranslate2.get_supported_compute_types("cuda")))
|
||||
if len(sys.argv) < 2:
|
||||
return 0
|
||||
from faster_whisper import WhisperModel
|
||||
modele = WhisperModel("large-v3", device="cuda", compute_type="float16")
|
||||
debut = time.perf_counter()
|
||||
segments, info = modele.transcribe(sys.argv[1], language="fr", beam_size=5, vad_filter=True)
|
||||
texte = [(s.start, s.end, s.text) for s in segments]
|
||||
duree = time.perf_counter() - debut
|
||||
print(f"audio {info.duration:.1f} s transcrit en {duree:.1f} s, langue forcée fr")
|
||||
for start, end, t in texte[:10]:
|
||||
print(f"[{start:6.1f}-{end:6.1f}] {t.strip()}")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -0,0 +1,10 @@
|
||||
# Versions épinglées — une seule source pour build.sh, le Dockerfile et la CI.
|
||||
CT2_VERSION=4.6.0
|
||||
CT2_UPSTREAM=https://github.com/OpenNMT/CTranslate2
|
||||
# Image de construction : toolchain CUDA 13 + cuDNN 9, Ubuntu 22.04 (glibc 2.35)
|
||||
# pour que la roue porte l'étiquette manylinux_2_35 et s'installe sur DGX OS
|
||||
# (24.04) comme sur Ubuntu 22.04. Le GPU n'est pas nécessaire à la compilation.
|
||||
CUDA_IMAGE=nvidia/cuda:13.0.1-cudnn-devel-ubuntu22.04
|
||||
# Architectures GPU : Jetson Orin (8.7), Grace Hopper (9.0), DGX Spark GB10 (12.1).
|
||||
# « Common » (défaut amont) ignore 12.1, d'où la liste explicite.
|
||||
CUDA_ARCH_LIST="8.7;9.0;12.1"
|
||||
Reference in new issue
Block a user