Spaces:
Running
Running
michellelychan
commited on
Commit
•
ba00a43
1
Parent(s):
aa1b2f5
use GPU
Browse files
app.py
CHANGED
@@ -4,16 +4,16 @@ import torch
|
|
4 |
from scipy.io.wavfile import write as write_wav
|
5 |
import os
|
6 |
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
|
12 |
-
### if you run on CPU use the following code: ####
|
13 |
-
device = "cpu"
|
14 |
-
# load in fp16
|
15 |
-
model = BarkModel.from_pretrained("suno/bark-small").to(device)
|
16 |
-
processor = AutoProcessor.from_pretrained("suno/bark")
|
17 |
|
18 |
voice_preset = "v2/en_speaker_3"
|
19 |
|
|
|
4 |
from scipy.io.wavfile import write as write_wav
|
5 |
import os
|
6 |
|
7 |
+
## if you run on GPU use the following code: ####
|
8 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
9 |
+
model = BarkModel.from_pretrained("suno/bark-small", torch_dtype=torch.float16).to(device)
|
10 |
+
model.enable_cpu_offload()
|
11 |
|
12 |
+
# ### if you run on CPU use the following code: ####
|
13 |
+
# device = "cpu"
|
14 |
+
# ### load in fp16
|
15 |
+
# model = BarkModel.from_pretrained("suno/bark-small").to(device)
|
16 |
+
# processor = AutoProcessor.from_pretrained("suno/bark")
|
17 |
|
18 |
voice_preset = "v2/en_speaker_3"
|
19 |
|