JetsonHacks

Developing on NVIDIA® Jetson™ for AI on the Edge

GPU Activity Monitor – NVIDIA Jetson TX Dev Kit

Sometimes you just want to see how hard the GPU is working. Enter the GPU Activity Monitor. Looky here:

Background

Traditionally if you want to see how busy a Linux system is, you can use a graphical tool like System Monitor. The CPU, memory and networking and a wide variety of other good innards are on display. However, one thing that is missing is GPU utilization.

Most developers use the tegrastats tool to get a feel for GPU utilization, which reports as a percentage of maximum. This prints with a large number of other system parameters every second. For my particular use case, I am only interested in a graph of how the GPU is being utilized over time.

Simple Stupid Good

After fiddling around a little bit, I figured out how to get the GPU utilization and wrote a simple Python script to graph utilization against time. Similar to the way that System Monitor works, the graph shows utilization over a 60 second interval.

This is a dead simple implementation, rather brute force. It would have been nice if I knew Python, but hey! The Python script utilizes the Matplotlib library. You can use the script with Python 2 or Python 3.

Installation

The graph is implemented as an animated Python Matplotlib graph. The first step is to install the appropriate Matplotlib library.

For Python 2.7, Matplotlib may be installed as follows:

$ sudo apt-get install python-matplotlib

For Python 3, Matplotlib may be installed as follows:

$ sudo apt-get install python3-matplotlib

Next, on the JetsonHacks account on Github there is a repository named gpuGraphTX. Clone the repository

$ git clone https://github.com/jetsonhacks/gpuGraphTX

and switch over to the repository’s directory:

$ cd gpuGraphTX

The Fun Part, Run the Script

You can run the app:

$ ./gpuGraph.py

or:

$ python gpuGraph.py

or:

$ python3 gpuGraph.py

After a little time spent loading fonts, the graph appears:

GPU Activity Monitor
GPU Activity Monitor

You can resize the window to get a better view of the activity, as well as use the toolbar to do actions like zoom in on any given section or save the graph to a file.

Notes

In the video, the script was installed on a Jetson TX2 directly after flashing L4T 28.2 using JetPack 3.2. The script has been tested with both the Jetson TX1 and Jetson TX2, and using Python 2.7 and Python 3.5.

Facebook
Twitter
LinkedIn
Reddit
Email
Print

4 Responses

  1. Some of you may get this error:
    NotImplementedError: Surface.create_for_data: Not Implemented yet.

    Using the GTK3 backend with Python3 requires that you use cairocffi instead of py3cairo. py3cairo does not implement Surface.create_for_data

    The fix:
    sudo apt-get install python3-cairocffi

  2. I have installed JetPack 3.3 and I get the following error:

    ”’
    Traceback (most recent call last):
    File “/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_gtk3.py”, line 289, in idle_draw
    self.draw()
    File “/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_gtk3.py”, line 282, in draw
    self.get_property(“window”).process_updates (False)
    TypeError: Couldn’t find foreign struct converter for ‘cairo.Context’
    ”’

    Can you help me?

    1. Thanks Michael,

      Indeed, for my JetPack 3.3 I needed to install the package from this thread you posted.
      To make it simpler to readers, the command is:
      $sudo apt-get install python-gi-cairo

      Take care!

Leave a Reply

Your email address will not be published. Required fields are marked *

Disclaimer

Some links here are affiliate links. If you purchase through these links I will receive a small commission at no additional cost to you. As an Amazon Associate, I earn from qualifying purchases.

Books, Ideas & Other Curiosities