[Tutorial] Check GPU and PCIe versions and matching rates

Please indicate the source for reprinting: Senior Xiaofeng’s Big Bang Theory [xfxuezhang.cn]

PCIe theoretical speed comparison table

bash script

#!/bin/bash

# 查找所有 NVIDIA GPU 设备的设备ID及其类型
device_info=$(lspci | grep -i nvidia | egrep "VGA compatible controller|3D controller" | awk '{print $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20}')

# 通过换行符分隔设备信息并遍历
echo "$device_info" | while IFS= read -r line; do
    id=$(echo $line | awk '{print $1}')
    type=$(echo $line | cut -d ' ' -f 2-)
    # 使用 lspci -n 获取特定设备的硬件信息
    device_info=$(lspci -n | grep -i $id | awk '{print $3}')

    echo "设备编号: $id"
    echo "设备类型: $type"
    echo "设备信息: $device_info"
    # 提取并打印 LnkCap 和 LnkSta 信息
    echo "带宽信息:"
    sudo lspci -n -d $device_info -vvv | grep -i width
    echo
done

running result

Field explanation

  1. Device number 41:00.0. In many cases, a physical device, such as a graphics card, can have multiple functions. For example, a graphics card might have one function for graphics processing (VGA compatible controller) and another function for sound processing (Audio device). These functions are handled as separate devices in the system, but they are actually different parts of the same physical hardware:

    1. 41is the bus number;
    2. 00 is the device number;
    3. 0 Here is the function number, which means this is the first function of the device; if it is 1, it means the second function;
  2. LnkCap (Link Capabilities): This is a summary of the link capabilities supported by this PCI device. It provides information about how the device communicates with other parts of the computer.

  3. Port #0: This refers to the port number the device is connected to. In this case it is port number 0. This is an internal reference used to differentiate between different ports on the same device or on the same motherboard.

  4. Speed ​​16GT/s: This means that the maximum theoretical transfer rate of the link is 16 GigaTransfers per second (GT/s). GT/s is a unit of measurement for PCIe bus speed that measures the rate at which packets are transferred, not the actual data transfer rate. Each packet contains some additional information (such as error detection codes), so the actual data transfer rate will be slightly lower.

  5. Width x16: This indicates that the link is 16 lanes wide. A PCIe link can consist of 1, 2, 4, 8, 12, 16 or 32 lanes, each lane being a serial connection. An x16 link means there are 16 such channels, each capable of independent data transfer, thus increasing overall bandwidth.

  6. ASPM not supported: ASPM stands for Active State Power Management and is an energy-saving mechanism. This means that the device or port does not support ASPM, that is, it cannot dynamically adjust power consumption to save energy based on current usage.

  7. Exit Latency L0s <512ns, L1 <4us: It is one of the power management features of PCIe (Peripheral Component Interconnect Express) devices. It describes the requirements for the device to recover from the low power state (L0s or L1) to the full power state (L0). time.

Guess you like

Origin blog.csdn.net/sxf1061700625/article/details/134986037