# torch.cuda.set\_per\_process\_memory\_fraction() doesn’t see shared memory

**URL:** <https://discuss.pytorch.org/t/torch-cuda-set-per-process-memory-fraction-doesn-t-see-shared-memory/223336>\
**Category:** data\
**Created:** [September 26, 2025, 12:20pm UTC](https://discuss.pytorch.org/t/torch-cuda-set-per-process-memory-fraction-doesn-t-see-shared-memory/223336 "2025-09-26T12:20:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![elismasilva](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/elismasilva/32/78308_2.png) [@elismasilva](https://discuss.pytorch.org/u/elismasilva)\
**Post date:** [September 26, 2025, 12:20pm UTC](https://discuss.pytorch.org/t/torch-cuda-set-per-process-memory-fraction-doesn-t-see-shared-memory/223336/1 "2025-09-26T12:20:33Z")

</div>

torch.cuda.set\_per\_process\_memory\_fraction() doesn’t see shared memory. I have a GPU with 8GB of video memory. I’m running a model that consumes my 8GB and overflows another 8GB into Windows’ shared video memory. When I set torch.cuda.set\_per\_process\_memory\_fraction(fraction=1.0, device=0), the process limits the total to just the GPU’s 8GB of video memory. I wanted to simulate, for example, telling PyTorch that I have, for example, 13GB available, also considering shared memory. I want to set a limit to know how far my model can load. For example, sometimes the model shows that it consumed 16.9GB considering shared memory. But I wanted to set it to 16GB to see if it would run because I have the impression that it doesn’t actually need the 16.9GB, but I can’t run this simulation.

---

<div class="post-metadata">

**Author:** ![ptrblck](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/ptrblck/32/1823_2.png) [@ptrblck](https://discuss.pytorch.org/u/ptrblck)\
**Post date:** [September 26, 2025, 1:45pm UTC](https://discuss.pytorch.org/t/torch-cuda-set-per-process-memory-fraction-doesn-t-see-shared-memory/223336/2 "2025-09-26T13:45:10Z")

</div>

PyTorch does not enable or use Windows’ “shared video memory” feature as it’s a driver feature. It thus also does not have any control when and if it will be used.

---

<div class="post-metadata">

**Author:** ![elismasilva](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/elismasilva/32/78308_2.png) [@elismasilva](https://discuss.pytorch.org/u/elismasilva)\
**Post date:** [September 26, 2025, 7:08pm UTC](https://discuss.pytorch.org/t/torch-cuda-set-per-process-memory-fraction-doesn-t-see-shared-memory/223336/4 "2025-09-26T19:08:11Z")

</div>

So you’re telling me that when PyTorch applies set\_per\_process\_memory\_fraction it’s only seeing the 8GB of my GPU. I tried using max\_split\_size\_mb to set a limit, but that doesn’t stop the driver from allocating shared memory, even though I set it to something. It seems to only be related to the cache. So, there’s no way to tell PyTorch that you can use 8GB of the GPU and only 4GB of shared memory, right?

---

<div class="post-metadata">

**Author:** ![ptrblck](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/ptrblck/32/1823_2.png) [@ptrblck](https://discuss.pytorch.org/u/ptrblck)\
**Post date:** [September 26, 2025, 10:40pm UTC](https://discuss.pytorch.org/t/torch-cuda-set-per-process-memory-fraction-doesn-t-see-shared-memory/223336/5 "2025-09-26T22:40:27Z")

</div>

> [@elismasilva](#):
>
> when PyTorch applies set\_per\_process\_memory\_fraction it’s only seeing the 8GB of my GPU

Yes, this option limits the allowed allocated memory by checking the total memory via `cudaMemGetInfo` as seen [here](https://github.com/pytorch/pytorch/blob/0ebfa3d7d29e9278d7c41c9b349bfc53268268b4/c10/cuda/CUDACachingAllocator.cpp#L2019-L2026). PyTorch does not have any knowledge about Windows driver features which offload GPU memory to the host behind your back without opting-in.
