Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend HW image decoder bench script to support multiple GPUs #5065

Merged
merged 1 commit into from
Sep 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Comment on lines +24 to +25
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recall some issue that device_ids do not have to be consecutive (I might be wrong though). How about providing a list of devices instead? Something along the lines:

Suggested change
parser.add_argument('-n', dest='gpu_num',
help='Number of GPUs used starting from device_id', default=1, type=int)
parser.add_argument('-d', dest='device_id', help='device_id', default=0, nargs='*')

And the usage would be:

python hw_decoder_bench.py -d 1 3 -b ...
python hw_decoder_bench.py -d 0 -b ...
    for di in range(args.device_id):
        pipes.append(DecoderPipeline(device_id=di))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The numbers are consecutive, but the order may differ from the PCI order.
I rather imagine this script to be used to test on heterogenous systems and the user will just decide how many GPUs is willing to use.

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')