forked from rapidsai/cugraph
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·409 lines (376 loc) · 15.1 KB
/
build.sh
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
#!/bin/bash
# Copyright (c) 2019-2023, NVIDIA CORPORATION.
# cugraph build script
# This script is used to build the component(s) in this repo from
# source, and can be called with various options to customize the
# build as needed (see the help output for details)
# Abort script on first error
set -e
NUMARGS=$#
ARGS=$*
# NOTE: ensure all dir changes are relative to the location of this
# script, and that this script resides in the repo dir!
REPODIR=$(cd $(dirname $0); pwd)
# Valid args to this script (all possible targets and options) - only one per line
VALIDARGS="
clean
uninstall
libcugraph
libcugraph_etl
cugraph
cugraph-service
pylibcugraph
cpp-mgtests
cugraph-pyg
cugraph-dgl
cugraph-nx
docs
-v
-g
-n
--pydevelop
--allgpuarch
--skip_cpp_tests
--without_cugraphops
--cmake_default_generator
--clean
-h
--help
"
HELP="$0 [<target> ...] [<flag> ...]
where <target> is:
clean - remove all existing build artifacts and configuration (start over)
uninstall - uninstall libcugraph and cugraph from a prior build/install (see also -n)
libcugraph - build libcugraph.so and SG test binaries
libcugraph_etl - build libcugraph_etl.so and SG test binaries
pylibcugraph - build the pylibcugraph Python package
cugraph-pyg - build the cugraph-pyg Python package
cugraph - build the cugraph Python package
cugraph-nx - build the cugraph-nx Python package
cugraph-service - build the cugraph-service_client and cugraph-service_server Python package
cpp-mgtests - build libcugraph and libcugraph_etl MG tests. Builds MPI communicator, adding MPI as a dependency.
cugraph-dgl - build the cugraph-dgl extensions for DGL
docs - build the docs
and <flag> is:
-v - verbose build mode
-g - build for debug
-n - do not install after a successful build (does not affect Python packages)
--pydevelop - use setup.py develop instead of install
--allgpuarch - build for all supported GPU architectures
--skip_cpp_tests - do not build the SG test binaries as part of the libcugraph and libcugraph_etl targets
--without_cugraphops - do not build algos that require cugraph-ops
--cmake_default_generator - use the default cmake generator instead of ninja
--clean - clean an individual target (note: to do a complete rebuild, use the clean target described above)
-h - print this text
default action (no args) is to build and install 'libcugraph' then 'libcugraph_etl' then 'pylibcugraph' then 'cugraph' targets
libcugraph build dir is: ${LIBCUGRAPH_BUILD_DIR}
Set env var LIBCUGRAPH_BUILD_DIR to override libcugraph build dir.
"
LIBCUGRAPH_BUILD_DIR=${LIBCUGRAPH_BUILD_DIR:=${REPODIR}/cpp/build}
LIBCUGRAPH_ETL_BUILD_DIR=${LIBCUGRAPH_ETL_BUILD_DIR:=${REPODIR}/cpp/libcugraph_etl/build}
PYLIBCUGRAPH_BUILD_DIR=${REPODIR}/python/pylibcugraph/_skbuild
CUGRAPH_BUILD_DIR=${REPODIR}/python/cugraph/_skbuild
CUGRAPH_SERVICE_BUILD_DIRS="${REPODIR}/python/cugraph-service/server/build
${REPODIR}/python/cugraph-service/client/build
"
CUGRAPH_DGL_BUILD_DIR=${REPODIR}/python/cugraph-dgl/build
# All python build dirs using _skbuild are handled by cleanPythonDir, but
# adding them here for completeness
BUILD_DIRS="${LIBCUGRAPH_BUILD_DIR}
${LIBCUGRAPH_ETL_BUILD_DIR}
${PYLIBCUGRAPH_BUILD_DIR}
${CUGRAPH_BUILD_DIR}
${CUGRAPH_SERVICE_BUILD_DIRS}
${CUGRAPH_DGL_BUILD_DIR}
"
# Set defaults for vars modified by flags to this script
VERBOSE_FLAG=""
CMAKE_VERBOSE_OPTION=""
BUILD_TYPE=Release
INSTALL_TARGET="--target install"
BUILD_CPP_TESTS=ON
BUILD_CPP_MG_TESTS=OFF
BUILD_ALL_GPU_ARCH=0
BUILD_WITH_CUGRAPHOPS=ON
CMAKE_GENERATOR_OPTION="-G Ninja"
PYTHON_ARGS_FOR_INSTALL="-m pip install --no-build-isolation --no-deps"
# Set defaults for vars that may not have been defined externally
# FIXME: if PREFIX is not set, check CONDA_PREFIX, but there is no fallback
# from there!
INSTALL_PREFIX=${PREFIX:=${CONDA_PREFIX}}
PARALLEL_LEVEL=${PARALLEL_LEVEL:=`nproc`}
BUILD_ABI=${BUILD_ABI:=ON}
function hasArg {
(( ${NUMARGS} != 0 )) && (echo " ${ARGS} " | grep -q " $1 ")
}
function buildAll {
(( ${NUMARGS} == 0 )) || !(echo " ${ARGS} " | grep -q " [^-][a-zA-Z0-9\_\-]\+ ")
}
function cleanPythonDir {
pushd $1 > /dev/null
rm -rf dist dask-worker-space cugraph/raft *.egg-info
find . -type d -name __pycache__ -print | xargs rm -rf
find . -type d -name _skbuild -print | xargs rm -rf
find . -type d -name dist -print | xargs rm -rf
find . -type f -name "*.cpp" -delete
find . -type f -name "*.cpython*.so" -delete
find . -type d -name _external_repositories -print | xargs rm -rf
popd > /dev/null
}
if hasArg -h || hasArg --help; then
echo "${HELP}"
exit 0
fi
# Check for valid usage
if (( ${NUMARGS} != 0 )); then
for a in ${ARGS}; do
if ! (echo "${VALIDARGS}" | grep -q "^[[:blank:]]*${a}$"); then
echo "Invalid option: ${a}"
exit 1
fi
done
fi
# Process flags
if hasArg -v; then
VERBOSE_FLAG="-v"
CMAKE_VERBOSE_OPTION="--log-level=VERBOSE"
fi
if hasArg -g; then
BUILD_TYPE=Debug
fi
if hasArg -n; then
INSTALL_TARGET=""
fi
if hasArg --allgpuarch; then
BUILD_ALL_GPU_ARCH=1
fi
if hasArg --skip_cpp_tests; then
BUILD_CPP_TESTS=OFF
fi
if hasArg --without_cugraphops; then
BUILD_WITH_CUGRAPHOPS=OFF
fi
if hasArg cpp-mgtests; then
BUILD_CPP_MG_TESTS=ON
fi
if hasArg --cmake_default_generator; then
CMAKE_GENERATOR_OPTION=""
fi
if hasArg --pydevelop; then
PYTHON_ARGS_FOR_INSTALL="-m pip install --no-build-isolation --no-deps -e"
fi
# Append `-DFIND_RAFT_CPP=ON` to EXTRA_CMAKE_ARGS unless a user specified the option.
SKBUILD_EXTRA_CMAKE_ARGS="${EXTRA_CMAKE_ARGS}"
if [[ "${EXTRA_CMAKE_ARGS}" != *"DFIND_CUGRAPH_CPP"* ]]; then
SKBUILD_EXTRA_CMAKE_ARGS="${SKBUILD_EXTRA_CMAKE_ARGS} -DFIND_CUGRAPH_CPP=ON"
fi
# If clean or uninstall targets given, run them prior to any other steps
if hasArg uninstall; then
if [[ "$INSTALL_PREFIX" != "" ]]; then
rm -rf ${INSTALL_PREFIX}/include/cugraph
rm -f ${INSTALL_PREFIX}/lib/libcugraph.so
rm -rf ${INSTALL_PREFIX}/include/cugraph_c
rm -f ${INSTALL_PREFIX}/lib/libcugraph_c.so
rm -rf ${INSTALL_PREFIX}/include/cugraph_etl
rm -f ${INSTALL_PREFIX}/lib/libcugraph_etl.so
rm -rf ${INSTALL_PREFIX}/lib/cmake/cugraph
rm -rf ${INSTALL_PREFIX}/lib/cmake/cugraph_etl
fi
# This may be redundant given the above, but can also be used in case
# there are other installed files outside of the locations above.
if [ -e ${LIBCUGRAPH_BUILD_DIR}/install_manifest.txt ]; then
xargs rm -f < ${LIBCUGRAPH_BUILD_DIR}/install_manifest.txt > /dev/null 2>&1
fi
# uninstall cugraph and pylibcugraph installed from a prior "setup.py
# install"
# FIXME: if multiple versions of these packages are installed, this only
# removes the latest one and leaves the others installed. build.sh uninstall
# can be run multiple times to remove all of them, but that is not obvious.
pip uninstall -y pylibcugraph cugraph cugraph-service-client cugraph-service-server \
cugraph-dgl cugraph-pyg cugraph-nx
fi
if hasArg clean; then
# Ignore errors for clean since missing files, etc. are not failures
set +e
# remove artifacts generated inplace
# FIXME: ideally the "setup.py clean" command would be used for this, but
# currently running any setup.py command has side effects (eg. cloning
# repos).
# (cd ${REPODIR}/python && python setup.py clean)
if [[ -d ${REPODIR}/python ]]; then
cleanPythonDir ${REPODIR}/python
fi
# If the dirs to clean are mounted dirs in a container, the contents should
# be removed but the mounted dirs will remain. The find removes all
# contents but leaves the dirs, the rmdir attempts to remove the dirs but
# can fail safely.
for bd in ${BUILD_DIRS}; do
if [ -d ${bd} ]; then
find ${bd} -mindepth 1 -delete
rmdir ${bd} || true
fi
done
# Go back to failing on first error for all other operations
set -e
fi
################################################################################
# Configure, build, and install libcugraph
if buildAll || hasArg libcugraph; then
if hasArg --clean; then
if [ -d ${LIBCUGRAPH_BUILD_DIR} ]; then
find ${LIBCUGRAPH_BUILD_DIR} -mindepth 1 -delete
rmdir ${LIBCUGRAPH_BUILD_DIR} || true
fi
else
if (( ${BUILD_ALL_GPU_ARCH} == 0 )); then
CUGRAPH_CMAKE_CUDA_ARCHITECTURES="NATIVE"
echo "Building for the architecture of the GPU in the system..."
else
CUGRAPH_CMAKE_CUDA_ARCHITECTURES="RAPIDS"
echo "Building for *ALL* supported GPU architectures..."
fi
mkdir -p ${LIBCUGRAPH_BUILD_DIR}
cd ${LIBCUGRAPH_BUILD_DIR}
cmake -B "${LIBCUGRAPH_BUILD_DIR}" -S "${REPODIR}/cpp" \
-DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} \
-DCMAKE_CUDA_ARCHITECTURES=${CUGRAPH_CMAKE_CUDA_ARCHITECTURES} \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
-DBUILD_TESTS=${BUILD_CPP_TESTS} \
-DBUILD_CUGRAPH_MG_TESTS=${BUILD_CPP_MG_TESTS} \
-DUSE_CUGRAPH_OPS=${BUILD_WITH_CUGRAPHOPS} \
${CMAKE_GENERATOR_OPTION} \
${CMAKE_VERBOSE_OPTION}
cmake --build "${LIBCUGRAPH_BUILD_DIR}" -j${PARALLEL_LEVEL} ${INSTALL_TARGET} ${VERBOSE_FLAG}
fi
fi
# Configure, build, and install libcugraph_etl
if buildAll || hasArg libcugraph_etl; then
if hasArg --clean; then
if [ -d ${LIBCUGRAPH_ETL_BUILD_DIR} ]; then
find ${LIBCUGRAPH_ETL_BUILD_DIR} -mindepth 1 -delete
rmdir ${LIBCUGRAPH_ETL_BUILD_DIR} || true
fi
else
if (( ${BUILD_ALL_GPU_ARCH} == 0 )); then
CUGRAPH_CMAKE_CUDA_ARCHITECTURES="NATIVE"
echo "Building for the architecture of the GPU in the system..."
else
CUGRAPH_CMAKE_CUDA_ARCHITECTURES="RAPIDS"
echo "Building for *ALL* supported GPU architectures..."
fi
mkdir -p ${LIBCUGRAPH_ETL_BUILD_DIR}
cd ${LIBCUGRAPH_ETL_BUILD_DIR}
cmake -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} \
-DCMAKE_CUDA_ARCHITECTURES=${CUGRAPH_CMAKE_CUDA_ARCHITECTURES} \
-DDISABLE_DEPRECATION_WARNING=${BUILD_DISABLE_DEPRECATION_WARNING} \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
-DBUILD_TESTS=${BUILD_CPP_TESTS} \
-DBUILD_CUGRAPH_MG_TESTS=${BUILD_CPP_MG_TESTS} \
-DCMAKE_PREFIX_PATH=${LIBCUGRAPH_BUILD_DIR} \
${CMAKE_GENERATOR_OPTION} \
${CMAKE_VERBOSE_OPTION} \
${REPODIR}/cpp/libcugraph_etl
cmake --build "${LIBCUGRAPH_ETL_BUILD_DIR}" -j${PARALLEL_LEVEL} ${INSTALL_TARGET} ${VERBOSE_FLAG}
fi
fi
# Build, and install pylibcugraph
if buildAll || hasArg pylibcugraph; then
if hasArg --clean; then
cleanPythonDir ${REPODIR}/python/pylibcugraph
else
# FIXME: skbuild with setuptools>=64 has a bug when called from a "pip
# install -e" command, resulting in a broken editable wheel. Continue
# to use "setup.py bdist_ext --inplace" for a develop build until
# https://github.com/scikit-build/scikit-build/issues/981 is closed.
if hasArg --pydevelop; then
cd ${REPODIR}/python/pylibcugraph
python setup.py build_ext \
--inplace \
-- \
-DFIND_CUGRAPH_CPP=ON \
-DUSE_CUGRAPH_OPS=${BUILD_WITH_CUGRAPHOPS} \
-Dcugraph_ROOT=${LIBCUGRAPH_BUILD_DIR} \
-- \
-j${PARALLEL_LEVEL:-1}
cd -
fi
SKBUILD_CONFIGURE_OPTIONS="${SKBUILD_EXTRA_CMAKE_ARGS} -DUSE_CUGRAPH_OPS=${BUILD_WITH_CUGRAPHOPS}" \
SKBUILD_BUILD_OPTIONS="-j${PARALLEL_LEVEL}" \
python ${PYTHON_ARGS_FOR_INSTALL} ${REPODIR}/python/pylibcugraph
fi
fi
# Build and install the cugraph Python package
if buildAll || hasArg cugraph; then
if hasArg --clean; then
cleanPythonDir ${REPODIR}/python/cugraph
else
# FIXME: skbuild with setuptools>=64 has a bug when called from a "pip
# install -e" command, resulting in a broken editable wheel. Continue
# to use "setup.py bdist_ext --inplace" for a develop build until
# https://github.com/scikit-build/scikit-build/issues/981 is closed.
if hasArg --pydevelop; then
cd ${REPODIR}/python/cugraph
python setup.py build_ext \
--inplace \
-- \
-DFIND_CUGRAPH_CPP=ON \
-DUSE_CUGRAPH_OPS=${BUILD_WITH_CUGRAPHOPS} \
-Dcugraph_ROOT=${LIBCUGRAPH_BUILD_DIR} \
-- \
-j${PARALLEL_LEVEL:-1}
cd -
fi
SKBUILD_CONFIGURE_OPTIONS="${SKBUILD_EXTRA_CMAKE_ARGS} -DUSE_CUGRAPH_OPS=${BUILD_WITH_CUGRAPHOPS}" \
SKBUILD_BUILD_OPTIONS="-j${PARALLEL_LEVEL}" \
python ${PYTHON_ARGS_FOR_INSTALL} ${REPODIR}/python/cugraph
fi
fi
# Install the cugraph-service-client and cugraph-service-server Python packages
if hasArg cugraph-service; then
if hasArg --clean; then
cleanPythonDir ${REPODIR}/python/cugraph-service
else
python ${PYTHON_ARGS_FOR_INSTALL} ${REPODIR}/python/cugraph-service/client
python ${PYTHON_ARGS_FOR_INSTALL} ${REPODIR}/python/cugraph-service/server
fi
fi
# Build and install the cugraph-pyg Python package
if hasArg cugraph-pyg; then
if hasArg --clean; then
cleanPythonDir ${REPODIR}/python/cugraph-pyg
else
python ${PYTHON_ARGS_FOR_INSTALL} ${REPODIR}/python/cugraph-pyg
fi
fi
# Install the cugraph-dgl extensions for DGL
if hasArg cugraph-dgl; then
if hasArg --clean; then
cleanPythonDir ${REPODIR}/python/cugraph-dgl
else
python ${PYTHON_ARGS_FOR_INSTALL} ${REPODIR}/python/cugraph-dgl
fi
fi
# Build and install the cugraph-nx Python package
if hasArg cugraph-nx; then
if hasArg --clean; then
cleanPythonDir ${REPODIR}/python/cugraph-nx
else
python ${PYTHON_ARGS_FOR_INSTALL} ${REPODIR}/python/cugraph-nx
fi
fi
# Build the docs
if hasArg docs; then
if [ ! -d ${LIBCUGRAPH_BUILD_DIR} ]; then
mkdir -p ${LIBCUGRAPH_BUILD_DIR}
cd ${LIBCUGRAPH_BUILD_DIR}
cmake -B "${LIBCUGRAPH_BUILD_DIR}" -S "${REPODIR}/cpp" \
-DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
${CMAKE_GENERATOR_OPTION} \
${CMAKE_VERBOSE_OPTION}
fi
cd ${LIBCUGRAPH_BUILD_DIR}
cmake --build "${LIBCUGRAPH_BUILD_DIR}" -j${PARALLEL_LEVEL} --target docs_cugraph ${VERBOSE_FLAG}
cd ${REPODIR}/docs/cugraph
make html
fi