build_dgl.sh 1.44 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
11
12
13
CMAKE_VARS="-DBUILD_CPP_TEST=ON -DUSE_OPENMP=ON -DBUILD_TORCH=ON"
# 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
15
16
if [ "$1" != "cugraph" ]; then
    CMAKE_VARS="$CMAKE_VARS -DTORCH_PYTHON_INTERPS=/opt/conda/envs/pytorch-ci/bin/python"
fi
17

18
19
20
21
22
23
#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

24
if [[ $1 != "cpu" ]]; then
25
    CMAKE_VARS="-DUSE_CUDA=ON -DUSE_NCCL=ON -DUSE_FP16=ON $CMAKE_VARS"
26
27
fi

28
if [ -d build ]; then
29
    rm -rf build
30
31
32
33
34
35
fi
mkdir build

rm -rf _download

pushd build
36
cmake $CMAKE_VARS ..
Jinjing Zhou's avatar
Jinjing Zhou committed
37
make -j
38
39
40
popd

pushd python
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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
60
popd