rahul7star commited on
Commit
851663b
·
verified ·
1 Parent(s): fc72e9f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -0
app.py CHANGED
@@ -6,6 +6,26 @@ from pydantic import BaseModel
6
  from fastapi.responses import FileResponse, HTMLResponse
7
 
8
  from src.chatterbox.mtl_tts import ChatterboxMultilingualTTS, SUPPORTED_LANGUAGES
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
  # -------------------------------------------------
11
  # App
 
6
  from fastapi.responses import FileResponse, HTMLResponse
7
 
8
  from src.chatterbox.mtl_tts import ChatterboxMultilingualTTS, SUPPORTED_LANGUAGES
9
+ import os
10
+ os.environ["CUDA_VISIBLE_DEVICES"] = ""
11
+ os.environ["TORCH_FORCE_CPU"] = "1"
12
+
13
+ import torch
14
+
15
+ # ===============================
16
+ # HARD FORCE CPU torch.load
17
+ # ===============================
18
+ _original_torch_load = torch.load
19
+
20
+ def cpu_only_torch_load(*args, **kwargs):
21
+ # Force CPU regardless of how torch.load is called
22
+ kwargs["map_location"] = torch.device("cpu")
23
+ return _original_torch_load(*args, **kwargs)
24
+
25
+ torch.load = cpu_only_torch_load
26
+
27
+ # Extra safety: disable CUDA completely
28
+ torch.cuda.is_available = lambda: False
29
 
30
  # -------------------------------------------------
31
  # App