blob: f40761e4b7128ec80494b8df5c43bf84f7fa0039 (
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
163
164
165
166
167
168
169
170
171
172
|
# Maintainer: Butui Hu <hot123tea123@gmail.com>
_CUDA_ARCH_LIST="6.0;6.1;6.2;7.0;7.2;7.5;8.0;8.6;8.6+PTX"
_pkgname=mxnet
pkgname=('mxnet-git' 'mxnet-cuda-git')
_pkgver=2.0.0
pkgver=2.0.0.r11770.7d84b59845
pkgrel=1
pkgdesc='A flexible and efficient library for deep learning'
arch=('x86_64')
url="http://mxnet.io/"
license=('Apache')
depends=(
'curl'
'double-conversion'
'hdf5'
'intel-mkl'
'intel-tbb'
'libjpeg-turbo'
'protobuf'
'python-graphviz'
'python-numpy'
'python-requests'
'zeromq'
)
makedepends=(
'chrpath'
'cmake'
'cuda'
'cudnn'
'cython'
'git'
'gtk3'
'nccl'
'opencv'
'python-setuptools'
'qt5-base'
)
provides=(mxnet=${pkgver})
conflicts=(mxnet)
source=("${_pkgname}::git+https://github.com/apache/incubator-mxnet.git")
sha512sums=('SKIP')
get_pyver() {
python -c 'import sys; print(str(sys.version_info[0]) + "." + str(sys.version_info[1]))'
}
pkgver() {
cd "${srcdir}/${_pkgname}"
ver=$(printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)")
echo "${_pkgver}.${ver}"
}
prepare() {
cd "${srcdir}/${_pkgname}"
git submodule update --init --recursive
# do not use 3rd party openmp
rm -rfv "${srcdir}/${_pkgname}/3rdparty/openmp"
# CUB is now available bundled with CUDA
rm -rfv "${srcdir}/${_pkgname}/3rdparty/nvidia_cub"
# the latest cmake set OpenMP_FOUND instead of OPENMP_FOUND
sed -i 's/OPENMP_FOUND/OpenMP_FOUND/g' "${srcdir}/${_pkgname}/CMakeLists.txt"
# fix newline error in description
sed -i "s#description=open(os.path.join(CURRENT_DIR, 'README.md')).read()#description='A flexible and efficient library for deep learning'#" "python/setup.py"
rm -rf "${srcdir}/${_pkgname}/build"
mkdir "${srcdir}/${_pkgname}/build"
cp -a "${srcdir}/${_pkgname}" "${srcdir}/mxnet-git"
cp -a "${srcdir}/${_pkgname}" "${srcdir}/mxnet-cuda-git"
}
build() {
cmake_opts=(
-DBUILD_CPP_EXAMPLES:BOOL=OFF
-DBUILD_TESTING:BOOL=OFF
-DCMAKE_INSTALL_LIBDIR:PATH=lib
-DCMAKE_INSTALL_PREFIX:PATH=/usr
-DCMAKE_SKIP_INSTALL_RPATH:BOOL=ON
-DINSTALL_DOCUMENTATION:BOOL=OFF
-DINSTALL_MKLDNN:BOOL=OFF
-DMKL_USE_SINGLE_DYNAMIC_LIBRARY:BOOL=ON
-DUSE_BLAS=mkl
-DUSE_CPP_PACKAGE:BOOL=ON
-DUSE_CXX14_IF_AVAILABLE:BOOL=ON
-DUSE_DIST_KVSTORE:BOOL=ON
-DUSE_GPERFTOOLS:BOOL=OFF
-DUSE_JEMALLOC:BOOL=OFF
-DUSE_LAPACK:BOOL=ON
-DUSE_LIBJPEG_TURBO:BOOL=ON
-DUSE_MKLDNN:BOOL=ON
-DUSE_MKL_IF_AVAILABLE:BOOL=ON
-DUSE_OPENMP:BOOL=ON
-DUSE_S3:BOOL=ON
)
# building with CUDA
cd "${srcdir}/mxnet-cuda-git/build"
cmake \
${cmake_opts[@]} \
-DMXNET_CUDA_ARCH=${_CUDA_ARCH_LIST} \
-DUSE_CUDA:BOOL=ON \
-DUSE_CUDNN:BOOL=ON \
-DUSE_NCCL:BOOL=ON \
-DUSE_OPENCV:BOOL=ON \
..
make
cd ../python
python setup.py build --with-cython
# building without CUDA
cd "${srcdir}/mxnet-git/build"
cmake \
${cmake_opts[@]} \
-DUSE_CUDA:BOOL=OFF \
-DUSE_CUDNN:BOOL=OFF \
-DUSE_NCCL:BOOL=OFF \
-DUSE_OPENCV:BOOL=ON \
..
make
cd ../python
python setup.py build --with-cython
}
_package() {
cd "${srcdir}/${pkgname}/build"
# install mxnet core component
make DESTDIR="${pkgdir}" install
if [ -f "${srcdir}/${pkgname}/build/im2rec" ]; then
install -Dm755 "${srcdir}/${pkgname}/build/im2rec" "${pkgdir}/usr/bin/im2rec"
chrpath --delete "${pkgdir}/usr/bin/im2rec"
fi
find "${pkgdir}" -type f -name '*.so' -exec chrpath --delete {} \;
# install python binding
cd "${srcdir}/${pkgname}/python"
python setup.py install --root="${pkgdir}" --optimize=1 --with-cython --skip-build
install -Dm644 "${srcdir}/${pkgname}/LICENSE" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
# create neccesarry soft links
ln -sf '/usr/lib/libmxnet.so' "${pkgdir}/usr/lib/python$(get_pyver)/site-packages/mxnet/libmxnet.so"
ln -s "/usr/include" "${pkgdir}/usr/lib/python$(get_pyver)/site-packages/mxnet/include"
# remove unwantted files
rm -rfv "${pkgdir}/usr/mxnet"
rm -rfv "${pkgdir}/usr/lib/cmake/dnnl"
rm -rfv "${pkgdir}/usr/lib/cmake/mkldnn"
rm -rfv "${pkgdir}/usr/share/doc"
rm -rfv "${pkgdir}/onednn"
find "${pkgdir}" -name '*.a' -delete
}
package_mxnet-git() {
depends+=(opencv)
_package
}
package_mxnet-cuda-git() {
pkgdesc="${pkgdesc} (with CUDA)"
depends+=(cuda cudnn nccl opencv)
provides+=(mxnet-cuda=${pkgver})
conflicts+=(mxnet-cuda)
_package
}
# vim:set ts=2 sw=2 et:
|