nvidia-uvm: first `UVM_REGISTER_GPU` holds `g_uvm_global.global_lock` for the whole `add_gpu()` setup, so concurrent `cuInit` in N processes on N different GPUs is serialized (~4.5 s on an 8x B200 node)
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 32/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- c, linux
調査の方向性
Start with kernel-open/nvidia-uvm/uvm_gpu.c, tracing uvm_gpu_retain_by_uuid(), gpu_retain_by_uuid_locked(), and add_gpu() to understand the global lock and GPU registration path. The report also identifies NV_ESC_RM_CONTROL calls whose serialization is unexplained, so read those paths alongside registration before deciding the scope. Profile both phases with the supplied concurrent cuInit reproducer; done means concurrent initialization on distinct GPUs no longer queues behind node-wide setup and the reported timings improve.
索引モデルが issue の本文から書いたものです。
説明
NVIDIA Open GPU Kernel Modules Version
580.126.09
Please confirm this issue does not happen with the proprietary driver (of the same version). This issue tracker is only for bugs specific to the open kernel driver.
- I confirm that this does not happen with the proprietary driver package.
Operating System and Version
Red Hat Enterprise Linux 9.4 (Plow)
Kernel Release
5.14.0-427.42.1.el9_4.x86_64
Please confirm you are running a stable release kernel (e.g. not a -rc). We do not accept bug reports for unreleased kernels.
- I am running on a stable kernel release.
Hardware: GPU
GPU 0: NVIDIA B200 (UUID: GPU-994d3962-dcb4-09b7-7863-81cc07c000f3) GPU 1: NVIDIA B200 (UUID: GPU-c3af7f06-77cc-298c-6878-4ffc853f901b) GPU 2: NVIDIA B200 (UUID: GPU-64247ee0-418d-d3c4-2072-035e59c1c3a4) GPU 3: NVIDIA B200 (UUID: GPU-5e6ac0f2-b02a-0d5e-94c8-67ad751595d6) GPU 4: NVIDIA B200 (UUID: GPU-d3810e9e-4606-a71c-0dc1-a05f1fadc8ec) GPU 5: NVIDIA B200 (UUID: GPU-b339c54a-6988-65ab-71db-350d4caf2a0d) GPU 6: NVIDIA B200 (UUID: GPU-c6306ffb-cdb8-d304-39af-56fcad864308) GPU 7: NVIDIA B200 (UUID: GPU-495ca190-a4b9-02bc-9060-4f547e013f0b)
Describe the bug
Summary
On an 8x B200 node, 8 processes that each start CUDA on their own, distinct GPU at the same time are served one after another inside the UVM driver. Each process's first cuInit sends UVM_REGISTER_GPU (ioctl nr 37 / 0x25 on
/dev/nvidia-uvm). That call's duration is staggered across the processes: 0.33, 0.44, 0.80, 1.74, 2.07, 2.57, 3.45, 4.44 s. The slowest is ~8 x the single-process cost. The processes don't share a GPU, so the serialization is node-wide, not per GPU.
This hits every MPI job that runs one rank per GPU: Open MPI's MPI_Init ends in a fence, so every rank waits for the last one in the driver queue. On our 8x B200 nodes MPI_Init takes ~7 s for 8 ranks/node vs ~1.2 s for 1 rank/node, and it grows by ~0.7-0.9 s per additional rank on the same node.
Environment
- GPUs: 8x NVIDIA B200 (183359 MiB each), one node
- Driver: 580.126.09, open kernel module (
Dual MIT/GPL) nvidia-smi -q: Persistence Mode = Enabled, Addressing Mode = HMMnvidia_uvmparameters:uvm_disable_hmm=N,uvm_ats_mode=1, rest default- Kernel: 5.14.0-427.42.1.el9_4.x86_64 (RHEL 9.4)
- CUDA: 12.9 (libcudart 12.9.79)
- Slurm with cgroup GPU binding: each process can open only its own
/dev/nvidiaN(all other/dev/nvidia*GPU nodes returnEPERM), so each
process sees exactly one, distinct GPU.
Evidence (strace -f -k -y, 8 processes, one GPU each)
Every process blocks in the same ioctl, issued from cuInit:
ioctl(20</dev/nvidia-uvm>, _IOC(_IOC_NONE, 0, 0x25, 0), 0x7ffefe270d00) = 0 <4.438661>
> libc.so.6(ioctl+0xb)
> libcuda.so.580.126.09() [0x449e53]
> libcuda.so.580.126.09() [0x320961]
> libcuda.so.580.126.09() [0x31187c]
> libcuda.so.580.126.09() [0x2d2ef7]
> libcuda.so.580.126.09() [0x331a31]
> libcuda.so.580.126.09(cuInit+0x1f)
> ... (caller: Open MPI / hwloc / UCX -- irrelevant, see below)
UVM_INITIALIZE (shown as _IOC(_IOC_NONE, 0, 0x1, 0x3000)) runs just before on the same fd and takes ~80 us, so the cost is in UVM_REGISTER_GPU.
Per-process UVM_REGISTER_GPU durations in one run (8 processes, 8 distinct GPUs):
0.327596 0.438258 0.800688 1.740365 2.066696 2.565258 3.448307 4.438661 s
A second run on another node of the same type gave 0.31-4.61 s. A third run where a different library made the first cuInit call gave 0.23-4.63 s. So the cost doesn't depend on the caller, only on concurrent first-time registration.
A related symptom: a process that closes a /dev/nvidia-uvm fd (here from nvmlShutdown) while others are registering blocks in close() for up to ~4.3 s and returns when the registration queue drains.
Where we think it comes from (source reading, 580.126.09)
kernel-open/nvidia-uvm/uvm_gpu.c:
uvm_gpu_retain_by_uuid()takesg_uvm_global.global_lockand callsgpu_retain_by_uuid_locked().- On the first retain of a GPU,
gpu_retain_by_uuid_locked()runsnvUvmInterfaceRegisterGpu()and thenadd_gpu()(parent GPU init, GPU init, and with HMMuvm_pmm_devmem_init()->memremap_pages()for the device-private page map), all with the global lock held. - If the GPU is already retained, it only does
atomic64_inc(&gpu->retained_count). uvm_gpu_release()takes the same lock, andremove_gpu()runs when the count reaches zero. So once the last process on a GPU exits, the next process pays the full setup again (every batch job, in practice).
So N processes doing their first registration of N different GPUs all run their add_gpu() back to back under one mutex. The same structure is still present in 620.70.06 (also checked 595.112.07 and 610.57.04).
We haven't profiled inside the kernel, so we can't say which part of add_gpu() dominates the ~0.55 s per GPU.
See reproducer below. Expected with per-GPU registration: all 8 close to the single-process time.
Observed (8x B200, 580.126.09, three repeats; every repeat is a first-time registration again because all processes exit in between):
| rep 1 | rep 2 | rep 3 | |
|---|---|---|---|
1 process, cuInit |
0.509 s | 0.519 s | 0.517 s |
8 concurrent, cuInit per process (sorted) |
2.73 3.03 3.45 3.98 4.64 5.38 6.23 7.19 s | 2.81 3.30 3.91 4.59 5.44 6.42 7.41 8.56 s | 2.87 3.34 3.89 4.57 5.39 6.35 7.36 8.31 s |
strace -f -T -y -e trace=ioctl on one 8-process run splits this into two phases:
UVM_REGISTER_GPU(/dev/nvidia-uvm,_IOC(_IOC_NONE, 0, 0x25, 0)), staggered:0.207 0.546 0.957 1.520 2.167 2.950 3.781 4.724 s. This is the one-at-a-time queue described above.UVM_INITIALIZEtakes 51-69 us in every process.- Before that, ~2.35 s in every process in
NV_ESC_RM_CONTROL(/dev/nvidiactl,_IOC(_IOC_READ|_IOC_WRITE, 0x46, 0x2a, ...)): about 25 calls of ~0.05-0.19 s each, and in each round all 8 processes' calls return within microseconds of each other. A single process's wholecuInittakes 0.51 s, so this phase also seems to be serialized or batched across processes. We can't see which RM control commands these are, or which lock is involved, from user space.
Per-process ioctl time in that traced run (nvidiactl / nvidia-uvm): gpu0 2.35/0.96, gpu1 2.37/3.78, gpu2 2.35/4.72, gpu3 2.34/0.55, gpu4 2.34/1.52, gpu5 2.34/0.21, gpu6 2.33/2.95, gpu7 2.36/2.17 s.
To Reproduce
Minimal reproducer (no MPI)
// cuinit_time.c -- build: gcc -O2 cuinit_time.c -o cuinit_time -I$CUDA_HOME/include -lcuda
#include <cuda.h>
#include <stdio.h>
#include <time.h>
static double now(void) {
struct timespec t;
clock_gettime(CLOCK_MONOTONIC,&t);
return t.tv_sec+t.tv_nsec*1e-9;
}
int main(void){
double t0=now();
CUresult r=cuInit(0);
printf("cuInit=%d %.3f s\n",(int)r,now()-t0);
return r;
}
On a fully, exclusively allocated node:
# one process alone (baseline)
CUDA_VISIBLE_DEVICES=0 ./cuinit_time
# 8 concurrent processes, each on its own GPU
for i in 0 1 2 3 4 5 6 7; do
CUDA_VISIBLE_DEVICES=$i ./cuinit_time &
done;
wait
Bug Incidence
Always
nvidia-bug-report.log.gz
nvidia-bug-report.part-00.gz
nvidia-bug-report.part-01.gz
nvidia-bug-report.part-02.gz
More Info
No response
- 主要言語
- C
- スター
- 17.7k
- フォーク
- 2k
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
NVIDIA/open-gpu-kernel-modules のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
NVIDIA/open-gpu-kernel-modules#1635 ·
メンテナーはふだん 1 日以内に返信
-
nvidia-drm: NULL dereference in nv_drm_create_sync_file() when sync_file_create() fails (kernel oops when fs.file-max is exhausted)再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
NVIDIA/open-gpu-kernel-modules#1601 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
NVIDIA/open-gpu-kernel-modules#1479 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
PlatformRequestHandler: missing !bInit guard on bSystemParamLimitUpdate causes NV_ERR_INVALID_DATA at boot対応中かも @SammyTourani が 69 日前に担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
NVIDIA/open-gpu-kernel-modules#1360 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
NVIDIA/open-gpu-kernel-modules#1343 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
NVIDIA/open-gpu-kernel-modules の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
Jstar269/nakagawa-recomp#3753 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
ly05010419/MacNativeGames#2474 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
Life-Framework/Life-Framework#7017 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
gjrtimmer/jetson-nvmpi#170 ·