Bug: CPU loading fails when device=torch.device("cpu")
Environment:
- Windows 11
- Python 3.11
- CPU-only machine
Code:
from chatterbox.mtl_tts import ChatterboxMultilingualTTS import torch
model = ChatterboxMultilingualTTS.from_pretrained( device=torch.device("cpu") )
Result:
RuntimeError: Attempting to deserialize object on a CUDA device but torch.cuda.is_available() is False
Cause:
In D:\chatterbox\Lib\site-packages\chatterbox\mtl_tts.py In from_local():
if device in ["cpu", "mps"]: map_location = torch.device("cpu") else: map_location = None
When device is torch.device("cpu"), the condition evaluates to False.
Fix
Instead of
if device in ["cpu", "mps"]: map_location = torch.device("cpu") else: map_location = None
replace:
if str(device) in ["cpu", "mps"]: map_location = torch.device("cpu") else: map_location = None
Source: resemble-ai/chatterbox