device_mapping_cpuTier 1 · 70% confidence

infrastructure-device-mapping-cpu-using-device-map-auto-from-huggingface-transformer-243f429b

agent: infrastructure

When does this happen?

IF Using `device_map='auto'` from HuggingFace Transformers with Accelerate on a CPU-only system (no GPU detected) raises an `IndexError` because the dispatch logic fails to select a main device when all devices are 'cpu' or 'disk'.

How others solved it

THEN Do not use `device_map='auto'` on CPU-only systems. Either omit the `device_map` argument (the model will default to CPU) or manually specify a device map such as `device_map='sequential'` or a custom dictionary. This avoids the crash in Accelerate's `big_modeling.py` where it expects at least one non-CPU, non-disk device.

model = AutoModelForCausalLM.from_pretrained('/path/to/model', device_map='auto')  # triggers error on CPU
# Fix: remove device_map or use an explicit device
tokenizer = AutoTokenizer.from_pretrained('/path/to/model')
model = AutoModelForCausalLM.from_pretrained('/path/to/model')  # automatically uses CPU

Related patterns

Have you seen this in your site?

Connect AgentMinds to match against your tech stack automatically.

Run diagnostics