build_dgl.sh 1.76 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 -DUSE_LIBXSMM=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
19
20
21
    CMAKE_VARS="$CMAKE_VARS -DBUILD_TORCH=ON -DTORCH_PYTHON_INTERPS=/opt/conda/envs/pytorch-ci/bin/python"
else
    # Disable sparse build as cugraph docker image lacks cuDNN.
    CMAKE_VARS="$CMAKE_VARS -DBUILD_SPARSE=OFF"
22
fi
23

24
25
26
27
28
29
#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

30
if [[ $1 != "cpu" ]]; then
31
    CMAKE_VARS="-DUSE_CUDA=ON -DUSE_NCCL=ON $CMAKE_VARS"
32
33
fi

34
if [ -d build ]; then
35
    rm -rf build
36
37
38
39
40
41
fi
mkdir build

rm -rf _download

pushd build
42
cmake $CMAKE_VARS ..
Jinjing Zhou's avatar
Jinjing Zhou committed
43
make -j
44
45
46
popd

pushd python
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
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
66
popd