# LLaMA-2: CPU Memory Usage with ‘low\_cpu\_mem\_usage=True’ and ‘torch\_dtype=“auto”’ flags

**URL:** <https://discuss.huggingface.co/t/llama-2-cpu-memory-usage-with-low-cpu-mem-usage-true-and-torch-dtype-auto-flags/53154>\
**Category:** 🤗Transformers\
**Created:** [September 1, 2023, 2:43pm UTC](https://discuss.huggingface.co/t/llama-2-cpu-memory-usage-with-low-cpu-mem-usage-true-and-torch-dtype-auto-flags/53154 "2023-09-01T14:43:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![hanguo](https://avatars.discourse-cdn.com/v4/letter/h/3bc359/32.png) [@hanguo](https://discuss.huggingface.co/u/hanguo)\
**Post date:** [September 1, 2023, 2:43pm UTC](https://discuss.huggingface.co/t/llama-2-cpu-memory-usage-with-low-cpu-mem-usage-true-and-torch-dtype-auto-flags/53154/1 "2023-09-01T14:43:26Z")

</div>

I have noticed that when I load the 70B model (specifically LLaMA-2) into the CPU using the ‘low\_cpu\_mem\_usage=True’ and ‘torch\_dtype=“auto”’ flags, it has almost no effect on the CPU memory usage. However, if I remove either of these flags, it consumes a significant amount of memory. I am curious about the reason behind this behavior. Is there any memory-mapping happening in the background? And if so, when does it trigger? I would really appreciate it if you could help me understand this better.

This has been discussed in a [different channel](https://discuss.huggingface.co/t/cpu-memory-usage-with-low-cpu-mem-usage-true-and-torch-dtype-auto-flags/52893) but was recommended to post in this channel.

@marcsun13 noticed that it might have something to do with safetensors format + fp16 (torch\_dtype=“auto will set torch\_dtype=torch.float16) + low\_cpu\_mem\_usage = True. The memory consumption also skyrocket with we use the PyTorch bin format (pytorch bin + fp16 + low\_cpu\_mem\_usage = True).

Thank you for your time!
