Host memory still occupied after huggingface model deleted
import torchfrom transformers import AutoConfig, AutoTokenizer, BloomForCausalLM, AutoModelForCausalLMimport timeimport psutilimport gcdef get_host_memory():memory_allocated = round(psutil.Process().memory_info().rss / 1024**3, 3)print(“cpu”," memory used total: ", memory_allocated, “GB”)def load_and_run():s_ = time.time()config = AutoConfig.from_pretrained(‘bigscience/bloom-560m’)model = AutoModelForCausalLM.from_config(config)e_ = time.time()print("model loading time: %f " % (e_ - s_))get_host_memory()del modeldel configload_and_run()gc.collect()for obj in gc.get_objects():try:if torch.is_tensor(obj) or (hasattr(obj, ‘data’) and torch.is_tensor(obj.data)):print(type(obj), obj.size())except:passget_host_memory()Expected behaviorright now:after model loaded:cpu  memory used total:  3.327 GBafter model deleted:cpu  memory used total:  3.364 GBexpected, host memory should be freed after model deleted.
2023-09-07T05:52:56Z
@sguggercould you help to check this quesiton? thank you!