Spaces:
Running
on
Zero
Running
on
Zero
Commit
·
bb03f90
1
Parent(s):
40dfec3
add spaces import and reintroduce GPU decorator for model loading
Browse files
app.py
CHANGED
@@ -4,6 +4,7 @@ import torch
|
|
4 |
import nemo.collections.asr as nemo_asr
|
5 |
from omegaconf import OmegaConf
|
6 |
import time
|
|
|
7 |
|
8 |
# Check if CUDA is available
|
9 |
print(f"CUDA available: {torch.cuda.is_available()}")
|
@@ -11,12 +12,14 @@ if torch.cuda.is_available():
|
|
11 |
print(f"CUDA device: {torch.cuda.get_device_name(0)}")
|
12 |
|
13 |
# Initialize the ASR model - removed spaces.GPU decorator due to pickling issues
|
|
|
14 |
def load_model():
|
15 |
print("Loading ASR model...")
|
16 |
# Load the NVIDIA NeMo ASR model
|
17 |
model = nemo_asr.models.EncDecRNNTBPEModel.from_pretrained("nvidia/parakeet-tdt-0.6b-v2")
|
18 |
# Move model to GPU if available
|
19 |
if torch.cuda.is_available():
|
|
|
20 |
model = model.cuda()
|
21 |
print(f"Model loaded on device: {model.device}")
|
22 |
return model
|
|
|
4 |
import nemo.collections.asr as nemo_asr
|
5 |
from omegaconf import OmegaConf
|
6 |
import time
|
7 |
+
import spaces
|
8 |
|
9 |
# Check if CUDA is available
|
10 |
print(f"CUDA available: {torch.cuda.is_available()}")
|
|
|
12 |
print(f"CUDA device: {torch.cuda.get_device_name(0)}")
|
13 |
|
14 |
# Initialize the ASR model - removed spaces.GPU decorator due to pickling issues
|
15 |
+
@spaces.GPU
|
16 |
def load_model():
|
17 |
print("Loading ASR model...")
|
18 |
# Load the NVIDIA NeMo ASR model
|
19 |
model = nemo_asr.models.EncDecRNNTBPEModel.from_pretrained("nvidia/parakeet-tdt-0.6b-v2")
|
20 |
# Move model to GPU if available
|
21 |
if torch.cuda.is_available():
|
22 |
+
print(f"CUDA device: {torch.cuda.get_device_name(0)}")
|
23 |
model = model.cuda()
|
24 |
print(f"Model loaded on device: {model.device}")
|
25 |
return model
|