Skip to content

Commit

Permalink
Extend HW image decoder bench script to support multiple GPUs (#5065)
Browse files Browse the repository at this point in the history
- adds an ability to run multiple data processing pipelines on
  multiple GPUs inside HW image decoder bench script

Signed-off-by: Janusz Lisiecki <jlisiecki@nvidia.com>
  • Loading branch information
JanuszL committed Sep 28, 2023
1 parent 02b195e commit 5fd490d
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions tools/hw_decoder_bench.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
parser = argparse.ArgumentParser(description='DALI HW decoder benchmark')
parser.add_argument('-b', dest='batch_size', help='batch size', default=1, type=int)
parser.add_argument('-d', dest='device_id', help='device id', default=0, type=int)
parser.add_argument('-n', dest='gpu_num',
help='Number of GPUs used starting from device_id', default=1, type=int)
parser.add_argument('-g', dest='device', choices=['gpu', 'cpu'],
help='device to use', default='gpu',
type=str)
Expand All @@ -31,8 +33,8 @@
parser.add_argument('-p', dest='pipeline', choices=['decoder', 'rn50'],
help='pipeline to test', default='decoder',
type=str)
parser.add_argument('--width_hint', dest="width_hint", default=0, type=int)
parser.add_argument('--height_hint', dest="height_hint", default=0, type=int)
parser.add_argument('--width_hint', dest='width_hint', default=0, type=int)
parser.add_argument('--height_hint', dest='height_hint', default=0, type=int)
parser.add_argument('--hw_load', dest='hw_load',
help='HW decoder workload (e.g. 0.66 means 66% of the batch)', default=0.75,
type=float)
Expand Down Expand Up @@ -78,25 +80,39 @@ def RN50Pipeline():
return images


pipes = []
if args.pipeline == 'decoder':
pipe = DecoderPipeline()
for i in range(args.gpu_num):
pipes.append(DecoderPipeline(device_id=i+args.device_id))
elif args.pipeline == 'rn50':
pipe = RN50Pipeline()
for i in range(args.gpu_num):
pipes.append(RN50Pipeline(device_id=i+args.device_id))
else:
raise RuntimeError('Unsupported pipeline')
pipe.build()
for p in pipes:
p.build()

for iteration in range(args.warmup_iterations):
output = pipe.run()
for p in pipes:
p.schedule_run()
for p in pipes:
_ = p.share_outputs()
for p in pipes:
p.release_outputs()
print('Warmup finished')

start = time.time()
test_iterations = args.total_images // args.batch_size

print('Test iterations: ', test_iterations)
for iteration in range(test_iterations):
output = pipe.run()
for p in pipes:
p.schedule_run()
for p in pipes:
_ = p.share_outputs()
for p in pipes:
p.release_outputs()
end = time.time()
total_time = end - start

print(test_iterations * args.batch_size / total_time, 'fps')
print(test_iterations * args.batch_size * args.gpu_num / total_time, 'fps')

0 comments on commit 5fd490d

Please sign in to comment.