Use without deepspeed (#280)

Use without deepspeed
This commit is contained in:
十字鱼 2025-09-08 22:09:26 +08:00 committed by GitHub
parent 474ec9b6cf
commit 9d4776b082
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -81,17 +81,22 @@ class IndexTTS2:
self.gpt.eval()
print(">> GPT weights restored from:", self.gpt_path)
if self.is_fp16:
use_deepspeed = True
try:
import deepspeed
use_deepspeed = True
except (ImportError, OSError, CalledProcessError) as e:
use_deepspeed = False
print(f">> DeepSpeed加载失败回退到标准推理: {e}")
self.gpt.post_init_gpt2_config(use_deepspeed=use_deepspeed, kv_cache=True, half=True)
else:
self.gpt.post_init_gpt2_config(use_deepspeed=True, kv_cache=True, half=False)
use_deepspeed = True
try:
import deepspeed
except (ImportError, OSError, CalledProcessError) as e:
use_deepspeed = False
print(f">> DeepSpeed加载失败回退到标准推理: {e}")
self.gpt.post_init_gpt2_config(use_deepspeed=use_deepspeed, kv_cache=True, half=False)
if self.use_cuda_kernel:
# preload the CUDA kernel for BigVGAN