Skip to content

Commit ca7e206

Browse files
authored
fix setting config for async pipeline (#3936)
* fix setting config for async pipeline * Apply suggestions from code review
1 parent cf5141d commit ca7e206

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

demos/common/python/model_zoo/model_api/pipelines/async_pipeline.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,29 +54,35 @@ def parse_value_per_device(devices: Set[str], values_string: str)-> Dict[str, in
5454

5555

5656
def get_user_config(flags_d: str, flags_nstreams: str, flags_nthreads: int)-> Dict[str, str]:
57+
from openvino import Core, properties
5758
config = {}
5859

5960
devices = set(parse_devices(flags_d))
6061

6162
device_nstreams = parse_value_per_device(devices, flags_nstreams)
63+
core = Core()
6264
for device in devices:
65+
supported_properties = core.get_property(device, properties.supported_properties())
6366
if device == 'CPU': # CPU supports a few special performance-oriented keys
6467
# limit threading for CPU portion of inference
6568
if flags_nthreads:
66-
config['CPU_THREADS_NUM'] = str(flags_nthreads)
67-
68-
config['CPU_BIND_THREAD'] = 'NO'
69-
70-
# for CPU execution, more throughput-oriented execution via streams
71-
config['CPU_THROUGHPUT_STREAMS'] = str(device_nstreams[device]) \
72-
if device in device_nstreams else 'CPU_THROUGHPUT_AUTO'
69+
config[device]['CPU_THREADS_NUM'] = str(flags_nthreads)
70+
71+
config[device]['ENABLE_CPU_PINNING'] = 'NO'
72+
if "CPU_THROUGHPUT_STREAMS" in supported_properties:
73+
# for CPU execution, more throughput-oriented execution via streams
74+
config[device]['CPU_THROUGHPUT_STREAMS'] = str(device_nstreams.get(device, 'CPU_THROUGHPUT_AUTO'))
75+
else:
76+
config[device]["NUM_STREAMS"] = str(device_nstreams.get(device, -1))
7377
elif device == 'GPU':
74-
config['GPU_THROUGHPUT_STREAMS'] = str(device_nstreams[device]) \
75-
if device in device_nstreams else 'GPU_THROUGHPUT_AUTO'
78+
if "GPU_THROUGHPUT_STREAMS" in supported_properties:
79+
config[device]['GPU_THROUGHPUT_STREAMS'] = str(device_nstreams.get(device, 'GPU_THROUGHPUT_AUTO'))
80+
else:
81+
config[device]["NUM_STREAMS"] = str(device_nstreams.get(device, -1))
7682
if 'MULTI' in flags_d and 'CPU' in devices:
7783
# multi-device execution with the CPU + GPU performs best with GPU throttling hint,
7884
# which releases another CPU thread (that is otherwise used by the GPU driver for active polling)
79-
config['GPU_PLUGIN_THROTTLE'] = '1'
85+
config[device]['GPU_PLUGIN_THROTTLE'] = '1'
8086
return config
8187

8288

0 commit comments

Comments
 (0)