addcorpbc commited on
Commit ·
1e83603
1
Parent(s): e94a060
Switch model loading to CPU
Browse files5 unmodified lines67891011125 unmodified lines18192021222324255 unmodified lineshf_token = os.getenv("HFTOKEN") # Updated to match your environment variable nameif not hf_token:raise ValueError("Hugging Face token is missing. Please add it as an environment variable named 'HFTOKEN'.")# Print the token for debuggingprint("Hugging Face Token:", hf_token)5 unmodified linestokenizer = AutoTokenizer.from_pretrained("meta-llama/Llama-2-7b-hf", cache_dir=cache_dir, use_auth_token=hf_token)model = AutoModelForCausalLM.from_pretrained("meta-llama/Llama-2-7b-hf",load_in_8bit=True, # Enable quantization for better performancedevice_map="auto", # Automatically map layers to available hardwarecache_dir=cache_dir,use_auth_token=hf_token # Pass the token for authenticated model loading)5 unmodified lines67891011125 unmodified lines181920212223245 unmodified lineshf_token = os.getenv("HFTOKEN") # Updated to match your environment variable nameif not hf_token:raise ValueError("Hugging Face token is missing. Please add it as an environment variable named 'HFTOKEN'.")# Print the token for debuggingprint("Hugging Face Token:", hf_token)5 unmodified linestokenizer = AutoTokenizer.from_pretrained("meta-llama/Llama-2-7b-hf", cache_dir=cache_dir, use_auth_token=hf_token)model = AutoModelForCausalLM.from_pretrained("meta-llama/Llama-2-7b-hf",device_map="auto", # Automatically map layers to available hardware (CPU here)cache_dir=cache_dir,use_auth_token=hf_token # Pass the token for authenticated model loading)
app.py+2-3