Auto-scale hardware: CUDA 13 only on cc>=7.5, pin ctranslate2 4.8 (cu12), fp16-less GPUs, CPU threads, llama --fit on >=7 GiB GPUs, CPU-only embeddings
This commit is contained in:
+4
-2
@@ -8,12 +8,14 @@ for sp in site.getsitepackages():
|
||||
|
||||
from faster_whisper import WhisperModel
|
||||
|
||||
CORES = max(1, (os.cpu_count() or 2) // 2) # ponytail: logical/2 ~ physical cores (no psutil); exact count if hybrid CPUs need it
|
||||
|
||||
def load_model(name):
|
||||
"""CUDA if it really works (probe one decode), else CPU int8."""
|
||||
try:
|
||||
m = WhisperModel(name, device="cuda", compute_type="float16")
|
||||
m = WhisperModel(name, device="cuda", compute_type="default")
|
||||
list(m.transcribe(np.zeros(16000, np.float32))[0])
|
||||
return m, "cuda"
|
||||
except Exception as e:
|
||||
print("cuda failed, using cpu:", e, flush=True)
|
||||
return WhisperModel(name, device="cpu", compute_type="int8"), "cpu"
|
||||
return WhisperModel(name, device="cpu", compute_type="int8", cpu_threads=CORES), "cpu"
|
||||
|
||||
Reference in New Issue
Block a user