Detailed explanation of monitoring NVIDIA GPU usage under Linux

Detailed explanation of monitoring NVIDIA GPU usage under Linux

When using TensorFlow for deep learning, insufficient video memory often occurs, so we hope to be able to check the GPU usage at any time. If you have an Nvidia GPU, you can do it with just one line of command on the command line.

1. Display current GPU usage

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

$ nvidia-smi

Output:

nvidia-smi

2. Periodically output GPU usage

But sometimes we want to know not only the GPU usage at a fixed moment, but also its trend. In this case, we want to output it periodically, such as updating the display every 10 seconds. At this time, you need to use the watch command to periodically execute the nvidia-smi command.

Understand 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 parameter is -n, which specifies how many seconds to execute the command.

Monitor video memory: We set it to display the video memory status every 10 seconds:

$ watch -n 10 nvidia-smi

The display is as follows:

watch -n 10 nvidia-smi

In this way, as long as the command line window is open, you can refresh it every ten seconds. Isn’t it convenient?

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

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Tutorial on Building a Linux GPU Server on CentOS 7

<<:  Summary of Mysql common benchmark commands

>>:  How to calculate the frame rate FPS of web animations

Recommend

Example explanation of alarm function in Linux

Introduction to Linux alarm function Above code: ...

HTML css js implements Tab page sample code

Copy code The code is as follows: <html xmlns=...

Pure HTML and CSS to achieve JD carousel effect

The JD carousel was implemented using pure HTML a...

MySQL configuration SSL master-slave replication

MySQL5.6 How to create SSL files Official documen...

How to rename the table in MySQL and what to pay attention to

Table of contents 1. Rename table method 2. Notes...

Example of using mycat to implement MySQL database read-write separation

What is MyCAT A completely open source large data...

Detailed explanation of Angular component projection

Table of contents Overview 1. Simple Example 1. U...

CentOS 8 installation diagram (super detailed tutorial)

CentOS 8 is officially released! CentOS fully com...

Full analysis of Vue diff algorithm

Table of contents Preface Vue update view patch s...

3 common errors in reading MySQL Binlog logs

1. mysqlbinlog: [ERROR] unknown variable 'def...

Example code for implementing div concave corner style with css

In normal development, we usually use convex roun...

Practical record of handling MySQL automatic shutdown problems

I recently helped someone with a project and the ...

SQL query for users who have placed orders for at least seven consecutive days

Create a table create table order(id varchar(10),...