-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathbuild.sh
executable file
·74 lines (64 loc) · 1.68 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash
CURRENT_DIR=$(cd "$(dirname "$0")"; pwd)
ONNXRUNTIME_VERSION="1.15.0"
ONNXRUNTIME_GPU=1
# Platform
platform="$(uname -s)"
case "$platform" in
Darwin*)
ONNXRUNTIME_PLATFORM="osx"
ONNXRUNTIME_GPU=0
;;
Linux*)
ONNXRUNTIME_PLATFORM="linux"
;;
MINGW32_NT*|MINGW64_NT*)
ONNXRUNTIME_PLATFORM="win"
;;
*)
echo "Unsupported platform: $platform"
exit 1
;;
esac
# Architecture
architecture="$(uname -m)"
case "$architecture" in
x86_64)
ONNXRUNTIME_ARCH="x64"
;;
armv7l)
ONNXRUNTIME_ARCH="arm"
;;
aarch64|arm64)
ONNXRUNTIME_ARCH="arm64"
;;
*)
echo "Unsupported architecture: $architecture"
exit 1
;;
esac
# GPU
if [ ${ONNXRUNTIME_GPU} == 1 ]; then
ONNXRUNTIME_PATH="onnxruntime-${ONNXRUNTIME_PLATFORM}-${ONNXRUNTIME_ARCH}-gpu-${ONNXRUNTIME_VERSION}"
else
ONNXRUNTIME_PATH="onnxruntime-${ONNXRUNTIME_PLATFORM}-${ONNXRUNTIME_ARCH}-${ONNXRUNTIME_VERSION}"
fi
# Download onnxruntime
if [ ! -d "${CURRENT_DIR}/${ONNXRUNTIME_PATH}" ]; then
echo "Downloading onnxruntime ..."
curl -L -O -C - https://github.com/microsoft/onnxruntime/releases/download/v${ONNXRUNTIME_VERSION}/${ONNXRUNTIME_PATH}.tgz
tar -zxvf ${ONNXRUNTIME_PATH}.tgz
fi
ONNXRUNTIME_DIR="${CURRENT_DIR}/${ONNXRUNTIME_PATH}"
if [ -d "${CURRENT_DIR}/build" ]; then
rm -rf build
mkdir build
echo "Directory ${CURRENT_DIR}/build exists."
else
mkdir build
echo "Directory ${CURRENT_DIR}/build does not exist."
fi
cd build
echo "Build Code ..."
cmake .. -D ONNXRUNTIME_DIR="${ONNXRUNTIME_DIR}" -DCMAKE_BUILD_TYPE=Release
cmake --build .