Calculation of GPU memory consumption on softmax layer doesn't match with the empirical result I'm training a language model with 5000 vocabularies using a single M60 GPU (w/ actually usable memory about 7.5G). 
The number of tokens per batch is about 8000, and the hidden dimension to the softmax layer is 512. So, if I understand correctly, fully-connected (softmax) layer theoretically consumes 5000*8000*512*4=81.92GB for a forward pass (4 is for float32).
But the GPU performed the forward and backward passes without any problem, and it says the GPU memory usage is less than 7GB in total. 

I used PyTorch. What's causing this? 

EDIT: To be clearer, the input to the final fc layer (256x5000 matrix) is of size [256, 32, 256].
GPU DRAM capacity - 7.5G
the below link explains how nVIDIA GPU cUDNN does memory optimization.
https://devblogs.nvidia.com/optimizing-recurrent-neural-networks-cudnn-5/
the below link has detailed steps to calculate memory required by parameters and data.
http://cs231n.github.io/convolutional-networks/#case
one data point missing in question is number of output classes in softmax layer.
The above two links will help you to calculate memory required and how software handles large matrix multiplication.