Commit ·
f8b59b5
1
Parent(s): 6d556cb
Fix CLAP from_pretrained daemonic process error in ZeroGPU worker
Browse filesMonkey-patch multiprocessing.Process.start to run inline before calling
ClapTextModelWithProjection.from_pretrained(), restoring it immediately
after. Prevents transformers from forking a subprocess for safe-tensor
verification, which fails in ZeroGPU daemonic workers.
HunyuanVideo-Foley/hunyuanvideo_foley/utils/model_utils.py
CHANGED
|
@@ -319,9 +319,22 @@ def load_model(model_path, config_path, device, enable_offload=False, model_size
|
|
| 319 |
logger.info("SigLIP2 model and preprocessing pipeline loaded successfully")
|
| 320 |
|
| 321 |
# clap text-encoder
|
|
|
|
|
|
|
|
|
|
|
|
|
| 322 |
logger.info("Loading CLAP text encoder...")
|
| 323 |
-
|
| 324 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 325 |
logger.info("CLAP tokenizer and model loaded successfully")
|
| 326 |
|
| 327 |
# syncformer
|
|
|
|
| 319 |
logger.info("SigLIP2 model and preprocessing pipeline loaded successfully")
|
| 320 |
|
| 321 |
# clap text-encoder
|
| 322 |
+
# Transformers' from_pretrained() spawns a subprocess for safe-tensor
|
| 323 |
+
# verification, which fails inside ZeroGPU's daemonic worker process.
|
| 324 |
+
# Monkey-patch multiprocessing.Process.start to run the target inline
|
| 325 |
+
# instead of forking, then restore it immediately after.
|
| 326 |
logger.info("Loading CLAP text encoder...")
|
| 327 |
+
import multiprocessing as _mp
|
| 328 |
+
_orig_start = _mp.Process.start
|
| 329 |
+
def _inline_start(self):
|
| 330 |
+
if self._target:
|
| 331 |
+
self._target(*self._args, **self._kwargs)
|
| 332 |
+
_mp.Process.start = _inline_start
|
| 333 |
+
try:
|
| 334 |
+
clap_tokenizer = AutoTokenizer.from_pretrained("laion/larger_clap_general")
|
| 335 |
+
clap_model = ClapTextModelWithProjection.from_pretrained("laion/larger_clap_general").to(device)
|
| 336 |
+
finally:
|
| 337 |
+
_mp.Process.start = _orig_start
|
| 338 |
logger.info("CLAP tokenizer and model loaded successfully")
|
| 339 |
|
| 340 |
# syncformer
|