Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RuntimeError: unable to mmap 23802932552 bytes from file <./flux1-dev.safetensors>: Cannot allocate memory (12) #528

Open
1 of 2 tasks
sakura-nyaa opened this issue Sep 22, 2024 · 0 comments

Comments

@sakura-nyaa
Copy link

System Info

  • transformers version: 4.44.2
  • Platform: Linux-6.10.10-arch1-1-x86_64-with-glibc2.40
  • Python version: 3.12.6
  • Huggingface_hub version: 0.24.6
  • Safetensors version: 0.4.6-dev.0
  • Accelerate version: 0.34.2
  • Accelerate config: not found
  • PyTorch version (GPU?): 2.3.1 (True)
  • Tensorflow version (GPU?): not installed (NA)
  • Flax version (CPU?/GPU?/TPU?): not installed (NA)
  • Jax version: not installed
  • JaxLib version: not installed
  • Using distributed or parallel set-up in script?: No.
  • Using GPU in script?: No.
  • GPU type: AMD Radeon RX 7600 XT

Information

  • The official example scripts
  • My own modified scripts

Reproduction

  1. Download https://huggingface.co/black-forest-labs/FLUX.1-dev/blob/main/flux1-dev.safetensors
  2. Try to load it with ws = safe_open("./flux1-dev.safetensors", framework="pt")
  3. Receive "RuntimeError: unable to mmap 23802932552 bytes from file <./flux1-dev.safetensors>: Cannot allocate memory (12)"

Expected behavior

The tensors should be lazy loaded.
I should be able to access metadata and choose to actually load a tensor into RAM/VRAM when needed.
The fact that the .safetensors file is 24 GB and I have 16 GB of RAM shouldn't affect the loading.

(I can safely lazy load a safetensors file that is around 5 GB with the exact same script, and no memory is actually allocated and everything works as expected. The issue only arises when attempting to load a safetensors file that is larger than system RAM.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant