Files
openvino/tools/benchmark
80f5fe953b Openvino hybrid awareness (#5261)
* change the deprecated method to the recent

* first ver of the hybrid cores aware CPU streams (+debug info)

* more debug and fixed sum threads

* disabled NUMA pinning to experiment with affinity via OS

* further brushing of stream to core type logic

* hybrid CPU-aware getNumberOfCPUCores

* adding check on the efficiency

* experimental TBB package (that cmake should pull from the internal server)

* iterating over core types in the reversed order (so the big cores are populated first in case user specified less than all #threads)

* adding back the NUMA affinity code-path for the full validation (incl 2 sockets Windows Server)

* cpplint fix and tabbing the #if clauses for the readbility

* pre-production TBB from internal server

* wrapping over #cores/types

* wrapping over #cores/types, ver 2

* wrapping over #streams instead

* disabling warnings as errors for a while (to unlock testing)

* accomodating new TBB layout for dependencies.bat

* next tbb ver (with debug binaries that probably can unlock the commodity builds, without playing product_configs)

* minor brushing for experiments (so that pinning can be disabled)

* minor brushing from code review

* Updating the SHA hash which appeared when rebasing to the master

* WIP refactoring

* Completed refactoring of the "config" phase of the cpu stream executor and on-the-fly streams to core types mapping

* making the benchmark_app aware about new pinning mode

* Brushing a bit (in preparation for the "soft" affinity)

* map to vector to simplify the things

* updated executors comparison

* more fine-grained pinning scheme for the HYBRID (required to allow all cores on 2+8 1+4, and other LITTLE-skewed scenarios)

TODO: seprate little to big ratio for the fp322 and int8 (and pass the fp32Only flag to the MakeDefaultMultiTHreaded)

* separating fp32 and int8 intensive cases for hybrid execution, also leveraging the HT if the #big_cores is small, refactored. also switched to the 2021.2 oneTBB RC package

* code style

* stripped tbb archives from unused folders and files, also has to rename the LICENSE.txt to the LICENSE to match existing OV packaging tools

* assigning nodeId regradless of pinning mode

* tests OpenCV builds with same 2021.2 oneTBB, ubuntu 18/20

* cmake install paths for oneTBB, alos a ie_parallel.cmake warning on older ver of TBB

* Updated latency case desc to cover multi-socket machines

* adding centos8 OCV with oneTBB build

updating TBB drops with hwloc shared libs added.

* enabled internal OCV from THIRD_PARTY_SERVER to test thru CI..
Added Centos7 notbb OCV build (until g-api get ready for onetbb) to unlock the Centos7 CI build

* separate rpath log to respect one-tbb specific paths

* fixed SEQ code-path

* fixed doc misprint

* allowing all cores in 2+8 for int8 as well

* cleaned from debug printfs

* HYBRID_AWARE pinning option for the Python benchmark_app

* OpenVINO Hybrid CPUs support

* Remove custom::task_arena abstraction layout

* Get back to the custom::task_arena interface

* Add windows.h inclusion

* Fix typo in macro name

* Separate TBB and TBBbind packages

* Fix compile-time conditions

* Fix preprocessors conditions

* Fix typo

* Fix linking

* make linking private

* Fix typo

* Fix target_compile_definitions syntax

* Implement CMake install logic, update sha hash for the tbbbind_2_4 package

* Add tbbbind_2_4 required paths to setup_vars

* Update CI paths

* Include ie_parallel.hpp to ie_system_conf.cpp

* Try to update dependencies scripts

* Try to fix dependencies.bat

* Modify dependencies script

* Use static tbbbind_2_4 library

* Remove redundant paths from CI

* Revert "cleaned from debug printfs"

This reverts commit 82c9bd90c5.

# Conflicts:
#	inference-engine/src/inference_engine/os/win/win_system_conf.cpp
#	inference-engine/src/inference_engine/threading/ie_cpu_streams_executor.cpp
#	inference-engine/src/mkldnn_plugin/config.cpp

* Update tbbbind package version

* fixed compilation

* removing the direct tbb::info calls from CPU plugin, to aggregate everything in the single module (that exposes the higher level APIs)

* Update tbbbind package version

(cherry picked from commit f66b8f6aa6)

* compilation fix

* brushing the headers a bit

* Make custom::task_arena inherited from tbb::task_arena

* change to the latest TBB API, and more debug printfs

* code-style

* ARM compilation

* aligned "failed system config" between OV and TBB (by using '-1')

* macos compilation fix

* default arena creation (to make sure all code-path have that fallback)

* Incapsulate all TBB versions related logic inside the custom namespace

* Move custom layer header to internal scope + minor improvements

* with all NUMA/Hybrid checks now consolidated in the custom_arena, cleaning the ugly ifdefs thta we had

* Introduce new ThreadBindingType + fix compilation

* fixing OMP compilation

* OpenVINO Hybrid CPUs support

* Remove custom::task_arena abstraction layout

* Get back to the custom::task_arena interface

* Add windows.h inclusion

* Fix typo in macro name

* Separate TBB and TBBbind packages

* Fix compile-time conditions

* Fix preprocessors conditions

* Fix typo

* Fix linking

* make linking private

* Fix typo

* Fix target_compile_definitions syntax

* Implement CMake install logic, update sha hash for the tbbbind_2_4 package

* Add tbbbind_2_4 required paths to setup_vars

* Update CI paths

* Include ie_parallel.hpp to ie_system_conf.cpp

* Try to update dependencies scripts

* Try to fix dependencies.bat

* Modify dependencies script

* Use static tbbbind_2_4 library

* Remove redundant paths from CI

* Update tbbbind package version

* Make custom::task_arena inherited from tbb::task_arena

* Incapsulate all TBB versions related logic inside the custom namespace

* Move custom layer header to internal scope + minor improvements

* Introduce new ThreadBindingType + fix compilation

* Fix compilation

* Use public tbbbind_2_4 package

* fixed macos build, corrected comments/desc

* reverted to the default binding selection logic ( to preserve the legacy beh)

* OpenVINO Hybrid CPUs support

* Remove custom::task_arena abstraction layout

* Get back to the custom::task_arena interface

* Add windows.h inclusion

* Fix typo in macro name

* Separate TBB and TBBbind packages

* Fix compile-time conditions

* Fix preprocessors conditions

* Fix typo

* Fix linking

* make linking private

* Fix typo

* Fix target_compile_definitions syntax

* Implement CMake install logic, update sha hash for the tbbbind_2_4 package

* Add tbbbind_2_4 required paths to setup_vars

* Update CI paths

* Include ie_parallel.hpp to ie_system_conf.cpp

* Try to update dependencies scripts

* Try to fix dependencies.bat

* Modify dependencies script

* Use static tbbbind_2_4 library

* Remove redundant paths from CI

* Update tbbbind package version

* Make custom::task_arena inherited from tbb::task_arena

* Incapsulate all TBB versions related logic inside the custom namespace

* Move custom layer header to internal scope + minor improvements

* Introduce new ThreadBindingType + fix compilation

* Fix compilation

* Use public tbbbind_2_4 package

* Apply review comments

* Fix compilation without tbbbind_2_4

* Fix compilation with different TBB versions

* code review remarks

* fix for the NONE pinning code-path under HYBRID_AWAR

* whitespace and cleaning the debug printfs (per review)

* code-review comments

* fixed code-style

Co-authored-by: Kochin, Ivan <ivan.kochin@intel.com>
Co-authored-by: Kochin Ivan <kochin.ivan@intel.com>
2021-04-28 17:42:58 +03:00
..
2021-04-28 17:42:58 +03:00
2019-10-04 19:26:43 +03:00

Benchmark Python* Application

This topic demonstrates how to run the Benchmark Application demo, which performs inference using convolutional networks.

How It Works

Upon start-up, the application reads command-line parameters and loads a network and images/binary files to the Inference Engine plugin, which is chosen depending on a specified device. The number of infer requests and execution approach depend on the mode defined with the -api command-line parameter.

Note

: By default, Inference Engine samples and demos expect input with BGR channels order. If you trained your model to work with RGB order, you need to manually rearrange the default channels order in the sample or demo application or reconvert your model using the Model Optimizer tool with --reverse_input_channels argument specified. For more information about the argument, refer to When to Reverse Input Channels section of Converting a Model Using General Conversion Parameters.

Synchronous API

For synchronous mode, the primary metric is latency. The application creates one infer request and executes the Infer method. A number of executions is defined by one of the two values:

  • Number of iterations defined with the -niter command-line argument
  • Time duration specified with the -t command-line argument
  • Both of them (execution will continue until both conditions are met)
  • Predefined duration if -niter and -t are not specified. Predefined duration value depends on device.

During the execution, the application collects two types of metrics:

  • Latency for each infer request executed with Infer method
  • Duration of all executions

Reported latency value is calculated as mean value of all collected latencies. Reported throughput value is a derivative from reported latency and additionally depends on batch size.

Asynchronous API

For asynchronous mode, the primary metric is throughput in frames per second (FPS). The application creates a certain number of infer requests and executes the StartAsync method. A number of executions is defined by one of the two values:

  • Number of iterations defined with the -niter command-line argument
  • Time duration specified with the -t command-line argument
  • Both of them (execution will continue until both conditions are met)
  • Predefined duration if -niter and -t are not specified. Predefined duration value depends on device.

The infer requests are executed asynchronously. Callback is used to wait for previous execution to complete. The application measures all infer requests executions and reports the throughput metric based on batch size and total execution duration.

Running

Before running the Benchmark tool, install the requirements:

pip install -r  requirements.txt

Notice that the benchmark_app usually produces optimal performance for any device out of the box.

So in most cases you don't need to play the app options explicitly and the plain device name is enough, e.g.:

$benchmark_app -m <model> -i <input> -d CPU

But it is still may be non-optimal for some cases, especially for very small networks. More details can read in Introduction to Performance Topics.

Running the application with the -h or --help' option yields the following usage message:

usage: benchmark_app.py [-h] [-i PATH_TO_INPUT] -m PATH_TO_MODEL
                        [-d TARGET_DEVICE]
                        [-l PATH_TO_EXTENSION] [-c PATH_TO_CLDNN_CONFIG]
                        [-api {sync,async}] [-niter NUMBER_ITERATIONS]
                        [-b BATCH_SIZE]
                        [-stream_output [STREAM_OUTPUT]] [-t TIME]
                        [-progress [PROGRESS]] [-nstreams NUMBER_STREAMS]
                        [-nthreads NUMBER_THREADS] [-pin {YES,NO}]
                        [--exec_graph_path EXEC_GRAPH_PATH]
                        [-pc [PERF_COUNTS]]

Options:
  -h, --help            Show this help message and exit.
  -i PATHS_TO_INPUT [PATHS_TO_INPUT ...], --paths_to_input PATHS_TO_INPUT [PATHS_TO_INPUT ...]
                        Optional. Path to a folder with images and/or binaries
                        or to specific image or binary file.
  -m PATH_TO_MODEL, --path_to_model PATH_TO_MODEL
                        Required. Path to an .xml file with a trained model.
  -d TARGET_DEVICE, --target_device TARGET_DEVICE
                        Optional. Specify a target device to infer on (the
                        list of available devices is shown below). Default
                        value is CPU. Use '-d HETERO:<comma separated devices
                        list>' format to specify HETERO plugin. Use '-d
                        MULTI:<comma separated devices list>' format to
                        specify MULTI plugin. The application looks for a
                        suitable plugin for the specified device.
  -l PATH_TO_EXTENSION, --path_to_extension PATH_TO_EXTENSION
                        Optional. Required for CPU custom layers. Absolute
                        path to a shared library with the kernels
                        implementations.
  -c PATH_TO_CLDNN_CONFIG, --path_to_cldnn_config PATH_TO_CLDNN_CONFIG
                        Optional. Required for GPU custom kernels. Absolute
                        path to an .xml file with the kernels description.
  -api {sync,async}, --api_type {sync,async}
                        Optional. Enable using sync/async API. Default value
                        is async.
  -niter NUMBER_ITERATIONS, --number_iterations NUMBER_ITERATIONS
                        Optional. Number of iterations. If not specified, the
                        number of iterations is calculated depending on a
                        device.
  -b BATCH_SIZE, --batch_size BATCH_SIZE
                        Optional. Batch size value. If not specified, the
                        batch size value is determined from IR
  -stream_output [STREAM_OUTPUT]
                        Optional. Print progress as a plain text. When
                        specified, an interactive progress bar is replaced
                        with a multiline output.
  -t TIME, --time TIME  Optional. Time in seconds to execute topology.
  -progress [PROGRESS]  Optional. Show progress bar (can affect performance
                        measurement). Default values is "False".
  -shape SHAPE          Optional. Set shape for input. For example,
                        "input1[1,3,224,224],input2[1,4]" or "[1,3,224,224]"
                        in case of one input size.
  -layout LAYOUT        Optional. Prompts how network layouts should be
                        treated by application. For example,
                        "input1[NCHW],input2[NC]" or "[NCHW]" in case of one
                        input size.
  -nstreams NUMBER_STREAMS, --number_streams NUMBER_STREAMS
                        Optional. Number of streams to use for inference on the CPU/GPU/MYRIAD
                        (for HETERO and MULTI device cases use format <device1>:<nstreams1>,<device2>:<nstreams2> or just <nstreams>).
                        Default value is determined automatically for a device.
                        Please note that although the automatic selection usually provides a reasonable performance,
                        it still may be non-optimal for some cases, especially for very small networks.
                        Also, using nstreams>1 is inherently throughput-oriented option, while for the best-latency
                        estimations the number of streams should be set to 1.
  -enforcebf16 [{true,false}], --enforce_bfloat16 [{true,false}]
                        Optional. By default floating point operations execution in bfloat16 precision are enforced if supported by platform.
                        'true'  - enable  bfloat16 regardless of platform support
                        'false' - disable bfloat16 regardless of platform support.
  -nthreads NUMBER_THREADS, --number_threads NUMBER_THREADS
                        Number of threads to use for inference on the CPU
                        (including HETERO  and MULTI cases).
  -pin {YES,NO,NUMA}, --infer_threads_pinning {YES,NO,NUMA}
                        Optional. Enable threads->cores ('YES' is default
                        value), threads->(NUMA)nodes ('NUMA') or completely
                        disable ('NO')CPU threads pinning for CPU-involved
                        inference.
  --exec_graph_path EXEC_GRAPH_PATH
                        Optional. Path to a file where to store executable
                        graph information serialized.
  -pc [PERF_COUNTS], --perf_counts [PERF_COUNTS]
                        Optional. Report performance counters.
  -dump_config DUMP_CONFIG
                        Optional. Path to JSON file to dump IE parameters,
                        which were set by application.
  -load_config LOAD_CONFIG
                        Optional. Path to JSON file to load custom IE
                        parameters. Please note, command line parameters have
                        higher priority then parameters from configuration
                        file.

Running the application with the empty list of options yields the usage message given above and an error message.

Application supports topologies with one or more inputs. If a topology is not data sensitive, you can skip the input parameter. In this case, inputs are filled with random values. If a model has only image input(s), please a provide folder with images or a path to an image as input. If a model has some specific input(s) (not images), please prepare a binary file(s), which is filled with data of appropriate precision and provide a path to them as input. If a model has mixed input types, input folder should contain all required files. Image inputs are filled with image files one by one. Binary inputs are filled with binary inputs one by one.

To run the tool, you can use [public](@ref omz_models_group_public) or [Intel's](@ref omz_models_group_intel) pre-trained models from the Open Model Zoo. The models can be downloaded using the [Model Downloader](@ref omz_tools_downloader).

Note

: Before running the demo with a trained model, make sure the model is converted to the Inference Engine format (*.xml + *.bin) using the Model Optimizer tool.

For example, to do inference of an image using a trained network with multiple outputs on CPU, run the following command:

python3 benchmark_app.py -i <path_to_image>/inputImage.bmp -m <path_to_model>/multiple-output.xml -d CPU

Demo Output

The application outputs number of executed iterations, total duration of execution, latency and throughput. Additionally, if you set the -pc parameter, the application outputs performance counters. If you set -exec_graph_path, the application reports executable graph information serialized.

[Step 8/9] Measuring performance (Start inference asynchronously, 60000 ms duration, 4 inference requests in parallel using 4 streams)
Progress: |................................| 100.00%

[Step 9/9] Dumping statistics report
Progress: |................................| 100.00%

Count:      4408 iterations
Duration:   60153.52 ms
Latency:    51.8244 ms
Throughput: 73.28 FPS

See Also