Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to monitor the GPU usage of NVIDIA in Linux

Shulou Source: shulou.com Published: 2022-06-01 20:04:38 10月31日 Update

This article will explain in detail how to monitor the GPU usage of NVIDIA in Linux. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

When using TensorFlow to run deep learning, there is often insufficient memory, so we want to be able to check the usage of GPU at any time. If you are the GPU of Nvidia, you only need one command from the command line.

1. Show current GPU usage

Nvidia comes with a command line tool for nvidia-smi, which displays the usage of video memory:

$nvidia-smi

Output:

two。 Periodically output GPU usage

But sometimes we want not only to know the GPU usage at that fixed time, but also to keep abreast of its trends, and then we want to output periodically, such as updating the display every 10 seconds. At this point, you need to use the watch command to execute the nvidia-smi command periodically.

Learn about the functions of watch:

$whatis watch watch (1)-execute a program periodically, showing output fullscreen

Function: execute a command periodically and display the output.

The basic usage of watch is:

$watch [options] command

The most commonly used argument is-n, which specifies how many seconds to execute the command.

Monitor video memory: we set it to display video memory every 10 seconds:

$watch-n 10 nvidia-smi

The display is as follows:

In this way, as long as the command line window is open, it can be refreshed every ten seconds, isn't it convenient?

If we want to periodically perform other command line operations, then we can simply change the following nvidia-smi, So Cool!

This is the end of this article on "how to monitor the GPU usage of NVIDIA in Linux". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Tags: Situation command cycle periodicity video memory output monitoring article more good practical one line function utilization content function trends parameters tools commonly used Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Linux Docker Apple MySQL