SHAMIL SHAHBAZ AWAN commited on
Commit
aad3197
·
verified ·
1 Parent(s): 7e71746

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -17,11 +17,11 @@ def load_model():
17
  low_cpu_mem_usage=True # Enable low memory usage on CPU
18
  )
19
 
20
- # Move model to CPU
21
  model = load_checkpoint_and_dispatch(
22
  model,
23
  MODEL_NAME,
24
- device_map="cpu", # Load model onto CPU
25
  )
26
 
27
  return pipeline("text-generation", model=model, tokenizer=tokenizer)
@@ -57,4 +57,4 @@ if st.button("Generate Code"):
57
  else:
58
  st.warning("Please enter a prompt.")
59
 
60
- st.caption("Created by Shamil")
 
17
  low_cpu_mem_usage=True # Enable low memory usage on CPU
18
  )
19
 
20
+ # Use 'auto' or 'balanced' device_map for CPU or GPU
21
  model = load_checkpoint_and_dispatch(
22
  model,
23
  MODEL_NAME,
24
+ device_map="auto", # Automatically determine the best device allocation
25
  )
26
 
27
  return pipeline("text-generation", model=model, tokenizer=tokenizer)
 
57
  else:
58
  st.warning("Please enter a prompt.")
59
 
60
+ st.caption("Powered by CodeGen-2B | Streamlit UI | CPU Optimized")