Skip to content

Gemma4e2b cannot be executed or fine-tuned. #7055

Closed

Description

@sakana-max

I am using machine translation from Japanese.

Note: Please do not remove the questions. Answer beside them.

  1. Did you update? pip install --upgrade unsloth unsloth_zoo  I should have updated it by runningirm https://unsloth.ai/install.ps1 | iex
  2. Colab or Kaggle or local / cloud This is the local Unsloth Studio.
  3. Number GPUs used, use nvidia-smi Since I'm on Windows, I checked using Task Manager. RTX 4060 Ti, 8GB VRAM.
  4. Which notebook? Please link!
  5. Which Unsloth version, TRL version, transformers version, PyTorch version? This is v0.1.481-beta
  6. Which trainer? SFTTrainer, GRPOTrainer etc

Error Details

When attempting to run Gemma4 e2b, the following error occurs:

Some modules are dispatched on the CPU or the disk. Make sure you have enough GPU RAM to fit the quantized model. If you want to dispatch the model on the CPU or the disk while keeping these modules in 32-bit, you need to set llm_int8_enable_fp32_cpu_offload=True and pass a custom device_map to from_pretrained. Check https://huggingface.co/docs/transformers/main/en/main_classes/quantization#offload-between-cpu-and-gpu for more details.

I selected the model installation from Fine-tuning Studio and installed unsloth/gemma-4-E2B-it, but the actual model is unsloth/gemma-4-e2b-it-unsloth-bnb-4bit. I'm unsure if this is normal behavior.

As indicated in the model selection, I believe it can run with approximately 6GB of VRAM.

Activity

  1. danielhanchen commented on Oct 11, 2026

    @danielhanchen
    Member

    Most likely fixed! Sorry on the delay. Gemma 4 E2B's 4-bit checkpoint is 8.1 GB, and 4.4 GB of that is one per-layer embedding table, so it cannot fit on an 8 GB card as is. Setting Offload layers to Auto in the training parameters moves that table to system RAM, but the first training step used to pull it back onto the GPU and run out of memory. That is fixed in #13320.

    Gemma 4 E2B 4-bit, LoRA r=16, batch 2, 5 steps, on a card capped at 8 GB with 7.3 GB free:

    Run Result Peak VRAM Losses
    Before, Offload layers off does not fit in GPU memory (cuda:0 has 7.26 GB free) - -
    Before, Offload layers Auto loads at 2.83 GB, then out of memory at step 1 (7.30 GB allocated) 7.43 GB -
    After, Offload layers Auto trains 5.74 GB 7.1479, 7.198, 6.5079, 5.3274, 4.7686
    Reference, no offload, no 8 GB cap trains 7.93 GB 7.1479, 7.198, 6.5079, 5.3274, 4.7686

    The losses match the run without offloading exactly. One caveat for Windows: Unsloth currently keeps embedding offload off on Windows and WSL, so there Auto can only offload decoder layers. If it still fails for you on Windows after updating, please reopen and we'll look at enabling it there.

    To update: Unsloth Desktop will have an update banner. For Studio, use unsloth studio update. For Docker, use docker exec <container> unsloth-studio-update. Reopen if it still happens.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions