blob: 262e8af541e0456d66163c34daf67a92242fcb8b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
|
# Maintainer: Mark Wagie <mark dot wagie at proton dot me>
pkgname=(
'ctranslate2'
'python-ctranslate2'
# 'ctranslate2-docs'
)
pkgbase=ctranslate2
pkgver=4.5.0
pkgrel=1
pkgdesc="A C++ and Python library for efficient inference with Transformer models."
arch=('x86_64')
url="https://opennmt.net/CTranslate2"
license=('MIT')
makedepends=(
'cmake'
'cuda'
# 'cudnn'
'gcc13'
'git'
'intel-oneapi-mkl'
'onednn'
'openblas'
'pybind11'
'python-build'
'python-installer'
# 'python-myst-parser' ## docs
'python-setuptools'
# 'python-sphinx' ## docs
# 'python-sphinx_rtd_theme' ## docs
'python-wheel'
)
#checkdepends=(
# 'python-opennmt-tf' ## TODO
# 'python-numpy'
# 'python-pytest'
# 'python-pytorch'
# 'python-yaml'
#)
options=('!lto') ## lto-wrapper fails with CUDA options enabled
source=("git+https://github.com/OpenNMT/CTranslate2.git#tag=v$pkgver"
'git+https://github.com/jarro2783/cxxopts.git'
'git+https://github.com/NVIDIA/thrust.git'
'git+https://github.com/google/googletest.git'
'git+https://github.com/google/cpu_features.git'
'git+https://github.com/gabime/spdlog.git'
'git+https://github.com/google/ruy.git'
'git+https://github.com/pytorch/cpuinfo.git'
'git+https://github.com/NVIDIA/cub.git')
sha256sums=('914dc8abc9f3ef75ae74e5673e8a99fca85a4d7036ba708e0c6569ec7511f4ec'
'SKIP'
'SKIP'
'SKIP'
'SKIP'
'SKIP'
'SKIP'
'SKIP'
'SKIP')
prepare() {
cd CTranslate2
git submodule init
for submodule in cxxopts thrust googletest cpu_features spdlog ruy; do
git config submodule.src/third_party/${submodule}.url "$srcdir/${submodule}"
done
git -c protocol.file.allow=always submodule update
pushd third_party/ruy
git submodule init
git config submodule.src/third_party/cpuinfo.url "$srcdir/cpuinfo"
git config submodule.src/third_party/googletest.url "$srcdir/googletest"
git -c protocol.file.allow=always submodule update
popd
pushd third_party/thrust
git submodule init
git config submodule.dependencies/cub.url "$srcdir/cub"
git -c protocol.file.allow=always submodule update
popd
}
build() {
## WITH_CUDNN='ON'
# hard dependency if enabled, however convolution layers will not be supported on
# GPU if CUDA is enabled without it
cmake -B build -S CTranslate2 \
-DCMAKE_C_COMPILER='gcc-13' \
-DCMAKE_CXX_COMPILER='g++-13' \
-DCMAKE_BUILD_TYPE='Release' \
-DCMAKE_INSTALL_PREFIX='/usr' \
-DOPENMP_RUNTIME='COMP' \
-DWITH_MKL='OFF' \
-DWITH_DNNL='OFF' \
-DWITH_OPENBLAS='ON' \
-DOPENBLAS_INCLUDE_DIR='/usr/include/openblas' \
-DWITH_RUY='ON' \
-DWITH_CUDA='ON' \
-DCUDA_DYNAMIC_LOADING='ON' \
-DCUDA_ARCH_LIST='Common' \
-Wno-dev
cmake --build build
pushd CTranslate2/python
CTRANSLATE2_ROOT=.. LIBRARY_PATH="$srcdir/build" python -m build --wheel --no-isolation
popd
# AttributeError: 'NoneType' object has no attribute 'endswith'
# pushd CTranslate2/docs
# PYTHONPATH="$srcdir/build" python generate.py python
# sphinx-build . build
# popd
}
#check() {
# cd CTranslate2
# C++ tests, requires BUILD_TESTS='ON'
# Does not actually build 'ctranslate2_test' to run tests ???
# ./tests/ctranslate2_test ../tests/data
# Python tests
# PYTHONPATH=python pytest python/tests/
#}
package_ctranslate2() {
pkgdesc="A C++ library for efficient inference with Transformer models."
depends=('nlohmann-json' 'onednn')
optdepends=('cuda')
provides=('libctranslate2.so=4')
DESTDIR="$pkgdir" cmake --install build
# Avoid conflict with nlohmann-json
rm -r "$pkgdir/usr/include/nlohmann"
install -Dm644 CTranslate2/LICENSE -t "$pkgdir/usr/share/licenses/$pkgname/"
}
package_python-ctranslate2() {
pkgdesc="A Python library for efficient inference with Transformer models."
depends=(
'ctranslate2'
'python-numpy'
'python-pytorch'
'python-setuptools'
'python-yaml'
)
optdepends=('python-pytorch-cuda')
cd CTranslate2/python
python -m installer --destdir="$pkgdir" dist/*.whl
install -Dm644 ../LICENSE -t "$pkgdir/usr/share/licenses/$pkgname/"
}
#package_ctranslate2-docs() {
# pkgdesc+=" (docs)"
# cd CTranslate2
# cp -r docs/build/* "$pkgdir/usr/share/doc/$pkgbase"
#}
|