Check GPU graphics card/CPU memory/hard disk information on Linux

Graphics card information command/CPU memory/hard disk

1. Graphics card

nvidia-smi
nvidia-smi (display the current GPU usage once)
nvidia-smi -l (refresh and display once every second)
watch -n 5 nvidia-smi (where 5 means refreshing the terminal display results every 6 seconds)

Table header explanation:
Fan: Displays the fan speed, the value is between 0 and 100%, which is the expected speed of the computer. If the computer is not cooled by the fan or the fan is broken, the display is N/A; Temp: The temperature inside the graphics card
, The unit is degrees Celsius;
Perf: represents the performance status, from P0 to P12, P0 represents the maximum performance, and P12 represents the minimum performance of the state;
Pwr: energy consumption representation;
Bus-Id: related information involving the GPU bus;
Disp.A: is Display Active means, indicating whether the GPU display is initialized;
Memory Usage: video memory usage;
Volatile GPU-Util: floating GPU utilization;
Compute M: calculation mode;
Processes below shows the video memory used by each process on each GPU Condition.
Insert image description here
Insert image description here

GPU: Number
Fan: Fan speed, changes between 0 and 100%, here is 42%
Name: Graphics card name, here is TITAN X
Temp: Graphics card temperature, here is 69 degrees Celsius
Perf: Performance status, from P0 to P12, P0 Maximum performance, P12 minimum
Persistence-M: Status switch of persistence mode. This mode consumes a lot of energy, but it is faster to start a new GPU application. Here is off
Pwr: Energy consumption
Bus-Id: Things involving the GPU bus
Disp.A: Indicates whether the GPU display is initialized
Memory-Usage: Existing usage, it is almost full
GPU-Util: GPU utilization
Compute M.: Computing mode

For reference, check the Linux server memory, CPU, graphics card, and hard disk usage, link: https://www.jianshu.com/p/0aed4feba213
https://www.cnblogs.com/wsnan/p/11769838.html

  • CUDA version
    1. Check the currently installed version (nvcc -V)
    that comes with the system: Use the nvcc (NVIDIA Cuda compiler driver) command to check the CUDA version installed on this machine: nvcc -V
    nvcc -V checks the cuda that comes with the system. version of.
    In the virtual environment: To check the version in the virtual environment, check the pip package or import the pytorch and tensorflow libraries for testing pytorch中:print(torch.__version__)和tensorflow中:conda list | grep cuda直接在终端里,打开相应环境,进行查看
    2. Check the highest supported CUDA version (nvidia-smi).
    Use the nvidia-smi command to check the Nvidia graphics card of the machine. Driver information, and the highest CUDA version supported by the driver. nvidia-smi, for example, the CUDA Version below is the highest version of CUDA that can be installed on my computer, and this version number is downwardly supported, and all CUDA packages lower than this version number can be installed.

Release graphics card memory
When running code in Ubuntu, sometimes the code exits and the graphics memory is still occupied.

1#批量清理显卡中残留进程:(批量包含其他信息时不行,要用/dev/nvidia*设置成指定哪个进行批量kill如:/dev/nvidia0)
sudo fuser -v /dev/nvidia* |awk '{for(i=1;i<=NF;i++)print "kill -9 " $i;}' | sudo sh

#或
lsof /dev/nvidia* | awk '{print $2}' | xargs -I {
    
    } kill {
    
    }

#或
fuser -v /dev/nvidia* | awk '{print $0}' |  xargs kill -9

2、手动
apt-get install psmisc
#查找占用GPU资源的PID
fuser -v /dev/nvidia*
# 解除显存占用
kill -9 ***(PID)  

2. CPU memory

  1. Check cup usage, memory
    (1) top
    (2) htop
    $ sudo apt-get install htop
    $ htop
    (3) free command The free
    command can display the free, used physical memory and swap memory in the Linux system, and the kernel The buffer used. Among Linux system monitoring tools, the free command is one of the most frequently used commands.

3. Hard drive

(1) df command
(2) df -h command, the direct execution of df command is not good, and the disk capacity cannot be displayed in the form of mb or gb. In order to display it in a humanized manner, you can add the -h parameter at the end. h is the first letter of human-reading, which can be understood as a format that can be read by humans.
(3) View partition: sudo fdisk -l

Guess you like

Origin blog.csdn.net/weixin_44986037/article/details/132253995