How to allocate special amount of GPU memory

Is there anyway to allocate special amount of GPU memory to the program via pytorch? in other words, can I block the memory while running my code?

What do you mean by blocking the memory?

I mean blocking the memory in a way that that amount would be set for your program to be used.
Meaning: e.g. you block X amount of gpu memory so X amount of GPU memory would be allocated for your code usage and if another person use the gpu they cannot use it. meaning you block X amount of GPU memory