-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·48 lines (40 loc) · 1.18 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
#!/bin/bash
set -ex
export MAX_JOBS=8
# setup sccache wrappers
if hash sccache 2>/dev/null; then
SCCACHE_BIN_DIR="/tmp/sccache"
mkdir -p "$SCCACHE_BIN_DIR"
for compiler in cc c++ gcc g++ x86_64-linux-gnu-gcc; do
(
echo "#!/bin/sh"
echo "exec $(which sccache) $(which $compiler) \"\$@\""
) > "$SCCACHE_BIN_DIR/$compiler"
chmod +x "$SCCACHE_BIN_DIR/$compiler"
done
export PATH="$SCCACHE_BIN_DIR:$PATH"
fi
# setup virtualenv
VENV_DIR=/tmp/venv
PYTHON="$(which python)"
if [[ "${CIRCLE_JOB}" =~ py((2|3)\\.?[0-9]?\\.?[0-9]?) ]]; then
PYTHON=$(which "python${BASH_REMATCH[1]}")
fi
$PYTHON -m virtualenv "$VENV_DIR"
source "$VENV_DIR/bin/activate"
pip install -U pip setuptools
# setup onnx as the submodule of pytorch
PYTORCH_DIR=/tmp/pytorch
ONNX_DIR="$PYTORCH_DIR/third_party/onnx"
git clone --recursive --quiet https://github.com/pytorch/pytorch.git "$PYTORCH_DIR"
rm -rf "$ONNX_DIR"
cp -r "$PWD" "$ONNX_DIR"
# install ninja to speedup the build
pip install ninja
# install everything
cd $PYTORCH_DIR
./scripts/onnx/install-develop.sh
# report sccache hit/miss stats
if hash sccache 2>/dev/null; then
sccache --show-stats
fi