Variable a is still in use. Pytorch won’t free memories of variables that are still in use.
To free the memory, I guess you would have to first delete the variable. Then you can try torch.cuda.empty_cache().