Saturday, October 26, 2024

How to Use nvtop Command to Monitor NVIDIA/AMD/Intel GPU on Linux Server

 The nvtop command is a powerful tool for Linux users who want to monitor the activity of their GPUs, regardless of whether they use NVIDIA, AMD, or Intel graphics cards. It functions similarly to the top or htop commands, providing a comprehensive view of GPU utilization and performance.

Understanding nvtop

nvtop is a ncurses-based interactive GPU status viewer, meaning it displays information in a user-friendly, text-based interface within your terminal. This makes it ideal for monitoring GPU performance without relying on graphical interfaces.

Support for Various GPU Types

nvtop is compatible with a wide range of GPUs, including:

  • AMD GPUs: Utilizing the amdgpu driver.

  • Intel GPUs: Using the i915 Linux driver.

  • NVIDIA GPUs: Supported for GeForce 600, GeForce 800M, and later models using the NVIDIA driver.

  • Adreno GPUs: By Qualcomm.

  • Apple GPUs: M series.

Installing nvtop

Installing nvtop is straightforward. You can follow the steps specific to your Linux distribution:

  • Arch Linux:

          sudo pacman -Syu nvtop
        

  • Gentoo Linux:

    sudo layman -a guru
    sudo emerge -av nvtop
        

  • Ubuntu Impish (21.10), Debian buster (stable), and newer:

    sudo apt update
    sudo apt install nvtop
        

    For Debian 10 and later, ensure you enable the contrib repository in your /etc/apt/sources.list file before installing.

  • Fedora Linux version 36+:

          sudo dnf install nvtop
        

  • CentOS Stream, RHEL, Rocky, and AlmaLinux version 8/9:

    # RHEL 8/9 
    sudo dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-$(rpm -E %{rhel}).noarch.rpm
    sudo dnf install nvtop
    
    # CentOS Stream, Rocky Linux, AlmaLinux 
    sudo dnf install -y epel-release
    sudo dnf install nvtop
        

  • Other Linux Distros:

    snap search nvtop
    sudo snap install nvtop
        

    For enhanced functionality with snap:

    sudo snap connect nvtop:process-control  # Kill GPU processes
    sudo snap connect nvtop:hardware-observe  # Inspect GPU info (Fan, PCIe, Power)
    sudo snap connect nvtop:system-observe    # AMDGPU process list support
    sudo snap connect nvtop:kubernetes-support # Workaround for per-process GPU usage
        

Docker Installation

For Docker users:

git clone https://github.com/Syllo/nvtop.git
cd nvtop
sudo docker build --tag nvtop .
sudo docker run -it --rm --runtime=nvidia --gpus=all --pid=host nvtop
    

Getting Started with nvtop

Once installed, simply run the command:

      nvtop
    

To customize the update interval, use the -d flag:

      nvtop -d 0.25  # Update every 0.25 seconds
    

Disable color output with the -C flag:

      nvtop -C
    

Display a single bar plot for the maximum GPU usage:

      nvtop -p
    

Keyboard Shortcuts

nvtop provides interactive navigation and control:

ShortcutDescription
UpSelect the previous process
DownSelect the next process
Left/RightScroll in the process row
+Sort increasingly
-Sort decreasingly
F2Enter setup utility to modify interface options
F12Save current interface options to persistent storage
F9Send a signal to the selected process
F6Select the field for sorting
F10, q, EscQuit nvtop

Conclusion

The nvtop command offers a comprehensive and user-friendly way to monitor GPU activity on Linux systems. Whether you are a casual user or a developer working with demanding applications, nvtop provides invaluable insight into GPU utilization and performance.

0 comments:

Post a Comment