How to adjust the CPU and GPU frequency dynamically on Jetson TX2 with C/C++?

Is there any C/C++ API can be used to adjust the CPU and GPU frequency dynamically? The only way I can find now is to use the integrated nvpmodel command.

Hi haofu,

cpu/gpu frequency is already adjusted dynamically by driver. nvpmodel is only for changing the power model.

jetson_clock.sh may be the one you want to refer to. It uses some sysfs to change the frequency.

Hi WayneWWW,

Thanks a lot.

Do you mean that CPU/GPU frequency is adjusted automatically by the system driver based on system workloads, and it cannot be controlled by developers or users?

From the introduction of nvpmodel in this website https://www.jetsonhacks.com/2017/03/25/nvpmodel-nvidia-jetson-tx2-development-kit/, different mode are configured with different combinations of CPU and GPU frequency. What’s the meaning of these frequency configurations? Does it mean that the frequency is fixed?

The DVFS tables list a range of allowed clocks. The “nvpmodel” selects that range depending on your requirements for trading off power consumption and performance. The maximum possible performance is with “sudo nvpmodel -m 0”. This allows max performance, but does not cause the system to run at that speed unless it is told to do so.

To set maximum clocks:

sudo ~nvidia/jetson_clocks.sh

If you set maximum clocks when the tables are set to a lower power model, then the clocks will be maxed only for that profile…if you set maximum clocks after using nvpmodel to allow full power consumption (the “-m 0”), then everything will remain at max clock (thermal management can still back off clocks if needed).

Note that “jetson_clocks.sh” is a human-readable bash script. You can see what it does by reading it.