Hi
We (a university of applied sciences in switzerland) found this great project and are now planning to use it in our Slurm-based HPC-Cluster due to its large potential to improve GPU utilization/efficiency.
At the moment we are only doing some local testing on a single Ubuntu server (no Kubernetes, no Slurm).
We noticed a unexpected CUDA OOM error when running 2 Pytorch Scripts, each allocating ~7 GB on a GPU with 11GB Memory.
We are using RTX 2080 Ti with CUDA 12.8
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 570.133.20 Driver Version: 570.133.20 CUDA Version: 12.8 |
|-----------------------------------------+------------------------+----------------------+
| GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|=========================================+========================+======================|
| 0 NVIDIA GeForce RTX 2080 Ti Off | 00000000:21:00.0 Off | N/A |
| 29% 36C P8 8W / 250W | 28MiB / 11264MiB | 0% Default |
| | | N/A |
+-----------------------------------------+------------------------+----------------------+
For testing we are using a slightly modified version of your pytorch-add.py with n set to different values.
1. case
n = 21000 -> ~6.9GB is allocated on the GPU
We run the script twice simultaneously in two shells
NVSHARE_DEBUG=1 LD_PRELOAD=libnvshare.so python /mnt/data/examples/pytorch-add-6.9G.py
Everything works as expected. Both show correct output: nvshare client is initialized, the first script runs for 30 seconds, switches to the second script and so on...
2. case
n = 21500 -> ~7.2GB is allocated on the GPU
Again, we run the script twice simultaneously in two shells.
NVSHARE_DEBUG=1 LD_PRELOAD=libnvshare.so python /mnt/data/examples/pytorch-add-7.2G.py
Both nvshare-clients are initializing, the first script is running on the GPU for 30 seconds.
Then the scheduler releases the lock and the second script tries to allocate memory, this time however, we get a CUDA OOM error.
# Script 1
[NVSHARE][DEBUG]: Found NVML
[NVSHARE][DEBUG]: NVSHARE_POD_NAME = none
[NVSHARE][DEBUG]: NVSHARE_POD_NAMESPACE = none
[NVSHARE][DEBUG]: Sent REGISTER
[NVSHARE][DEBUG]: Received SCHED_ON
[NVSHARE][INFO]: Successfully initialized nvshare GPU
[NVSHARE][INFO]: Client ID = 3461be0e3e2750d9
[NVSHARE][DEBUG]: real_cuMemGetInfo returned free=10575.12 MiB, total=10822.94 MiB
[NVSHARE][DEBUG]: nvshare's cuMemGetInfo returning free=9286.94 MiB, total=10822.94 MiB
[NVSHARE][DEBUG]: cuMemAlloc requested 1849688064 bytes
[NVSHARE][DEBUG]: cuMemAllocManaged allocated 1849688064 bytes at 0x7d56c4000000
[NVSHARE][DEBUG]: Total allocated memory on GPU is 1764.00 MiB
[NVSHARE][DEBUG]: Received LOCK_OK
[NVSHARE][DEBUG]: cuMemAlloc requested 1849688064 bytes
[NVSHARE][DEBUG]: cuMemAllocManaged allocated 1849688064 bytes at 0x7d5654000000
[NVSHARE][DEBUG]: Total allocated memory on GPU is 3528.00 MiB
0%| | 0/4000 [00:00<?, ?it/s][NVSHARE][DEBUG]: cuMemAlloc requested 1849688064 bytes
[NVSHARE][DEBUG]: cuMemAllocManaged allocated 1849688064 bytes at 0x7d55e4000000
[NVSHARE][DEBUG]: Total allocated memory on GPU is 5292.00 MiB
[NVSHARE][DEBUG]: Pending Kernel Window is 2.
0%| | 1/4000 [00:00<26:28, 2.52it/s][NVSHARE][DEBUG]: cuMemAlloc requested 1849688064 bytes
[NVSHARE][DEBUG]: cuMemAllocManaged allocated 1849688064 bytes at 0x7d5574000000
[NVSHARE][DEBUG]: Total allocated memory on GPU is 7056.00 MiB
[NVSHARE][DEBUG]: Pending Kernel Window is 4.
0%|▏ | 3/4000 [00:00<15:27, 4.31it/s][NVSHARE][DEBUG]: Pending Kernel Window is 8.
[NVSHARE][DEBUG]: Pending Kernel Window is 16.
0%|▋ | 15/4000 [00:00<02:41, 24.75it/s][NVSHARE][DEBUG]: Pending Kernel Window is 32.
1%|█▌ | 31/4000 [00:01<01:25, 46.24it/s][NVSHARE][DEBUG]: Pending Kernel Window is 64.
2%|███ | 63/4000 [00:01<00:56, 69.83it/s][NVSHARE][DEBUG]: Pending Kernel Window is 128.
3%|██████▎ | 127/4000 [00:02<00:45, 85.75it/s][NVSHARE][DEBUG]: Pending Kernel Window is 64.
6%|████████████▌ | 255/4000 [00:03<00:40, 93.34it/s]
.......
61%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████ | 2431/4000 [00:25<00:15, 98.07it/s][NVSHARE][DEBUG]: Pending Kernel Window is 64.
64%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▍ | 2559/4000 [00:26<00:14, 98.08it/s][NVSHARE][DEBUG]: Pending Kernel Window is 128.
66%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▌ | 2623/4000 [00:27<00:14, 98.07it/s][NVSHARE][DEBUG]: Received DROP_LOCK
[NVSHARE][DEBUG]: Pending Kernel Window is 1.
[NVSHARE][DEBUG]: Sent LOCK_RELEASED
# Script 2
[NVSHARE][DEBUG]: Found NVML
[NVSHARE][DEBUG]: NVSHARE_POD_NAME = none
[NVSHARE][DEBUG]: NVSHARE_POD_NAMESPACE = none
[NVSHARE][DEBUG]: Sent REGISTER
[NVSHARE][DEBUG]: Received SCHED_ON
[NVSHARE][INFO]: Successfully initialized nvshare GPU
[NVSHARE][INFO]: Client ID = 0ff51254656fe01d
[NVSHARE][DEBUG]: real_cuMemGetInfo returned free=6557.12 MiB, total=10822.94 MiB
[NVSHARE][DEBUG]: nvshare's cuMemGetInfo returning free=9286.94 MiB, total=10822.94 MiB
[NVSHARE][DEBUG]: cuMemAlloc requested 1849688064 bytes
[NVSHARE][DEBUG]: cuMemAllocManaged allocated 1849688064 bytes at 0x73e058000000
[NVSHARE][DEBUG]: Total allocated memory on GPU is 1764.00 MiB
[NVSHARE][DEBUG]: Received LOCK_OK
[NVSHARE][DEBUG]: cuMemAlloc requested 1849688064 bytes
[NVSHARE][DEBUG]: cuMemAllocManaged allocated 1849688064 bytes at 0x73dfe8000000
[NVSHARE][DEBUG]: Total allocated memory on GPU is 3528.00 MiB
0%| | 0/4000 [00:00<?, ?it/s][NVSHARE][DEBUG]: cuMemAlloc requested 1849688064 bytes
[NVSHARE][DEBUG]: cuMemAllocManaged allocated 1849688064 bytes at 0x73df78000000
[NVSHARE][DEBUG]: Total allocated memory on GPU is 5292.00 MiB
0%| | 0/4000 [00:00<?, ?it/s]
Traceback (most recent call last):
File "/mnt/data/examples/pytorch-add-7.2G.py", line 33, in <module>
z = torch.add(x, y)
^^^^^^^^^^^^^^^
RuntimeError: CUDA error: out of memory
CUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect.
For debugging consider passing CUDA_LAUNCH_BLOCKING=1
Compile with `TORCH_USE_CUDA_DSA` to enable device-side assertions.
I assumed that each of my scripts would be able to use basically all GPU memory (~11G) and nvshare would use page faults using unified memory to switch between the two.
Is this behaviour expected? Why does it happen exactly at 2 * 7 = 14GB?
Thanks!
Hi
We (a university of applied sciences in switzerland) found this great project and are now planning to use it in our Slurm-based HPC-Cluster due to its large potential to improve GPU utilization/efficiency.
At the moment we are only doing some local testing on a single Ubuntu server (no Kubernetes, no Slurm).
We noticed a unexpected CUDA OOM error when running 2 Pytorch Scripts, each allocating ~7 GB on a GPU with 11GB Memory.
We are using RTX 2080 Ti with CUDA 12.8
For testing we are using a slightly modified version of your pytorch-add.py with n set to different values.
1. case
n = 21000 -> ~6.9GB is allocated on the GPU
We run the script twice simultaneously in two shells
NVSHARE_DEBUG=1 LD_PRELOAD=libnvshare.so python /mnt/data/examples/pytorch-add-6.9G.py
Everything works as expected. Both show correct output: nvshare client is initialized, the first script runs for 30 seconds, switches to the second script and so on...
2. case
n = 21500 -> ~7.2GB is allocated on the GPU
Again, we run the script twice simultaneously in two shells.
NVSHARE_DEBUG=1 LD_PRELOAD=libnvshare.so python /mnt/data/examples/pytorch-add-7.2G.py
Both nvshare-clients are initializing, the first script is running on the GPU for 30 seconds.
Then the scheduler releases the lock and the second script tries to allocate memory, this time however, we get a CUDA OOM error.
I assumed that each of my scripts would be able to use basically all GPU memory (~11G) and nvshare would use page faults using unified memory to switch between the two.
Is this behaviour expected? Why does it happen exactly at 2 * 7 = 14GB?
Thanks!