Gregniuki commited on
Commit
c50bf62
·
verified ·
1 Parent(s): 4b04fc7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -1
app.py CHANGED
@@ -38,13 +38,25 @@ def gpu_decorator(func):
38
  else:
39
  return func
40
 
 
41
  device = (
42
  "cuda"
43
  if torch.cuda.is_available()
44
  else "mps" if torch.backends.mps.is_available() else "cpu"
45
  )
46
 
47
- print(f"Using {device} device")
 
 
 
 
 
 
 
 
 
 
 
48
 
49
  pipe = pipeline(
50
  "automatic-speech-recognition",
 
38
  else:
39
  return func
40
 
41
+ # Determine the device
42
  device = (
43
  "cuda"
44
  if torch.cuda.is_available()
45
  else "mps" if torch.backends.mps.is_available() else "cpu"
46
  )
47
 
48
+ # Set dtype: float16 for GPU, bfloat16 for CPU, and default to float32 for other cases
49
+ if device == "cuda":
50
+ dtype = torch.float16
51
+ elif device == "cpu":
52
+ dtype = torch.bfloat16
53
+ else:
54
+ dtype = torch.float32
55
+
56
+ # Create the torch.device object
57
+ device = torch.device(device)
58
+
59
+ print(f"Using device: {device}, dtype: {dtype}")
60
 
61
  pipe = pipeline(
62
  "automatic-speech-recognition",