Skip to main content
This section explains how to manage the DX-M1 accelerator module with command line tools, how to measure its performance and how to run inference using the Python interface.
In order to run the commands in this section, the driver and runtime installation must be completed. You can review the Installation section for the installation steps.

Command Line Tools

The following helper tools are installed together with the DX-RT runtime.

Querying the Device Status

The --status option is used to display the instantaneous temperature, voltage and clock frequency values of the module.
The --info option is used to display the hardware and version information of the module.
The frequently used options of the dxrt-cli tool are listed in the table below. For example, you can use the command below to monitor the device status at 1 second intervals.
The temperature of the module staying at high levels for a long time causes the hardware to lower its clock frequency in order to protect itself and the performance to decrease. Monitoring the temperature values with dxrt-cli --monitor is recommended in applications that you run under heavy workload.

Monitoring the NPU Utilization

You can use the dxtop tool to observe how busy the NPU cores are while your application is running.
The tool displays the utilization ratio, the temperature and the memory consumption for each NPU core in real time. Pressing the q key is enough to exit the application.

Downloading Pre-compiled Models

The NPU can only run models compiled into the .dxnn format. You do not need to compile your own model in order to try the examples in this section; more than three hundred pre-compiled models are provided in the DEEPX model repository (Model Zoo).

Downloading Models

The setup.sh script in the DX-APP repository is used to access the entire model repository and to download models by category. The script places the downloaded files into the assets/models directory. The file names of some frequently used models are listed in the table below.
You can verify that the model you downloaded is valid and runs on the board with the run_model -m ./assets/models/yolov5-s_640x640.dxnn -b command.
The options of the script related to model downloading are listed in the table below.
When the script is run without any option, the category and model selection is made through a menu. The list of available models is kept in the scripts/modelzoo_manifest.json file.
Since the --all option downloads all models in the repository, it requires tens of gigabytes of disk space. Downloading only the models you need with the --models or --category options is recommended.

Measuring Model Performance

The run_model tool is used to measure the real performance of a compiled model on the board.
required
The path of the .dxnn model file to be measured.
Measures in maximum throughput mode. It is the default operating mode.
Measures on a single core, sequentially with a single input.
default:"30"
The number of inference loops to be performed.
The duration of the measurement in seconds. When specified, it overrides the --loops value.
default:"0"
The number of warm-up rounds to be performed before starting the measurement.
Displays the NPU processing time and latency values in detail.
As a result of the command, the NPU processing time, the latency and the frames per second (FPS) values are reported.
To inspect the layer structure, the memory usage and the task distribution on the NPU of a model, you can use the parse_model -m yolov5-s_640x640.dxnn -v command.

Running Inference with Python

The InferenceEngine class in the dx_engine package is used to make use of the NPU in Python applications. The basic flow consists of the steps of loading the model, preparing the input buffer, running the inference and processing the results.
Using np.zeros() while creating the input buffer is not recommended. Since all of the virtual memory pages allocated with np.zeros() point to the same physical page, the PCIe DMA driver produces an EFAULT error when it sees the same physical page more than once. For this reason the buffer must be allocated with np.empty() and filled with fill() as in the example above.

Getting Model Information

The information about the input and output layers can be queried from the runtime so that the pre-processing and post-processing steps can be written correctly.

Asynchronous Inference

In applications that process continuous data such as a video stream, sending a new frame without waiting for the result of the inference increases the performance. The run_async method is used for this purpose. The method returns a job id without waiting for the inference to complete. There are two methods for collecting the results. The results can be delivered automatically by registering a callback function, or the result can be requested by using the wait method with the job id.
These two methods must not be used together. If the results will be collected with the wait method, a callback function must not be registered with register_callback.
Since the callback function is executed in a separate thread, a lock must be used when accessing shared data structures.

Performance Measurement and Device Monitoring

The inference performance can be measured with the run_benchmark method, and the device status can be read from within the application with the DeviceStatus class.
You can access the latency and NPU processing time statistics with the ie.get_latency_mean() and ie.get_npu_inference_time_mean() methods.

C/C++ API

In addition to the Python interface, DX-RT also provides a C and C++ interface. On the C++ side the same workflow is performed with the dxrt::InferenceEngine class.
All examples for the C++ and Python APIs are available in the dx_rt/examples directory of the SDK.