GPutil not working properly on NVIDIA Jetson Xavier NX

Question:

I’ve written code that collects telemetry information from the device and saves it in a .csv file.

However, I’m not able to detect the GPU from the GPUtil:

import GPUtil

GPU = GPUtil.getAvailable()

print(GPU)
print(GPUtil.__version__)

Output:

[]
1.4.0

I didn’t find information if it has any relation with the type of architecture of Jetson.

Below is some additional system information:

enter image description here

Asked By: whoisraibolt

||

Answers:

After a lot of hard work to come up with some solution, I came to some conclusions that I share here.

Reading a little more about GPUtil and analyzing the GPUtil source code here it becomes clear that:

GPUtil is a Python module for getting the GPU status from NVIDA GPUs using nvidia-smi.

Unfortunately, nvidia-smi does not work on NVIDIA Jetson devices (Xavier NX, Nano, AGX Xavier, TX1, TX2).

As my goal was to fetch telemetry data, there were two options:

  • tegrastats;
  • jetson-stats.

I found tegrastats options quite limited as tegrastats reports memory and processor usage for Tegra based devices, but it would be necessary to create a bash file, for, for example, automate the process.

You can find the tegrastats utility here.

As my goal was to create a Python script to fetch telemetry data together with other libraries, like cputil, the solution adopted was use the jtop from jetson-stats as a Python library.

jetson-stats is a package for monitoring and control your NVIDIA Jetson [Xavier NX, Nano, AGX Xavier, TX1, TX2] and works with all NVIDIA Jetson ecosystem.

jtop is a system monitoring utility that runs on the terminal and see and control realtime the status of your NVIDIA Jetson. CPU, RAM, GPU status and frequency and other.

To use it, was needed to install jetson-stats:

$ sudo -H pip install -U jetson-stats

To use jtop just type in the terminal the command jtop. The prompt interface will be show.

To import jtop as a Python library just write the following line of code in Python script:

from jtop import jtop

And in my specific case I used the following snippet code:

with jtop() as jetson:
    xavier_nx = jetson.stats

    CPU_temperature = xavier_nx['Temp CPU']
    GPU_temperature = xavier_nx['Temp GPU']
    Thermal_temperature = xavier_nx['Temp thermal']

.stats returns a python dict structure, and the available data values are:

time, uptime, jetson_clocks, nvp model, CPU1, CPU2, CPU3, CPU4, CPU5,
CPU6, GPU, MTS FG, MTS BG, RAM, EMC, SWAP, APE, NVENC, NVDEC, NVJPG,
fan, Temp AO, Temp AUX, Temp CPU, Temp GPU, Temp thermal, power cur,
power avg.

Unfortunately jetson-stats doesn’t work with Docker. This can be a negative and important point when thinking about using this service in your application.

Answered By: whoisraibolt

jetson-stats also works in Docker.
Following the documentation: https://rnext.it/jetson_stats/docker.html

  1. Install jetson-stats on your host
  2. Install jetson-stats on your container as well
  3. Pass to your container /run/jtop.sock:/run/jtop.sock

example of Docker

docker run --rm -it -v /run/jtop.sock:/run/jtop.sock rbonghi/jetson_stats:latest

I hope I have helped you

Answered By: Raffaello Bonghi