-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_multiple_dnn.py
99 lines (93 loc) · 2.22 KB
/
run_multiple_dnn.py
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
import subprocess
import threading
from datetime import datetime
from pathlib import Path
import time
print("Code started")
avgRun = 1
count = 0
warmUp = 0
iteration = 1000
def process_run(
network_name,
batch,
warmUp,
iteration,
engine,
output_dir,
threadno,
other_network,
TRTEXEC_PATH,
count,
):
dt = datetime.now()
print("iter:", dt)
with open(
output_dir
+ "/"
+ str(network_name)
+ "_"
+ str(other_network)
+ "_"
+ str(threadno)
+ "_results.log",
"w",
) as log_file:
subprocess.run(
[
TRTEXEC_PATH,
"--iterations=" + str(iteration),
"--dumpProfile",
"--batch=" + str(batch),
"--avgRuns=" + str(avgRun),
"--warmUp=" + str(warmUp),
"--duration=0",
f"--loadEngine={engine}",
],
stdout=log_file,
)
# subprocess.run(["nsys","profile","--accelerator-trace=nvmedia","--trace=cuda,opengl,nvtx,nvmedia","--process-scope=system-wide", TRTEXEC_PATH, "--iterations="+str(iteration),"--dumpProfile", "--avgRuns="+str(avgRun), "--warmUp="+str(warmUp), "--duration=0", f"--loadEngine={engine}"], stdout=log_file)
test_network = Path(str("google_only_gpu.plan"))
test_network_2 = Path(str("google_only_dla.plan"))
network_name = test_network.stem
network_name_2 = test_network_2.stem
print("Network1:", network_name)
print("Network2:", network_name_2)
print("--------------------")
batch1 = 1
batch2 = 1
t1 = threading.Thread(
target=process_run,
args=(
network_name,
batch1,
warmUp,
iteration,
"google_only_gpu.plan",
"multi_dnn_execution_logs",
1,
network_name_2,
"tensorrt_sharedMem1/bin/trtexec",
count,
),
)
t2 = threading.Thread(
target=process_run,
args=(
network_name_2,
batch2,
warmUp,
iteration - 2,
"google_only_dla.plan",
"multi_dnn_execution_logs",
2,
network_name,
"tensorrt_sharedMem2/bin/trtexec",
count,
),
)
t1.start()
time.sleep(1)
t2.start()
t1.join()
t2.join()