modelscope / modelscope/DiffSynth-Studio

Facing issue while running Wan14B on Mutli GPU

Open
#659 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
13.1k
Forks
1.3k
Avg merge
13h 12m
Merged PRs (30d)
45

Description

Hi Team, Thanks for your work but I am not able to run the 14B model using the step given.

I have 8 gpu with 24GB ram.

Cmd used:
torchrun --standalone --nproc_per_node=8 examples/wanvideo/acceleration/unified_sequence_parallel.py

Code used:

import torch
from PIL import Image
from diffsynth import save_video, VideoData
from diffsynth.pipelines.wan_video_new import WanVideoPipeline, ModelConfig
import torch.distributed as dist


pipe = WanVideoPipeline.from_pretrained(
    torch_dtype=torch.bfloat16,
    device="cuda",
    use_usp=True,
    skip_download = True,
    redirect_common_files = False,
    model_configs=[
        ModelConfig(path = [
            "/data/akshay/wan/Wan2.1-T2V-14B/diffusion_pytorch_model-00001-of-00006.safetensors",
            "/data/akshay/wan/Wan2.1-T2V-14B/diffusion_pytorch_model-00002-of-00006.safetensors",
            "/data/akshay/wan/Wan2.1-T2V-14B/diffusion_pytorch_model-00003-of-00006.safetensors",
            "/data/akshay/wan/Wan2.1-T2V-14B/diffusion_pytorch_model-00004-of-00006.safetensors",
            "/data/akshay/wan/Wan2.1-T2V-14B/diffusion_pytorch_model-00005-of-00006.safetensors",
            "/data/akshay/wan/Wan2.1-T2V-14B/diffusion_pytorch_model-00006-of-00006.safetensors",
        ], offload_device="cpu"),
        ModelConfig(path = "/data/akshay/wan/Wan2.1-T2V-14B/models_t5_umt5-xxl-enc-bf16.pth", offload_device="cpu"),
        ModelConfig(path = "/data/akshay/wan/Wan2.1-T2V-14B/Wan2.1_VAE.pth", offload_device="cpu"),
    
    ],
)

print('loading complete')
pipe.enable_vram_management()


video = pipe(
    prompt="一名宇航员身穿太空服,面朝镜头骑着一匹机械马在火星表面驰骋。红色的荒凉地表延伸至远方,点缀着巨大的陨石坑和奇特的岩石结构。机械马的步伐稳健,扬起微弱的尘埃,展现出未来科技与原始探索的完美结合。宇航员手持操控装置,目光坚定,仿佛正在开辟人类的新疆域。背景是深邃的宇宙和蔚蓝的地球,画面既科幻又充满希望,让人不禁畅想未来的星际生活。",
    negative_prompt="色调艳丽,过曝,静态,细节模糊不清,字幕,风格,作品,画作,画面,静止,整体发灰,最差质量,低质量,JPEG压缩残留,丑陋的,残缺的,多余的手指,画得不好的手部,画得不好的脸部,畸形的,毁容的,形态畸形的肢体,手指融合,静止不动的画面,杂乱的背景,三条腿,背景人很多,倒着走",
    seed=0, tiled=True,
)
if dist.get_rank() == 0:
    save_video(video, "video1.mp4", fps=15, quality=5)

Error:

Traceback (most recent call last):
[rank5]:   File "/data/akshay/wan/DiffSynth-Studio/examples/wanvideo/acceleration/unified_sequence_parallel.py", line 51, in <module>
[rank5]:     pipe.enable_vram_management()
[rank5]:   File "/data/akshay/wan/DiffSynth-Studio/diffsynth/pipelines/wan_video_new.py", line 278, in enable_vram_management
[rank5]:     vram_limit = self.get_vram()
[rank5]:                  ^^^^^^^^^^^^^^^
[rank5]:   File "/data/akshay/wan/DiffSynth-Studio/diffsynth/pipelines/wan_video_new.py", line 147, in get_vram
[rank5]:     return torch.cuda.mem_get_info(self.device)[1] / (1024 ** 3)
[rank5]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank5]:   File "/opt/conda/lib/python3.11/site-packages/torch/cuda/memory.py", line 684, in mem_get_info
[rank5]:     device = _get_device_index(device)
[rank5]:              ^^^^^^^^^^^^^^^^^^^^^^^^^
[rank5]:   File "/opt/conda/lib/python3.11/site-packages/torch/cuda/_utils.py", line 38, in _get_device_index
[rank5]:     return _torch_get_device_index(device, optional, allow_cpu)
[rank5]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[rank5]:   File "/opt/conda/lib/python3.11/site-packages/torch/_utils.py", line 803, in _get_device_index
[rank5]:     raise ValueError(
[rank5]: ValueError: Expected a torch.device with a specified index or an integer, but got:cuda

Can you please help me with this?
Thanks

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with examples/wanvideo/acceleration/unified_sequence_parallel.py and inspect diffsynth/pipelines/wan_video_new.py at get_vram and enable_vram_management, then reproduce the supplied torchrun command. Trace how the pipeline device is set across ranks; done means the multi-GPU example passes vram management without the reported torch.cuda.mem_get_info ValueError.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
distributed-systems, machine-learning
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.