Yixuan Li
commited on
Commit
·
8221cd6
1
Parent(s):
f634dc4
forcing torch.load to CPU
Browse files
app.py
CHANGED
|
@@ -7,7 +7,13 @@ import soundfile as sf
|
|
| 7 |
import torch
|
| 8 |
device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
| 9 |
_old_load = torch.load
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
import torchaudio
|
| 13 |
import hydra
|
|
|
|
| 7 |
import torch
|
| 8 |
device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
| 9 |
_old_load = torch.load
|
| 10 |
+
|
| 11 |
+
def safe_torch_load(*args, **kwargs):
|
| 12 |
+
if 'map_location' not in kwargs:
|
| 13 |
+
kwargs['map_location'] = device
|
| 14 |
+
return _old_load(*args, **kwargs)
|
| 15 |
+
|
| 16 |
+
torch.load = safe_torch_load
|
| 17 |
|
| 18 |
import torchaudio
|
| 19 |
import hydra
|