Skip to content

Instantly share code, notes, and snippets.

@vadimkantorov
Created May 23, 2025 17:26
Show Gist options
  • Save vadimkantorov/8d1f8881c462002bcafb2591cdae786a to your computer and use it in GitHub Desktop.
Save vadimkantorov/8d1f8881c462002bcafb2591cdae786a to your computer and use it in GitHub Desktop.
Downloads and tests import of a HuggingFace model into a meta device (and thus does not use any GPU/CPU memory)
# Usage: bash cache_hf_model.sh Qwen/Qwen3-8B
# export HF_HOME=/my/cache/HF_HOME
python -c 'import sys, transformers; transformers.AutoModel.from_pretrained(sys.argv[-1], trust_remote_code=True, device_map="meta")' $@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment