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

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

10
11
12
13
14
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.
CMAKE_VARS="$CMAKE_VARS -DTORCH_PYTHON_INTERPS=/opt/conda/envs/pytorch-ci/bin/python"
15

16
17
18
19
20
21
#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

22
if [ "$1" == "gpu" ]; then
23
    CMAKE_VARS="-DUSE_CUDA=ON -DUSE_NCCL=ON $CMAKE_VARS"
24
25
fi

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

rm -rf _download

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

pushd python
VoVAllen's avatar
VoVAllen committed
39
for backend in pytorch mxnet tensorflow
Mufei Li's avatar
Mufei Li committed
40
do
VoVAllen's avatar
VoVAllen committed
41
conda activate "${backend}-ci"
42
rm -rf build *.egg-info dist
VoVAllen's avatar
VoVAllen committed
43
pip uninstall -y dgl
Minjie Wang's avatar
Minjie Wang committed
44
# test install
45
python3 setup.py install
Minjie Wang's avatar
Minjie Wang committed
46
47
# test inplace build (for cython)
python3 setup.py build_ext --inplace
VoVAllen's avatar
VoVAllen committed
48
done
49
popd