import torch import gc torch.cuda.empty_cache() gc.collect()