Skip to content

[BUG] model, tokenizer = FastLanguageModel.from_pretrained(...) hangs when using accelerate  #2280

Closed as duplicate

Description

@Henchen99

Environment Setup

  • Python Version: 3.10.16
  • Frameworks/Libraries:
    accelerate==1.5.2
    unsloth==2025.3.8
    torch==2.6.0
    torchaudio==2.6.0
    torchvision==0.21.0
    
  • Run Mode: Python script

Training Configuration

GRPOConfig(
    learning_rate = 1e-6,
    weight_decay = 0.1,
    num_train_epochs = 1,
    per_device_train_batch_size = 4,
    gradient_accumulation_steps = 4,
    num_generations = 8,
    max_prompt_length = 512,
    max_completion_length = 6000,
    report_to = ["wandb"],
    save_strategy = "epoch",
    save_total_limit = 1,
    seed = 42,
    output_dir = "outputs"
)

Reproduction Steps

from unsloth import FastLanguageModel

model, tokenizer = FastLanguageModel.from_pretrained(
    model_name = "/vault/ultraz/open-r1/data/llama3-3b-lora-checkpoint_1023",
    max_seq_length = 6000,
    fast_inference = False,
    max_lora_rank = 32,
    gpu_memory_utilization = 0.6
)

Launched using:

accelerate config
accelerate launch train_script.py

Behavior

  • Script hangs indefinitely at from_pretrained().
  • No error logs or crash — process becomes unresponsive.
  • All GPUs are visible and idle (verified using nvidia-smi).

Last visible output:

INFO 04-03 20:04:07 [cuda.py:291] Using Flash Attention backend.
loading configuration file /vault/ultraz/open-r1/data/llama3-3b-lora-checkpoint_1023/generation_config.json
Generate config GenerationConfig {
  "bos_token_id": 128000,
  "do_sample": true,
  "eos_token_id": [
    128001,
    128008,
    128009
  ],
  "temperature": 0.6,
  "top_p": 0.9
}

INFO 04-03 20:04:08 [cuda.py:291] Using Flash Attention backend.
[E403 20:14:00.181953387 socket.cpp:1023] [c10d] The client socket has timed out after 600000ms while trying to connect to (10.137.32.41, 40935).
[W403 20:14:00.182477993 TCPStore.cpp:330] [c10d] TCP client failed to connect/validate to host 10.137.32.41:40935 - retrying (try=0, timeout=600000ms, delay=32905ms): The client socket has timed out after 600000ms while trying to connect to (10.137.32.41, 40935).
Exception raised from throwTimeoutError at /pytorch/torch/csrc/distributed/c10d/socket.cpp:1025 (most recent call first)

Activity

  1. changed the title [-][BUG] model, tokenizer = FastLanguageModel.from_pretrained(...) hangs[/-] [+][BUG] model, tokenizer = FastLanguageModel.from_pretrained(...) hangs when using accelerate [/+] on Apr 4, 2025
  2. mmathew23 commented on Apr 4, 2025

    @mmathew23
    Contributor

    What's in your checkpoint? Does it hang when you load a huggingface model string?

  3. Henchen99 commented on Apr 4, 2025

    @Henchen99
    Author

    The checkpoint contains the full weights of a trained LLaMA 3B Instruct model. I tried with meta-llama/Llama-3.2-3B-Instruct and it still hangs. However, when I run the same script using python train_script.py then it runs fine, but runs out of memory because its not distributing the memory across the GPUs

  4. mmathew23 commented on Apr 4, 2025

    @mmathew23
    Contributor

    If it's hanging with a regular huggingface model it suggests a problem outside of unsloth, but also make sure you're using the latest unsloth versions. I suspect it could be due to accelerate and the config you have. Try without accelerate. Unsloth doesn't support multi-gpu yet so you generally don't need to launch with accelerate.

  5. Henchen99 commented on Apr 4, 2025

    @Henchen99
    Author

    I see, I also have a feeling it might be a problem out of unsloth. Currently if I do not use accelerate, when it loads to my GPU, all the memory just goes to the first one, and the other ones have nothing so it goes out of memory. Are there any ways around equal GPU distribution?

  6. mmathew23 commented on Apr 4, 2025

    @mmathew23
    Contributor

    unsloth does not support multi gpu at the moment. It's coming soon.

  7. rolandtannous commented on May 14, 2025

    @rolandtannous
    Contributor

    @Henchen99 @mmathew23

    We're working on multi-gpu support. Should be released soon.
    meanwhile have you tried accelerate?

    merging this thread with #2435
    Feel free to leave your comments and follow up questions there

    thank you!

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions