stardate69 commited on
Commit
050eb17
Β·
verified Β·
1 Parent(s): ad61fc3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -11,9 +11,14 @@ if HUGGINGFACE_TOKEN is None:
11
  raise ValueError("Missing Hugging Face token. Please set it in Spaces Secrets.")
12
  login(HUGGINGFACE_TOKEN)
13
 
14
- # Set device for PyTorch
15
- device = "cuda" if torch.cuda.is_available() else "cpu"
16
- torch_dtype = torch.float16 if device == "cuda" else torch.float32
 
 
 
 
 
17
 
18
  # Load the pipeline
19
  pipe = StableAudioPipeline.from_pretrained(
 
11
  raise ValueError("Missing Hugging Face token. Please set it in Spaces Secrets.")
12
  login(HUGGINGFACE_TOKEN)
13
 
14
+ # Set device for PyTorch (only CPU, if no GPU is available)
15
+ device = "cpu"
16
+ torch_dtype = torch.float32 # Use float32 for CPU by default
17
+
18
+ # Check for GPU availability
19
+ if torch.cuda.is_available():
20
+ device = "cuda"
21
+ torch_dtype = torch.float16 # Use float16 for GPU to optimize memory usage
22
 
23
  # Load the pipeline
24
  pipe = StableAudioPipeline.from_pretrained(