Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
simple-yolov3-benchmark
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Weihao KONG
simple-yolov3-benchmark
Commits
5da606c8
Commit
5da606c8
authored
Jul 27, 2021
by
Weihao KONG
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Autorun multiple benchmarks
parent
8154b9bb
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
89 additions
and
2 deletions
+89
-2
.gitignore
+4
-2
run_benchmark.py
+33
-0
run_multiple_benchmarks.py
+52
-0
No files found.
.gitignore
View file @
5da606c8
venv/
venv/
logs/
logs/
*.stdout
*.stdout
*.stderr
*.stderr
\ No newline at end of file
__pycache__
.vscode
\ No newline at end of file
run_benchmark.py
View file @
5da606c8
...
@@ -2,6 +2,7 @@ import subprocess
...
@@ -2,6 +2,7 @@ import subprocess
import
argparse
import
argparse
import
os
import
os
import
sys
import
sys
import
re
parser
=
argparse
.
ArgumentParser
(
description
=
''
)
parser
=
argparse
.
ArgumentParser
(
description
=
''
)
parser
.
add_argument
(
'--gpu'
,
dest
=
'gpu'
,
action
=
'store_true'
,
help
=
'Whether to use GPU for inference'
)
parser
.
add_argument
(
'--gpu'
,
dest
=
'gpu'
,
action
=
'store_true'
,
help
=
'Whether to use GPU for inference'
)
...
@@ -12,6 +13,9 @@ parser.add_argument('--parallelruns',dest='parallelruns',type=int,default=1, hel
...
@@ -12,6 +13,9 @@ parser.add_argument('--parallelruns',dest='parallelruns',type=int,default=1, hel
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
if
not
(
args
.
gpu
or
args
.
dla1
or
args
.
dla2
):
raise
ValueError
(
"No device chosen. Where do you want the benchmark to run?"
)
def
gen_command
(
onnx_path
,
engine_path
,
useDLACore
):
def
gen_command
(
onnx_path
,
engine_path
,
useDLACore
):
onnx_path_arg
=
"--onnx="
+
onnx_path
onnx_path_arg
=
"--onnx="
+
onnx_path
engine_path_arg
=
"--loadEngine="
+
engine_path
engine_path_arg
=
"--loadEngine="
+
engine_path
...
@@ -39,6 +43,23 @@ def gen_command(onnx_path, engine_path, useDLACore):
...
@@ -39,6 +43,23 @@ def gen_command(onnx_path, engine_path, useDLACore):
return
run_command
return
run_command
def
parse_avg_latency
(
fd
):
fd
.
seek
(
0
,
0
)
sum_latency
=
0
nlines
=
0
for
line
in
fd
:
matches
=
re
.
search
(
r"Average\s+on\s+(\d+)\s+runs.*?"
r"GPU\s+latency:\s+((?<!\d|\.)\d+(?:\.\d+)?)\s+.*?"
r"end\s+to\s+end\s+((?<!\d|\.)\d+(?:\.\d+)?)\s+ms"
,
line
)
if
matches
==
None
:
continue
GPU_latency
=
float
(
matches
.
group
(
2
))
sum_latency
+=
GPU_latency
nlines
+=
1
fd
.
seek
(
0
,
0
)
return
sum_latency
/
nlines
processes
=
{
processes
=
{
'gpu'
:[],
'gpu'
:[],
'dla1'
:[],
'dla1'
:[],
...
@@ -128,6 +149,7 @@ for process_list in processes.values():
...
@@ -128,6 +149,7 @@ for process_list in processes.values():
for
p
in
process_list
:
for
p
in
process_list
:
p
.
wait
()
p
.
wait
()
#Print log
for
key
,
file_pair_list
in
logfiles
.
items
():
for
key
,
file_pair_list
in
logfiles
.
items
():
if
file_pair_list
==
[]:
if
file_pair_list
==
[]:
continue
continue
...
@@ -142,6 +164,17 @@ for key,file_pair_list in logfiles.items():
...
@@ -142,6 +164,17 @@ for key,file_pair_list in logfiles.items():
print
(
pair
[
1
]
.
read
(),
file
=
sys
.
stderr
,
end
=
'
\n
'
)
print
(
pair
[
1
]
.
read
(),
file
=
sys
.
stderr
,
end
=
'
\n
'
)
print
(
'-'
*
40
+
'------end------'
+
'-'
*
40
,
file
=
sys
.
stderr
,
end
=
'
\n
'
)
print
(
'-'
*
40
+
'------end------'
+
'-'
*
40
,
file
=
sys
.
stderr
,
end
=
'
\n
'
)
#Get FPS
sum_FPS
=
0
for
key
,
file_pair_list
in
logfiles
.
items
():
if
file_pair_list
==
[]:
continue
for
f_stdout
,
f_stderr
in
file_pair_list
:
sum_FPS
+=
args
.
bs
/
(
parse_avg_latency
(
f_stdout
)
/
1000
)
print
(
"Total FPS: "
,
sum_FPS
)
for
key
,
file_pair_list
in
logfiles
.
items
():
for
key
,
file_pair_list
in
logfiles
.
items
():
if
file_pair_list
==
[]:
if
file_pair_list
==
[]:
continue
continue
...
...
run_multiple_benchmarks.py
0 → 100644
View file @
5da606c8
import
sys
import
subprocess
import
re
def
run_once
(
gpu
,
dla1
,
dla2
,
bs
,
nprocess
):
interpreter
=
sys
.
executable
run_command
=
[
interpreter
]
run_command
+=
[
'run_benchmark.py'
]
if
gpu
:
run_command
+=
[
"--gpu"
]
if
dla1
:
run_command
+=
[
"--dla1"
]
if
dla2
:
run_command
+=
[
"--dla2"
]
run_command
+=
[
"--bs="
+
str
(
bs
)]
run_command
+=
[
"--parallelruns="
+
str
(
nprocess
)]
completed_status
=
subprocess
.
run
(
run_command
,
shell
=
False
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
stdout
=
completed_status
.
stdout
.
decode
(
encoding
=
'utf-8'
)
stderr
=
completed_status
.
stderr
.
decode
(
encoding
=
'utf-8'
)
# if any(char.isalnum() for char in stderr):
# print('-'*20+'STDERR of run \"'+' '.join(run_command)+"\" is not empty!!!"+'-'*20,file=sys.stderr)
# print(stderr,file=sys.stderr)
# print('-'*20+'-'*20,file=sys.stderr)
for
line
in
stdout
.
split
(
'
\n
'
):
if
not
(
'FPS'
in
line
):
continue
pattern
=
r'Total\s+FPS:\s+((?<!\d|\.)\d+(?:\.\d+)?).*?'
FPS
=
float
(
re
.
search
(
pattern
,
line
)
.
group
(
1
))
return
FPS
# s = run_once(gpu=True,dla1=False,dla2=False,bs=16,nprocess=2)
# print(s)
print
(
'Devices,bs,process,fps'
)
for
bs
in
(
1
,
16
):
for
nprocess
in
(
1
,
2
,
4
,
8
,
10
):
FPS
=
run_once
(
gpu
=
True
,
dla1
=
False
,
dla2
=
False
,
bs
=
bs
,
nprocess
=
nprocess
)
print
(
'GPU,{:d},{:d},{:.4f}'
.
format
(
bs
,
nprocess
,
FPS
))
for
device
in
[
'GPU'
,
'GPU+2DLA'
]:
for
bs
in
(
1
,
2
,
4
,
16
):
FPS
=
run_once
(
gpu
=
True
,
dla1
=
bool
(
'2DLA'
in
device
),
dla2
=
bool
(
'2DLA'
in
device
),
bs
=
bs
,
nprocess
=
1
)
print
(
device
+
',{:d},{:d},{:.4f}'
.
format
(
bs
,
1
,
FPS
))
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment