fix: 避免在 MinGW-w64 环境 jit compile cuda ext
This commit is contained in:
parent
59c05c0765
commit
92bb2eb0c0
@ -2,9 +2,10 @@
|
||||
# Licensed under the MIT license.
|
||||
|
||||
import os
|
||||
import sys
|
||||
import pathlib
|
||||
import subprocess
|
||||
|
||||
import platform
|
||||
from torch.utils import cpp_extension
|
||||
|
||||
"""
|
||||
@ -46,11 +47,16 @@ def chinese_path_compile_support(sources, buildpath):
|
||||
|
||||
|
||||
def load(force_rebuild=False):
|
||||
import torch
|
||||
if not torch.cuda.is_available():
|
||||
raise RuntimeError("Please install PyTorch with CUDA support to use the anti_alias_activation_cuda extension.")
|
||||
try:
|
||||
from indextts.BigVGAN.alias_free_activation.cuda import anti_alias_activation_cuda
|
||||
if not force_rebuild: return anti_alias_activation_cuda
|
||||
if not force_rebuild:
|
||||
return anti_alias_activation_cuda
|
||||
except ImportError:
|
||||
anti_alias_activation_cuda = None
|
||||
|
||||
module_name = "anti_alias_activation_cuda"
|
||||
# Build path
|
||||
srcpath = pathlib.Path(__file__).parent.absolute()
|
||||
@ -68,6 +74,14 @@ def load(force_rebuild=False):
|
||||
assert isinstance(spec.loader, importlib.abc.Loader)
|
||||
spec.loader.exec_module(module)
|
||||
return module
|
||||
|
||||
if platform.system() == "Windows" and "MINGW64" in os.environ.get("MSYSTEM", ""):
|
||||
# 在 MinGW-w64 (如 Git Bash) 环境下编译 CUDA 扩展可能会阻塞或失败
|
||||
# https://github.com/index-tts/index-tts/issues/172#issuecomment-2914995096
|
||||
print("Warning: Detected running in MinGW-w64 (e.g., Git Bash). CUDA extension build is not supported in this environment.", file=sys.stderr)
|
||||
raise RuntimeError(
|
||||
"Please use Command Prompt (cmd) or PowerShell to compile the anti_alias_activation_cuda extension."
|
||||
)
|
||||
if not cpp_extension.CUDA_HOME:
|
||||
raise RuntimeError(cpp_extension.CUDA_NOT_FOUND_MESSAGE)
|
||||
cpp_extension.verify_ninja_availability()
|
||||
|
||||
@ -102,8 +102,9 @@ class IndexTTS:
|
||||
print(">> Preload custom CUDA kernel for BigVGAN", anti_alias_activation_cuda)
|
||||
except Exception as e:
|
||||
print(">> Failed to load custom CUDA kernel for BigVGAN. Falling back to torch.", e, file=sys.stderr)
|
||||
print(" Reinstall with `pip install -e . --no-deps --no-build-isolation` to prebuild `anti_alias_activation_cuda` kernel.", file=sys.stderr)
|
||||
print(
|
||||
"See more details: https://github.com/index-tts/index-tts/issues/164#issuecomment-2903453206"
|
||||
"See more details: https://github.com/index-tts/index-tts/issues/164#issuecomment-2903453206", file=sys.stderr
|
||||
)
|
||||
self.use_cuda_kernel = False
|
||||
self.bigvgan = Generator(self.cfg.bigvgan, use_cuda_kernel=self.use_cuda_kernel)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user