System Info
transformers version: 4.36.2
- Platform: Linux-5.10.201-191.748.amzn2.x86_64-x86_64-with-glibc2.31
- Python version: 3.10.13
- Huggingface_hub version: 0.20.2
- Safetensors version: 0.4.1
- Accelerate version: 0.26.0
- Accelerate config: not found
- PyTorch version (GPU?): 2.1.0 (True)
- Tensorflow version (GPU?): not installed (NA)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Using GPU in script?:
- Using distributed or parallel set-up in script?:
Who can help?
I am using transformers to load a model into GPU, and I observed that before moving the model to GPU there is a peak of RAM usage that later gets unused. I assume the model is loaded into CPU before moving into GPU.
In GPU model takes around 4Gi and to load it I need more than 7Gi of RAM which seems weird.
Is there a way to load it direcly to the GPU without spending so much RAM?
I have tried with the low_cpu_mem_usage and device_map parameter to cuda and auto but no luck.
from transformers import AutoModel; m = AutoModel.from_pretrained("jinaai/jina-embeddings-v2-base-en", trust_remote_code=True, low_cpu_mem_usage=True, device_map="auto")
Information
Tasks
Reproduction
from transformers import AutoModel; m = AutoModel.from_pretrained("jinaai/jina-embeddings-v2-base-en", trust_remote_code=True, low_cpu_mem_usage=True, device_map="auto")
Expected behavior
Not having such a memory peak
System Info
transformersversion: 4.36.2Who can help?
I am using transformers to load a model into GPU, and I observed that before moving the model to GPU there is a peak of RAM usage that later gets unused. I assume the model is loaded into CPU before moving into GPU.
In GPU model takes around 4Gi and to load it I need more than 7Gi of RAM which seems weird.
Is there a way to load it direcly to the GPU without spending so much RAM?
I have tried with the
low_cpu_mem_usageanddevice_mapparameter tocudaandautobut no luck.Information
Tasks
examplesfolder (such as GLUE/SQuAD, ...)Reproduction
Expected behavior
Not having such a memory peak