Limit the amount of pinned memory

Hi all,

can I somehow limit the amount of pinned memory that can be allocated by a user? I have some students developing on a system and I like to prevent them from allocating more than ~800 MB of pinned memory. Allocating more than 800 MB of pinnend memory kills not only the processing allocating the memory but also other random processes. :mellow:


Maybe a custom, hacked CUDA header file that leaves out the cudaMalloc functions, and then providing access to them through a convenience library that checks how much you’ve allocated?

Yeah that was my thought too. Take away the standard alloc functions and replace them with your own wrapper code which has managed pointers and sanity checks to limit what can be allocated.

There is an outside chance the CUDA driver might have some internal limit mechanism that might be exposed via symbols (but I have not heard of it), but the operating system itself takes a laissez-faire approach to user space memory management.

Thanks, yes, that is probably the easiest solution.

If “pinned memory” is the same thing as what is performed by mlock() and friends, then you can set a limit in /etc/security/limits.conf