forked from microsoft/onnxruntime-extensions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·30 lines (25 loc) · 877 Bytes
/
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
#!/bin/bash
# The example build script to build the source in Linux-like platform
set -e -x -u
cuda_arch=''
if [[ $@ == *"DOCOS_USE_CUDA=ON"* && $@ != *"DCMAKE_CUDA_ARCHITECTURES"* ]]; then
nvidia=$(nvidia-smi --query-gpu=compute_cap --format=csv,noheader,nounits)
cuda_arch=$(echo $nvidia | awk '{print $1}' | tr -d '.')
fi
OSNAME=$(uname -s)
if [ -z ${CPU_NUMBER+x} ]; then
if [[ "$OSNAME" == "Darwin" ]]; then
CPU_NUMBER=$(sysctl -n hw.logicalcpu)
else
CPU_NUMBER=$(nproc)
fi
fi
BUILD_FLAVOR=RelWithDebInfo
target_dir=out/$OSNAME/$BUILD_FLAVOR
mkdir -p "$target_dir" && cd "$target_dir"
param="$@ ../../.."
if [ -n "$cuda_arch" ]; then
param="$@ -DCMAKE_CUDA_ARCHITECTURES=$cuda_arch ../../.."
fi
# it looks the parallel build on CI pipeline machine causes crashes.
cmake $param && cmake --build . --config $BUILD_FLAVOR --parallel "${CPU_NUMBER}"