a_d:

Firstly, why is pytorch reserving so less memory when my graphics card is of 8GB and second is instead of pytorch reserving memory, is there any way we can tell pytorch to use all the space available.


When the error is raised, 1.18GB are already allocated from the previously executed code and PyTorch tries to allocate 5.96GB, which doesn’t fit into the available 5.68GB.
The rest of the device would most likely be used by the CUDA context (to store the kernels etc.).