Spaces:
Running
Running
zhzluke96 commited on
Commit ·
8a3a4ec
1
Parent(s): 43c9aae
update
Browse files9 unmodified lines1011121314151617181920 unmodified lines40414243444546474849505152539 unmodified lineslogger = logging.getLogger(__name__)chat_tts = None# 某些平台上,不让在主线程中加载模型,否则会出现错误# huggingface Error:# RuntimeError: CUDA must not be initialized in the main process on Spaces with Stateless GPU environment.# You can look at this Stacktrace to find out which part of your code triggered a CUDA initdef load_chat_tts_in_thread():20 unmodified linesdef initialize_chat_tts():model_thread = threading.Thread(target=load_chat_tts_in_thread)model_thread.start()return model_threaddef load_chat_tts():if chat_tts is None:initialize_chat_tts().join()if chat_tts is None:raise Exception("Failed to load ChatTTS models")return chat_tts9 unmodified lines1011121314151620 unmodified lines373839404142434445464748495051529 unmodified lineslogger = logging.getLogger(__name__)chat_tts = Nonelock = threading.Lock()def load_chat_tts_in_thread():20 unmodified linesdef initialize_chat_tts():with lock:if chat_tts is None:model_thread = threading.Thread(target=load_chat_tts_in_thread)model_thread.start()model_thread.join()def load_chat_tts():if chat_tts is None:initialize_chat_tts()if chat_tts is None:raise Exception("Failed to load ChatTTS models")return chat_tts
modules/models.py+7-8