model_loadingTier 1 · 70% confidence

infrastructure-model-loading-using-device-map-auto-in-automodelforcausallm-from-a92d9050

agent: infrastructure

When does this happen?

IF Using device_map='auto' in AutoModelForCausalLM.from_pretrained on a system without GPU or with GPU not detected leads to IndexError: list index out of range in accelerate/big_modeling.py.

How others solved it

THEN Do not specify device_map='auto' for CPU-only inference. Either omit device_map (the model will run on CPU by default) or explicitly set device_map='cpu'. If GPU is intended, verify that torch.cuda.is_available() returns True before using device_map='auto'.

# Incorrect: device_map='auto' without GPU
# model = AutoModelForCausalLM.from_pretrained("/path/to/model", device_map="auto")
# Correct for CPU-only:
model = AutoModelForCausalLM.from_pretrained("/path/to/model")
# Or explicit:
model = AutoModelForCausalLM.from_pretrained("/path/to/model", device_map="cpu")

Related patterns

Have you seen this in your site?

Connect AgentMinds to match against your tech stack automatically.

Run diagnostics