-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·212 lines (173 loc) · 5.54 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
# #!/bin/bash
# set -euo pipefail
# CURRENT_DIR=$(cd "$(dirname "$0")" && pwd)
# # Default values
# ONNXRUNTIME_VERSION="${1:-1.20.1}"
# ONNXRUNTIME_GPU="${2:-0}"
# # Function to display usage
# usage() {
# echo "Usage: $0 [ONNXRUNTIME_VERSION] [ONNXRUNTIME_GPU]"
# echo
# echo "This script downloads ONNX Runtime for the current platform and architecture and builds YOLOs-CPP."
# echo
# echo "Arguments:"
# echo " ONNXRUNTIME_VERSION Version of ONNX Runtime to download (default: 1.20.1)."
# echo " ONNXRUNTIME_GPU Whether to use GPU support (0 for CPU, 1 for GPU, default: 0)."
# echo
# echo "Examples:"
# echo " $0 1.20.1 0 # Downloads ONNX Runtime v1.20.1 for CPU."
# echo " $0 1.16.3 1 # Downloads ONNX Runtime v1.16.3 for GPU."
# echo
# exit 1
# }
# # Show usage if help is requested
# if [[ "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then
# usage
# fi
# # Detect platform and architecture
# platform=$(uname -s)
# architecture=$(uname -m)
# case "$platform" in
# Darwin*)
# ONNXRUNTIME_PLATFORM="osx"
# ONNXRUNTIME_GPU=0
# ;;
# Linux*) ONNXRUNTIME_PLATFORM="linux" ;;
# MINGW*) ONNXRUNTIME_PLATFORM="win" ;;
# *)
# echo "Unsupported platform: $platform"
# exit 1
# ;;
# esac
# # Determine ONNX Runtime architecture
# if [[ "$architecture" == "aarch64" || "$architecture" == "arm64" ]]; then
# ONNXRUNTIME_GPU=0
# if [[ "$ONNXRUNTIME_PLATFORM" == "linux" ]]; then
# ONNXRUNTIME_ARCH="aarch64"
# else
# ONNXRUNTIME_ARCH="arm64"
# fi
# elif [[ "$architecture" == "x86_64" ]]; then
# if [[ "$ONNXRUNTIME_PLATFORM" == "win" ]]; then
# ONNXRUNTIME_ARCH="x64"
# else
# ONNXRUNTIME_ARCH="x86_64"
# fi
# elif [[ "$architecture" == arm* ]]; then
# ONNXRUNTIME_GPU=0
# ONNXRUNTIME_ARCH="arm"
# elif [[ "$architecture" == i*86 ]]; then
# ONNXRUNTIME_GPU=0
# ONNXRUNTIME_ARCH="x86"
# else
# echo "Unsupported architecture: $architecture"
# exit 1
# fi
# # Determine ONNX Runtime path
# if [ "$ONNXRUNTIME_GPU" -eq 1 ]; then
# ONNXRUNTIME_PATH="onnxruntime-${ONNXRUNTIME_PLATFORM}-${ONNXRUNTIME_ARCH}-gpu-${ONNXRUNTIME_VERSION}"
# else
# ONNXRUNTIME_PATH="onnxruntime-${ONNXRUNTIME_PLATFORM}-${ONNXRUNTIME_ARCH}-${ONNXRUNTIME_VERSION}"
# fi
# ONNXRUNTIME_DIR="${CURRENT_DIR}/${ONNXRUNTIME_PATH}"
# # Function to download and extract ONNX Runtime
# download_onnxruntime() {
# local url="https://github.com/microsoft/onnxruntime/releases/download/v${ONNXRUNTIME_VERSION}/${ONNXRUNTIME_PATH}.tgz"
# echo "Downloading ONNX Runtime from $url ..."
# if ! curl -L -O -C - "$url"; then
# echo "Failed to download ONNX Runtime."
# exit 1
# fi
# echo "Extracting ONNX Runtime ..."
# if ! tar -zxvf "${ONNXRUNTIME_PATH}.tgz"; then
# echo "Failed to extract ONNX Runtime."
# exit 1
# fi
# rm -f "${ONNXRUNTIME_PATH}.tgz"
# }
# # Function to build the project
# build_project() {
# local build_type="${1:-Release}"
# local build_dir="${CURRENT_DIR}/build"
# if [ -d "$build_dir" ]; then
# echo "Removing previous build directory ..."
# rm -rf "$build_dir"
# fi
# mkdir -p "$build_dir"
# cd "$build_dir"
# echo "Configuring CMake with build type: $build_type ..."
# cmake .. -D ONNXRUNTIME_DIR="${ONNXRUNTIME_DIR}" -DCMAKE_BUILD_TYPE="$build_type" -DCMAKE_CXX_FLAGS_RELEASE="-O3 -march=native"
# echo "Building project ..."
# cmake --build .
# }
# # Main script execution
# if [ ! -d "$ONNXRUNTIME_DIR" ]; then
# download_onnxruntime
# fi
# build_project "Release"
# echo "Build completed successfully."
#!/bin/bash
CURRENT_DIR=$(cd "$(dirname "$0")"; pwd)
# ONNXRUNTIME_VERSION="1.16.3"
ONNXRUNTIME_VERSION="1.19.2"
ONNXRUNTIME_GPU=0
# 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}"
# Remove previous build directory
if [ -d "${CURRENT_DIR}/build" ]; then
rm -rf build
fi
mkdir build
cd build
echo "Build Code ..."
# cmake .. -D ONNXRUNTIME_DIR="${ONNXRUNTIME_DIR}" -DCMAKE_BUILD_TYPE=Release
# cmake .. -D ONNXRUNTIME_DIR="${ONNXRUNTIME_DIR}" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS_DEBUG="-pg"
# CMake configuration with optimization flags
cmake .. -D ONNXRUNTIME_DIR="${ONNXRUNTIME_DIR}" -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS_RELEASE="-O3 -march=native"
cmake --build .