Skip to content

5090 上执行单卡推理报OOM #563

@lmhahatest

Description

@lmhahatest

5090 上执行python3 generate.py --task t2v-14B --size 480*832 --frame_num 1 --ckpt_dir ./Wan2.1-T2V-14B --offload_model True --t5_cpu --sample_steps 10 --prompt "Two anthropomorphic cats in comfy boxing gear and bright gloves fight intensely on a spotlighted stage."

GPU上显示容量够
nvidia-smi -i 0 --query-gpu=memory.total,memory.used,memory.free --format=csv
memory.total [MiB], memory.used [MiB], memory.free [MiB]
32607 MiB, 0 MiB, 32121 MiB

但是报OOM

Traceback (most recent call last):
File "/home/Wan2.1/generate.py", line 587, in
generate(args)
File "/home/Wan2.1/generate.py", line 360, in generate
wan_t2v = wan.WanT2V(
File "/home/Wan2.1/wan/text2video.py", line 111, in init
self.model.to(self.device)
File "/usr/local/lib/python3.10/dist-packages/diffusers/models/modeling_utils.py", line 1435, in to
return super().to(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1371, in to
return self._apply(convert)
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 930, in _apply
module._apply(fn)
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 930, in _apply
module._apply(fn)
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 930, in _apply
module._apply(fn)
[Previous line repeated 1 more time]
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 957, in _apply
param_applied = fn(param)
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1357, in convert
return t.to(
torch.OutOfMemoryError: CUDA out of memory. Tried to allocate 100.00 MiB. GPU 0 has a total capacity of 31.37 GiB of which 47.81 MiB is free. Including non-PyTorch memory, this process has 31.31 GiB memory in use. Of the allocated memory 30.72 GiB is allocated by PyTorch, and 5.09 MiB is reserved by PyTorch but unallocated. If reserved but unallocated memory is large try setting PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True to avoid fragmentation. See documentation for Memory Management (https://pytorch.org/docs/stable/notes/cuda.html#environment-variables)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions