Spaces:
Paused
Paused
kgupta21 commited on
Commit ·
eb5c340
1
Parent(s): a956d76
local inference page with fixes to gpu with zerogpu + add accelerate for device mapping
Browse filesFiles changed (2)
- app.py+21-4
- requirements.txt+2-1
47 unmodified lines484950515253545556575847 unmodified lines# Initialize Llamatry:logger.info("Initializing Llama model...")if torch.cuda.is_available():llm_model_id = "chuanli11/Llama-3.2-3B-Instruct-uncensored"llm = AutoModelForCausalLM.from_pretrained(llm_model_id, torch_dtype=torch.float16, device_map="auto")tokenizer = AutoTokenizer.from_pretrained(llm_model_id)tokenizer.use_default_system_prompt = Falseexcept Exception as e:logger.error(f"Error initializing Llama model: {str(e)}")llm = None47 unmodified lines4849505152535455565758596061626364656667686970717273747547 unmodified lines# Initialize Llamatry:logger.info("Initializing Llama model...")llm_model_id = "chuanli11/Llama-3.2-3B-Instruct-uncensored"# Initialize tokenizer firsttokenizer = AutoTokenizer.from_pretrained(llm_model_id)tokenizer.use_default_system_prompt = False# Initialize model with proper device mappingif torch.cuda.is_available():logger.info("Loading Llama model on GPU...")llm = AutoModelForCausalLM.from_pretrained(llm_model_id,torch_dtype=torch.float16,device_map="auto",load_in_8bit=True # Use 8-bit quantization to reduce memory usage)else:logger.info("Loading Llama model on CPU...")llm = AutoModelForCausalLM.from_pretrained(llm_model_id,device_map={"": "cpu"},low_cpu_mem_usage=True)except Exception as e:logger.error(f"Error initializing Llama model: {str(e)}")llm = None
5 unmodified lines67895 unmodified lineshuggingface-hub>=0.20.0torch>=2.0.0transformers>=4.36.0spaces>=0.19.35 unmodified lines6789105 unmodified lineshuggingface-hub>=0.20.0torch>=2.0.0transformers>=4.36.0spaces>=0.19.3accelerate>=0.27.0
app.py+21-4
requirements.txt+2-1