最近使用 AI Server 時發現訓練模型的 DataLoader 很慢,於是我測試 GPU Server 的 PCIe 傳輸效能時,發現一個奇怪的現象:雖然主機板與 CPU 都標榜支援 PCIe Gen4 x16,但實際測試 Host to Device (H2D) 帶寬卻只有 Gen1 水準 (0.5 GB/s)。想請教大家可能的原因與解決方式。
CUDA Samples v12.4 (NVIDIA/cuda-samples)
使用 lspci 檢查
傳輸閒置時:在待機給最低 Gen1 速度合理
LnkCap: Port #0, Speed 16GT/s, Width x16
LnkSta: Speed 2.5GT/s (downgraded), Width x16 (ok)
傳輸中:有提升至 Gen4x16 也合理
LnkCap: Port #0, Speed 16GT/s, Width x16
LnkSta: Speed 16GT/s (ok), Width x16 (ok)
CUDA bandwidthTest (pinned memory)
我是透過 Github 上 NVIDIA/cuda-samples Releases v12.4 版本測試
使用指令為:
./Samples/1_Utilities/bandwidthTest/bandwidthTest --memory=pinned --device=4
輸出結果: 以 Device 發起的傳輸速度都正常,從 CPU 提供的傳輸 (H2D) 受到限制 (Gen1),很不合理
Host to Device Bandwidth: 0.5 GB/s
Device to Host Bandwidth: 26.3 GB/s
Device to Device Bandwidth: 720.9 GB/s
拓樸 (nvidia-smi topo -m)
這邊單純做一個觀察: 其中 A6000 有使用 NVLink
GPU0 GPU1 GPU2 GPU3 CPU Affinity NUMA Affinity
GPU0 X SYS SYS SYS 0-23 0
GPU1 SYS X NV4 SYS 0-23 0
GPU2 SYS NV4 X SYS 0-23 0
GPU3 SYS SYS SYS X 0-23 0
PCI 流程 以最後一張 3090 為例
(base) louis900412@server:~$ lspci -tv | egrep -i 'NVIDIA|09a2'
+-[0000:c2]-+-00.0 Intel Corporation Device 09a2
| \-02.0-[c3]--+-00.0 NVIDIA Corporation GA102 [GeForce RTX 3090]
| \-00.1 NVIDIA Corporation GA102 High Definition Audio Controller
+-[0000:89]-+-00.0 Intel Corporation Device 09a2
| \-02.0-[8a]--+-00.0 NVIDIA Corporation GA102GL [RTX A6000]
| \-00.1 NVIDIA Corporation GA102 High Definition Audio Controller
+-[0000:50]-+-00.0 Intel Corporation Device 09a2
| \-02.0-[51]--+-00.0 NVIDIA Corporation GA102GL [RTX A6000]
| \-00.1 NVIDIA Corporation GA102 High Definition Audio Controller
+-[0000:17]-+-00.0 Intel Corporation Device 09a2
| \-02.0-[18]--+-00.0 NVIDIA Corporation GA102 [GeForce RTX 3090]
| \-00.1 NVIDIA Corporation GA102 High Definition Audio Controller
\-[0000:00]-+-00.0 Intel Corporation Device 09a2
最高傳輸寬帶 Max Payload Size (MPS) / Max Read Request Size (MRRS)
觀察到即使 17:02.0, 18:00.0 都給到 256 bytes,但 17:00.0 也只有 128 bytes,這部分也是納悶,因為我在 BIOS 中都將 MPS/MRRS 設定為最高 512 與 4096。
sudo lspci -vv -s 17:00.0 | egrep -i 'DevCtl|MaxPayload|MaxReadReq'
DevCap: MaxPayload 128 bytes, PhantFunc 0
DevCtl: CorrErr- NonFatalErr- FatalErr- UnsupReq-
MaxPayload 128 bytes, MaxReadReq 128 bytes
DevCtl2: Completion Timeout: 50us to 50ms, TimeoutDis- LTR- OBFF Disabled,
sudo lspci -vv -s 17:02.0 | egrep -i 'DevCtl|MaxPayload|MaxReadReq'
DevCap: MaxPayload 256 bytes, PhantFunc 0
DevCtl: CorrErr- NonFatalErr- FatalErr+ UnsupReq-
MaxPayload 256 bytes, MaxReadReq 256 bytes
DevCtl2: Completion Timeout: 260ms to 900ms, TimeoutDis- LTR- OBFF Disabled, ARIFwd-
sudo lspci -vv -s 18:00.0 | egrep -i 'DevCtl|MaxPayload|MaxReadReq'
DevCap: MaxPayload 256 bytes, PhantFunc 0, Latency L0s unlimited, L1 <64us
DevCtl: CorrErr- NonFatalErr- FatalErr+ UnsupReq-
MaxPayload 256 bytes, MaxReadReq 256 bytes
DevCtl2: Completion Timeout: 50us to 50ms, TimeoutDis- LTR- OBFF Disabled,
似乎修改 BIOS 中 Max Payload Size (MPS) / Max Read Request Size (MRRS) 於 lspci 中不起作用,D2H 速度有 Gen4 水準,而 H2D 只有 Gen1 速度,不太清楚哪邊沒有設定好,我有嘗試 BIOS: Restore Optimized Defaults
還是一樣... 我認為問題出在 MPS 與 MRRS 設定不被 CPU 准許,可能有所住。
PCIe 速度對照表。