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

AutoModelForCasualLM.from_pretrained() exits without warning/error #36245

Open
2 of 4 tasks
blazgocompany opened this issue Feb 18, 2025 · 3 comments
Open
2 of 4 tasks
Labels

Comments

@blazgocompany
Copy link

System Info

transformers 4.49.0
Python 3.11.9

Who can help?

@ArthurZucker @gante

Information

  • The official example scripts
  • My own modified scripts

Tasks

  • An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • My own task or dataset (give details below)

Reproduction

This is what I ran:

from transformers import AutoModelForCausalLM, AutoTokenizer
import os
current_dir = os.path.dirname(os.path.abspath(__file__))
tokenizer = AutoTokenizer.from_pretrained(
    current_dir,
    use_safetensors=True,
)
print("tokenizer loaded")
model = AutoModelForCausalLM.from_pretrained(
    current_dir,
    use_safetensors=True,
)
print("model loaded")
input_ids = tokenizer("Hello, whats 23*6/4?", return_tensors="pt").input_ids
response = model.generate(
    input_ids,
    temperature=0.3,
)
print("response generated")
print(tokenizer.decode(response[0]))

I get "tokenizer loaded" but not "model loaded". the python script exits (unerrored) before that.
The current directory of the file was produced by git clone https://huggingface.co/deca-ai/2-mini-beta which does include a model.safetensors.index.json.
Looking at Task Manager, memory never goes higher than 200-300MB, so I'm not sure if it's even getting there.

Expected behavior

The model should run like normal (even if it's slow)

@Rocketknight1
Copy link
Member

Hi, we might need a bit more info to help diagnose this! Can you:

  1. Try loading the model from the Hub directly instead of a local folder
  2. Try loading another model of a similar size (to make sure it's not just a memory issue)
  3. Try running this on a non-Windows machine

@blazgocompany
Copy link
Author

blazgocompany commented Feb 18, 2025 via email

@Rocketknight1
Copy link
Member

The model is stored in the huggingface cache, when you load from the Hub, so you won't need to redownload it after the first time. On Linux/Mac the cache is in ~/.cache/huggingface, on Windows I'm not sure but I suspect it lives in %appdata%.

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

No branches or pull requests

2 participants