Spaces:
Running on Zero
Running on Zero
Make device selection CPU-safe
Browse files
app.py
CHANGED
|
@@ -15,9 +15,14 @@ MODEL_ID = "sbintuitions/kana-whisper"
|
|
| 15 |
|
| 16 |
# ZeroGPU exposes CUDA at startup, so we can load straight onto the GPU. The
|
| 17 |
# @spaces.GPU decorator on transcribe() is what actually reserves the slice at
|
| 18 |
-
# call time; on non-ZeroGPU hardware the decorator is a no-op.
|
| 19 |
-
device
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
model = AutoModelForSpeechSeq2Seq.from_pretrained(
|
| 23 |
MODEL_ID,
|
|
|
|
| 15 |
|
| 16 |
# ZeroGPU exposes CUDA at startup, so we can load straight onto the GPU. The
|
| 17 |
# @spaces.GPU decorator on transcribe() is what actually reserves the slice at
|
| 18 |
+
# call time; on non-ZeroGPU hardware the decorator is a no-op. We detect the
|
| 19 |
+
# device so the Space still builds/runs on plain CPU hardware (just slower).
|
| 20 |
+
if torch.cuda.is_available():
|
| 21 |
+
device = "cuda"
|
| 22 |
+
torch_dtype = torch.float16
|
| 23 |
+
else:
|
| 24 |
+
device = "cpu"
|
| 25 |
+
torch_dtype = torch.float32
|
| 26 |
|
| 27 |
model = AutoModelForSpeechSeq2Seq.from_pretrained(
|
| 28 |
MODEL_ID,
|