mirror of
https://github.com/RVC-Boss/GPT-SoVITS.git
synced 2026-09-15 05:35:42 +08:00
Merge 1b8059cf610c1e89bd7798cab721145ea1fc50a6 into 48b1a0169a28582a8984402f82cf438d3bfa6aca
This commit is contained in:
commit
1e150aef3c
@ -27,7 +27,15 @@ logging.config.dictConfig(uvicorn.config.LOGGING_CONFIG)
|
||||
logger = logging.getLogger("uvicorn")
|
||||
|
||||
is_half = True
|
||||
device = "cuda" if torch.cuda.is_available() else "cpu"
|
||||
# Detect the current accelerator (CUDA, NPU, XPU, MPS, …) in a device-agnostic way.
|
||||
# Using torch.accelerator (available since PyTorch 2.5) ensures the script works
|
||||
# out of the box on Ascend NPU, Intel XPU, Apple MPS, etc. without hard-coding
|
||||
# "cuda". Falls back to the traditional CUDA-or-CPU heuristic when torch.accelerator
|
||||
# is not available (PyTorch < 2.5).
|
||||
if hasattr(torch, "accelerator") and torch.accelerator.is_available():
|
||||
device = str(torch.accelerator.current_accelerator())
|
||||
else:
|
||||
device = "cuda" if torch.cuda.is_available() else "cpu"
|
||||
now_dir = os.getcwd()
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user