versae commited on
Commit
2e7a033
·
1 Parent(s): 1a0d4be

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -108,7 +108,7 @@ class TextGeneration:
108
  self.model_name_or_path, use_auth_token=HF_AUTH_TOKEN if HF_AUTH_TOKEN else None,
109
  pad_token_id=self.tokenizer.eos_token_id, eos_token_id=self.tokenizer.eos_token_id,
110
  torch_dtype=DTYPE, low_cpu_mem_usage=False if DEVICE == "cpu" else True
111
- ).to(device=DEVICE, non_blocking=True)
112
  _ = self.model.eval()
113
  device_number = -1 if DEVICE == "cpu" else int(DEVICE.split(":")[-1])
114
  self.generator = pipeline(self.task, model=self.model, tokenizer=self.tokenizer, device=device_number)
@@ -131,7 +131,8 @@ class TextGeneration:
131
  )[0]["generated_text"]
132
 
133
 
134
- @st.cache(allow_output_mutation=True)
 
135
  def load_text_generator():
136
  generator = TextGeneration()
137
  generator.load()
 
108
  self.model_name_or_path, use_auth_token=HF_AUTH_TOKEN if HF_AUTH_TOKEN else None,
109
  pad_token_id=self.tokenizer.eos_token_id, eos_token_id=self.tokenizer.eos_token_id,
110
  torch_dtype=DTYPE, low_cpu_mem_usage=False if DEVICE == "cpu" else True
111
+ ).to(device=DEVICE, non_blocking=False)
112
  _ = self.model.eval()
113
  device_number = -1 if DEVICE == "cpu" else int(DEVICE.split(":")[-1])
114
  self.generator = pipeline(self.task, model=self.model, tokenizer=self.tokenizer, device=device_number)
 
131
  )[0]["generated_text"]
132
 
133
 
134
+ #@st.cache(allow_output_mutation=True)
135
+ @st.cache(hash_funcs={torch.nn.parameter.Parameter: lambda _: None})
136
  def load_text_generator():
137
  generator = TextGeneration()
138
  generator.load()