Spaces:
Paused
Paused
Update app/main.py
Browse files71 unmodified lines72737475767778795 unmodified lines85868788899091929394959697989971 unmodified linesif current_model == model_name and generator is not None:returndevice = 0 if torch.cuda.is_available() else -1torch_dtype = torch.float16 if device == 0 else torch.float32logger.info(f"Loading model {model_name} on device {device}")5 unmodified linesmodel = AutoModelForCausalLM.from_pretrained(model_name,cache_dir=cache_dir,device_map="auto" if device == 0 else None,torch_dtype=torch_dtype)generator = pipeline(task="text-generation",model=model,tokenizer=tokenizer,device=device,return_full_text=False)71 unmodified lines72737475767778795 unmodified lines85868788899091929394959697989910071 unmodified linesif current_model == model_name and generator is not None:returndevice = torch.device("cuda" if torch.cuda.is_available() else "cpu")torch_dtype = torch.float16 if device.type == "cuda" else torch.float32logger.info(f"Loading model {model_name} on device {device}")5 unmodified linesmodel = AutoModelForCausalLM.from_pretrained(model_name,cache_dir=cache_dir,torch_dtype=torch_dtype).to(device)# Create pipeline with proper device indexpipeline_device = 0 if device.type == "cuda" else -1generator = pipeline(task="text-generation",model=model,tokenizer=tokenizer,device=pipeline_device,return_full_text=False)
app/main.py+6-5