Skip to content

Commit c0ee3e5

Browse files
committed
yolo benchmark suite
1 parent e26ba6f commit c0ee3e5

File tree

4 files changed

+122
-1
lines changed

4 files changed

+122
-1
lines changed

Dockerfile

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
FROM tensorflow/tensorflow:2.1.0-py3
2+
3+
ARG DOCKERVERSION=19.03.12
4+
RUN apt-get update -y --fix-missing && \
5+
apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common && \
6+
apt install -y git wget time && \
7+
apt-get install -y libgl1-mesa-dev && \
8+
apt install -y libsm6 libxrender1 libfontconfig1 && \
9+
pip3 install opencv-python==4.1.0.25 && \
10+
python3 -m pip install opencv-contrib-python && \
11+
python3 -m pip install --upgrade pip && \
12+
python3 -m pip install absl-py && \
13+
git clone https://github.com/whalepark/yolov3-tf2.git /root/yolov3-tf2 && \
14+
wget https://pjreddie.com/media/files/yolov3.weights -P /root/yolov3-tf2/data && \
15+
cd /root/yolov3-tf2/ && \
16+
python3.6 convert.py

README.md

+12-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,12 @@
1-
# yolov3-tf2
1+
# yolov3-tf2 Benchmark
2+
3+
* To build a container image:
4+
```
5+
./build_image.sh
6+
```
7+
8+
9+
* To measure the latencies of the application:
10+
```
11+
./measure_latency.sh [#instances]
12+
```

build_image.sh

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
docker image build --no-cache -t yolo-monolithic .

measure_latency.sh

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
#!/bin/bash
2+
3+
TIMESTAMP=$(date +%Y%m%d-%H:%M:%S)
4+
mkdir -p data
5+
NUMINSTANCE=1
6+
7+
function util_get_running_time() {
8+
local container_name=$1
9+
local start=$(docker inspect --format='{{.State.StartedAt}}' $container_name | xargs date +%s.%N -d)
10+
local end=$(docker inspect --format='{{.State.FinishedAt}}' $container_name | xargs date +%s.%N -d)
11+
local running_time=$(echo $end - $start | tr -d $'\t' | bc)
12+
13+
echo $running_time
14+
}
15+
16+
function measure_latency_monolithic() {
17+
local numinstances=$1
18+
local container_list=()
19+
local rusage_logging_dir=$(realpath data/${TIMESTAMP}-${numinstances}-latency-monolithic)
20+
local rusage_logging_file=tmp-service.log
21+
22+
mkdir -p ${rusage_logging_dir}
23+
init
24+
25+
26+
# 512mb, oom
27+
# 512 + 256 = 768mb, oom
28+
# 1024mb, ok
29+
# 1024 + 256 = 1280mb
30+
# 1024 + 512 = 1536mb
31+
# 1024 + 1024 = 2048mb
32+
docker \
33+
run \
34+
--name yolo-monolithic-0000 \
35+
--memory=1024mb \
36+
--cpus=1.2 \
37+
--workdir='/root/yolov3-tf2' \
38+
yolo-monolithic \
39+
python3.6 detect.py path --image data/street.jpg
40+
41+
running_time=$(util_get_running_time yolo-monolithic-0000)
42+
echo $running_time > "${rusage_logging_dir}"/yolo-monolithic-0000.latency
43+
44+
for i in $(seq 1 $numinstances); do
45+
local index=$(printf "%04d" $i)
46+
local container_name=yolo-monolithic-${index}
47+
48+
docker \
49+
run \
50+
-d \
51+
--name=${container_name} \
52+
--memory=1gb \
53+
--cpus=1.2 \
54+
--workdir='/root/yolov3-tf2' \
55+
yolo-monolithic \
56+
python3.6 detect.py path --image data/street.jpg
57+
sleep 1.5
58+
done
59+
60+
for i in $(seq 1 $numinstances); do
61+
local index=$(printf "%04d" $i)
62+
local container_name=yolo-monolithic-${index}
63+
64+
docker wait "${container_name}"
65+
running_time=$(util_get_running_time "${container_name}")
66+
echo $running_time > "${rusage_logging_dir}"/"${container_name}".latency
67+
echo $running_time
68+
done
69+
70+
local folder=$(realpath data/${TIMESTAMP}-${numinstances}-graph-monolithic)
71+
mkdir -p $folder
72+
for i in $(seq 0 $numinstances); do
73+
local index=$(printf "%04d" $i)
74+
local container_name=yolo-monolithic-${index}
75+
docker logs $container_name 2>&1 | grep "graph_construction_time" > $folder/$container_name.graph
76+
done
77+
78+
folder=$(realpath data/${TIMESTAMP}-${numinstances}-inf-monolithic)
79+
mkdir -p $folder
80+
for i in $(seq 0 $numinstances); do
81+
local index=$(printf "%04d" $i)
82+
local container_name=yolo-monolithic-${index}
83+
docker logs $container_name 2>&1 | grep "inference_time" > $folder/$container_name.inf
84+
done
85+
86+
# For debugging
87+
docker logs -f yolo-monolithic-$(printf "%04d" $numinstances)
88+
}
89+
90+
[[ $# -ge 1 ]] && NUMINSTANCE=$1
91+
measure_latency_monolithic $NUMINSTANCE

0 commit comments

Comments
 (0)