build_dgl.sh 1.65 KB
Newer Older
1
#!/bin/bash
2
set -e
VoVAllen's avatar
VoVAllen committed
3
. /opt/conda/etc/profile.d/conda.sh
4

5
if [ $# -ne 1 ]; then
6
    echo "Device argument required, can be cpu, gpu or cugraph"
7
8
9
    exit -1
fi

10
CMAKE_VARS="-DBUILD_CPP_TEST=ON -DUSE_OPENMP=ON"
11
12
13
# This is a semicolon-separated list of Python interpreters containing PyTorch.
# The value here is for CI.  Replace it with your own or comment this whole
# statement for default Python interpreter.
14
if [ "$1" != "cugraph" ]; then
15
16
17
    # We do not build pytorch for cugraph because currently building
    # pytorch against all the supported cugraph versions is not supported
    # See issue: https://github.com/rapidsai/cudf/issues/8510
18
    CMAKE_VARS="$CMAKE_VARS -DBUILD_TORCH=ON -DBUILD_SPARSE=ON -DTORCH_PYTHON_INTERPS=/opt/conda/envs/pytorch-ci/bin/python"
19
fi
20

21
22
23
24
25
26
#This is implemented to detect underlying architecture and enable arch specific optimization.
arch=`uname -m`
if [[ $arch == *"x86"* ]]; then
  CMAKE_VARS="-DUSE_AVX=ON $CMAKE_VARS"
fi

27
if [[ $1 != "cpu" ]]; then
28
    CMAKE_VARS="-DUSE_CUDA=ON -DUSE_NCCL=ON $CMAKE_VARS"
29
30
fi

31
if [ -d build ]; then
32
    rm -rf build
33
34
35
36
37
38
fi
mkdir build

rm -rf _download

pushd build
39
cmake $CMAKE_VARS ..
Jinjing Zhou's avatar
Jinjing Zhou committed
40
make -j
41
42
43
popd

pushd python
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
if [[ $1 == "cugraph" ]]; then
    rm -rf build *.egg-info dist
    pip uninstall -y dgl
    # test install
    python3 setup.py install
    # test inplace build (for cython)
    python3 setup.py build_ext --inplace
else
    for backend in pytorch mxnet tensorflow
    do
    conda activate "${backend}-ci"
    rm -rf build *.egg-info dist
    pip uninstall -y dgl
    # test install
    python3 setup.py install
    # test inplace build (for cython)
    python3 setup.py build_ext --inplace
    done
fi
63
popd