Instructions to use zai-org/CogVideoX1.5-5B-I2V with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use zai-org/CogVideoX1.5-5B-I2V with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline from diffusers.utils import load_image, export_to_video # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("zai-org/CogVideoX1.5-5B-I2V", dtype=torch.bfloat16, device_map="cuda") pipe.to("cuda") prompt = "A man with short gray hair plays a red electric guitar." image = load_image( "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/guitar-man.png" ) output = pipe(image=image, prompt=prompt).frames[0] export_to_video(output, "output.mp4") - Notebooks
- Google Colab
- Kaggle
torch.OutOfMemoryError
I used the given sample program, but there seems to be a problem, he actually has to allocate 700 + GiB of memory, I am not sure if this is correct
torch.OutOfMemoryError: CUDA out of memory. Tried to allocate 727.61 GiB. GPU 0 has a total capacity of 31.75 GiB of which 22.86 GiB is free. Process 2853 has 8.88 GiB memory in use. Of the allocated memory 8.39 GiB is allocated by PyTorch, and 129.11 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)
What worked for us was
in
from_pretrainedon a dual 24gb setupdevice_map="balanced", max_memory={0:"24GiB",1:"24GiB"}then as instructed comment out
#pipe.enable_sequential_cpu_offload()but don't add back apipe.to("cuda")since it will default to that and was getting confused when included
Generated these:
Based on this source FLUX frame:
https://liaise.cloud/bob?node=BOB:4UsGAcaVUh8m9Eza52HL8NrgGi9uNzQchc2Nz38CwQzU:2003994:1734790309441:2kzml8nz6etew7ykuihtugvcm57wypuelbibeimik6gk