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)
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 32/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Stack tecnológico
- c, linux
- Área
- backend, operating-systems, performance
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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
- Lenguaje dominante
- C
- Estrellas
- 17.7k
- Forks
- 2k
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de NVIDIA/open-gpu-kernel-modules
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
NVIDIA/open-gpu-kernel-modules#1635 ·
Los mantenedores suelen responder en 1 día
-
nvidia-drm: NULL dereference in nv_drm_create_sync_file() when sync_file_create() fails (kernel oops when fs.file-max is exhausted)Quizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
NVIDIA/open-gpu-kernel-modules#1601 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
NVIDIA/open-gpu-kernel-modules#1479 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
PlatformRequestHandler: missing !bInit guard on bSystemParamLimitUpdate causes NV_ERR_INVALID_DATA at bootPosiblemente ocupada @SammyTourani la tomó hace 69 días. Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
NVIDIA/open-gpu-kernel-modules#1360 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
NVIDIA/open-gpu-kernel-modules#1343 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de NVIDIA/open-gpu-kernel-modules
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
Jstar269/nakagawa-recomp#3753 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 72/100
ly05010419/MacNativeGames#2474 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Life-Framework/Life-Framework#7017 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
gjrtimmer/jetson-nvmpi#170 ·