From 34fc9add0a01e4f0224dd13952460223819fafaf Mon Sep 17 00:00:00 2001 From: pftq Date: Fri, 13 Jun 2025 22:33:13 -0700 Subject: [PATCH 1/4] Fixed multi-gpu error in gradio from gpu_infer cast type: 'str' object cannot be interpreted as an integer --- vace/models/wan/wan_vace.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vace/models/wan/wan_vace.py b/vace/models/wan/wan_vace.py index d388c50..3c303f8 100644 --- a/vace/models/wan/wan_vace.py +++ b/vace/models/wan/wan_vace.py @@ -471,7 +471,7 @@ def __init__( def dynamic_load(self): if hasattr(self, 'inference_pids') and self.inference_pids is not None: return - gpu_infer = os.environ.get('LOCAL_WORLD_SIZE') or torch.cuda.device_count() + gpu_infer = int(os.environ.get('LOCAL_WORLD_SIZE', torch.cuda.device_count())) pmi_rank = int(os.environ['RANK']) pmi_world_size = int(os.environ['WORLD_SIZE']) in_q_list = [torch.multiprocessing.Manager().Queue() for _ in range(gpu_infer)] From 614b855e4ed32bfb2d709760e30ba5fe7b136a34 Mon Sep 17 00:00:00 2001 From: pftq Date: Fri, 13 Jun 2025 23:04:19 -0700 Subject: [PATCH 2/4] Fix timeout in multi-gpu gradio from hardcoded port and world size --- vace/models/wan/wan_vace.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/vace/models/wan/wan_vace.py b/vace/models/wan/wan_vace.py index 3c303f8..4333ea4 100644 --- a/vace/models/wan/wan_vace.py +++ b/vace/models/wan/wan_vace.py @@ -445,10 +445,11 @@ def __init__( self.config = config self.checkpoint_dir = checkpoint_dir self.use_usp = use_usp - os.environ['MASTER_ADDR'] = 'localhost' - os.environ['MASTER_PORT'] = '12345' - os.environ['RANK'] = '0' - os.environ['WORLD_SIZE'] = '1' + if ulysses_size is None or ulysses_size == 1: # 20250613 pftq: fix multi-gpu gradio timeout + os.environ['MASTER_ADDR'] = 'localhost' + os.environ['MASTER_PORT'] = '12345' + os.environ['RANK'] = '0' + os.environ['WORLD_SIZE'] = '1' self.in_q_list = None self.out_q = None self.inference_pids = None From e29647016871cfe3fe07ebb22d2ba5425775675f Mon Sep 17 00:00:00 2001 From: pftq Date: Fri, 13 Jun 2025 23:38:56 -0700 Subject: [PATCH 3/4] Update wan_vace.py --- vace/models/wan/wan_vace.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/vace/models/wan/wan_vace.py b/vace/models/wan/wan_vace.py index 4333ea4..3c303f8 100644 --- a/vace/models/wan/wan_vace.py +++ b/vace/models/wan/wan_vace.py @@ -445,11 +445,10 @@ def __init__( self.config = config self.checkpoint_dir = checkpoint_dir self.use_usp = use_usp - if ulysses_size is None or ulysses_size == 1: # 20250613 pftq: fix multi-gpu gradio timeout - os.environ['MASTER_ADDR'] = 'localhost' - os.environ['MASTER_PORT'] = '12345' - os.environ['RANK'] = '0' - os.environ['WORLD_SIZE'] = '1' + os.environ['MASTER_ADDR'] = 'localhost' + os.environ['MASTER_PORT'] = '12345' + os.environ['RANK'] = '0' + os.environ['WORLD_SIZE'] = '1' self.in_q_list = None self.out_q = None self.inference_pids = None From 6f4b734bcbda5e0a957b1921faaa8ccaf40c5194 Mon Sep 17 00:00:00 2001 From: pftq Date: Sat, 14 Jun 2025 00:03:31 -0700 Subject: [PATCH 4/4] Allow user-specified width, height, and frame count in gradio. --- vace/gradios/vace_wan_demo.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/vace/gradios/vace_wan_demo.py b/vace/gradios/vace_wan_demo.py index 19ec224..a7c8be5 100644 --- a/vace/gradios/vace_wan_demo.py +++ b/vace/gradios/vace_wan_demo.py @@ -208,7 +208,8 @@ def generate(self, output_gallery, src_video, src_mask, src_ref_image_1, src_ref [src_mask], [src_ref_images], num_frames=num_frames, - image_size=SIZE_CONFIGS[f"{output_width}*{output_height}"], + #image_size=SIZE_CONFIGS[f"{output_width}*{output_height}"], + image_size=(output_width, output_height), # 20250613 pftq: Use width/height from user input device=self.pipe.device) video = self.pipe.generate( prompt, @@ -216,6 +217,7 @@ def generate(self, output_gallery, src_video, src_mask, src_ref_image_1, src_ref src_mask, src_ref_images, size=(output_width, output_height), + frame_num = num_frames, # 20250613 pftq: Use frame number input from user input context_scale=context_scale, shift=shift_scale, sampling_steps=sample_steps, @@ -224,8 +226,11 @@ def generate(self, output_gallery, src_video, src_mask, src_ref_image_1, src_ref seed=infer_seed, offload_model=True) - name = '{0:%Y%m%d%H%M%S}'.format(datetime.datetime.now()) - video_path = os.path.join(self.save_dir, f'cur_gallery_{name}.mp4') + #name = '{0:%Y%m%d%H%M%S}'.format(datetime.datetime.now()) + #video_path = os.path.join(self.save_dir, f'cur_gallery_{name}.mp4') + # 20250613 pftq: friendlier filenames + name = datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S")+f'_wan-vace_context-{context_scale}_cfg-{guide_scale}_steps-{sample_steps}_seed-{infer_seed}' + video_path = os.path.join(self.save_dir, f'{name}.mp4') video_frames = (torch.clamp(video / 2 + 0.5, min=0.0, max=1.0).permute(1, 2, 3, 0) * 255).cpu().numpy().astype(np.uint8) try: