> For the complete documentation index, see [llms.txt](https://docs.clore.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.clore.ai/guides/guides_v2-hi/video-generation/cogvideox.md).

# CogVideoX वीडियो जनरेशन

Clore.ai GPUs पर Zhipu AI के CogVideoX diffusion transformer के साथ टेक्स्ट या छवियों से 6-सेकंड के वीडियो जनरेट करें।

CogVideoX Zhipu AI (Tsinghua) के open-weight video diffusion transformers का एक परिवार है। मॉडल टेक्स्ट प्रॉम्प्ट (T2V) या संदर्भ छवि + प्रॉम्प्ट (I2V) से 720×480 रिज़ॉल्यूशन और 8 fps पर 6-सेकंड की सुसंगत क्लिप्स बनाते हैं। दो पैरामीटर स्केल उपलब्ध हैं — तेज़ iteration के लिए 2B और अधिक fidelity के लिए 5B — दोनों के साथ नेटिव `diffusers` के माध्यम से इंटीग्रेशन `CogVideoXPipeline`.

से किराये के GPU पर CogVideoX चलाना [Clore.ai](https://clore.ai/) से आप स्थानीय हार्डवेयर सीमाओं को छोड़ सकते हैं और प्रति क्लिप कुछ पैसे में बड़े पैमाने पर वीडियो जनरेट कर सकते हैं।

## मुख्य विशेषताएँ

* **Text-to-Video (T2V)** — एक दृश्य का वर्णन करें और 8 fps (49 frames) पर 720×480 की 6-सेकंड क्लिप प्राप्त करें।
* **Image-to-Video (I2V)** — एक संदर्भ छवि और प्रॉम्प्ट दें; मॉडल इसे temporal consistency के साथ animate करता है।
* **दो स्केल** — CogVideoX-2B (तेज़, \~12 GB VRAM) और CogVideoX-5B (उच्च गुणवत्ता, \~20 GB VRAM)।
* **नेटिव diffusers सपोर्ट** — first-class `CogVideoXPipeline` और `CogVideoXImageToVideoPipeline` क्लासें।
* **3D causal VAE** — कुशल denoising के लिए 49 frames को एक कॉम्पैक्ट latent space में compress करता है।
* **ओपन वेट्स** — 2B वेरिएंट के लिए Apache-2.0 लाइसेंस; 5B के लिए research license।

## आवश्यकताएँ

| घटक        | न्यूनतम          | अनुशंसित         |
| ---------- | ---------------- | ---------------- |
| GPU VRAM   | 16 GB (2B, fp16) | 24 GB (5B, bf16) |
| System RAM | 32 GB            | 64 GB            |
| डिस्क      | 30 GB            | 50 GB            |
| Python     | 3.10+            | 3.11             |
| CUDA       | 12.8+            | 12.8+            |

**Clore.ai GPU अनुशंसा:** एक **RTX 4090** (24 GB, $0.14–0.42/घंटा) 2B और 5B दोनों वेरिएंट को आराम से संभालता है। एक **RTX 3090** (24 GB, $0.07–0.21/घंटा) bf16 पर 5B के लिए भी उतना ही अच्छा काम करता है और बजट विकल्प है।

## त्वरित शुरुआत

```bash
# वातावरण बनाएँ
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu128
pip install diffusers transformers accelerate sentencepiece imageio[ffmpeg]

# GPU सत्यापित करें
python -c "import torch; print(torch.cuda.get_device_name(0))"
```

## उपयोग के उदाहरण

### Text-to-Video (5B)

```python
import torch
from diffusers import CogVideoXPipeline
from diffusers.utils import export_to_video

pipe = CogVideoXPipeline.from_pretrained(
    "THUDM/CogVideoX-5b",
    torch_dtype=torch.bfloat16,
)
pipe.to("cuda")
pipe.enable_model_cpu_offload()      # ~4 GB peak VRAM बचाता है
pipe.vae.enable_tiling()             # 24 GB कार्डों पर 720x480 के लिए आवश्यक

prompt = (
    "सूर्यास्त के समय सूरजमुखी के खेत में दौड़ता हुआ गोल्डन रिट्रीवर, "
    "cinematic lighting, slow motion, 4K quality"
)

video_frames = pipe(
    prompt=prompt,
    num_frames=49,
    guidance_scale=6.0,
    num_inference_steps=50,
    generator=torch.Generator("cuda").manual_seed(42),
).frames[0]

export_to_video(video_frames, "retriever_sunset.mp4", fps=8)
print("retriever_sunset.mp4 सहेजा गया")
```

### Image-to-Video (5B)

```python
import torch
from PIL import Image
from diffusers import CogVideoXImageToVideoPipeline
from diffusers.utils import export_to_video

pipe = CogVideoXImageToVideoPipeline.from_pretrained(
    "THUDM/CogVideoX-5b-I2V",
    torch_dtype=torch.bfloat16,
)
pipe.to("cuda")
pipe.enable_model_cpu_offload()
pipe.vae.enable_tiling()

image = Image.open("reference.png").resize((720, 480))

video_frames = pipe(
    prompt="कैमरा धीरे-धीरे विषय के चारों ओर घूमता है, हल्की हवा",
    image=image,
    num_frames=49,
    guidance_scale=6.0,
    num_inference_steps=50,
).frames[0]

export_to_video(video_frames, "animated.mp4", fps=8)
```

### 2B वेरिएंट के साथ तेज़ जनरेशन

```python
from diffusers import CogVideoXPipeline
import torch

pipe = CogVideoXPipeline.from_pretrained(
    "THUDM/CogVideoX-2b",
    torch_dtype=torch.float16,
)
pipe.to("cuda")
pipe.vae.enable_tiling()

frames = pipe(
    prompt="खिलते चेरी ब्लॉसम पेड़ का टाइम-लैप्स",
    num_frames=49,
    guidance_scale=6.0,
    num_inference_steps=30,       # कम स्टेप्स → तेज़
).frames[0]
```

## Clore.ai उपयोगकर्ताओं के लिए सुझाव

1. **VAE tiling सक्षम करें** — बिना `pipe.vae.enable_tiling()` decode के दौरान 24 GB कार्डों पर 3D VAE मेमोरी से बाहर हो जाएगा।
2. **उपयोग करें `enable_model_cpu_offload()`** — निष्क्रिय मॉड्यूल्स को अपने-आप RAM में शिफ्ट करता है; कुल समय में \~10 % जोड़ता है लेकिन 4+ GB पीक VRAM बचाता है।
3. **5B के लिए bf16, 2B के लिए fp16** — 5B checkpoint को bf16 में प्रशिक्षित किया गया था; fp16 का उपयोग करने से NaN outputs हो सकते हैं।
4. **मॉडल्स को स्थायी रखें** — एक Clore.ai persistent volume को माउंट करें `/models` और सेट करें `HF_HOME=/models/hf` ताकि weights container restarts के बाद भी बने रहें।
5. **रात भर batch करें** — लंबे prompt lists को एक सरल Python loop से queue करें; Clore.ai billing hourly है, इसलिए GPU को पूरी तरह उपयोग करें।
6. **SSH + tmux** — जनरेशन को अंदर चलाएँ `tmux` ताकि कनेक्शन टूटने पर process बंद न हो।
7. **सही GPU चुनें** — Clore.ai marketplace को ≥24 GB VRAM कार्डों के लिए filter करें; उपलब्ध सबसे सस्ते RTX 3090 / 4090 को खोजने के लिए price के अनुसार sort करें।

## समस्या निवारण

| समस्या                                  | ठीक करें                                                                                                            |
| --------------------------------------- | ------------------------------------------------------------------------------------------------------------------- |
| `OutOfMemoryError` VAE decode के दौरान  | Call करें `pipe.vae.enable_tiling()` inference से पहले                                                              |
| 5B के साथ NaN / काले frames             | इसे बदलें `torch.bfloat16`; 5B वेरिएंट के लिए fp16 समर्थित नहीं है                                                  |
| `ImportError: imageio`                  | `pip install imageio[ffmpeg]` — MP4 export के लिए ffmpeg plugin की आवश्यकता है                                      |
| पहली run बहुत धीमी है                   | Model download \~20 GB का है; बाद की runs cached weights का उपयोग करती हैं                                          |
| CUDA version mismatch                   | सुनिश्चित करें कि PyTorch CUDA version driver से मेल खाता हो: `python -c "import torch; print(torch.version.cuda)"` |
| टूटी-फूटी motion / flickering           | बढ़ाएँ `num_inference_steps` को 50 तक; कम करें `guidance_scale` को 5.0                                              |
| Container डाउनलोड के बीच में बंद हो गया | सेट करें `HF_HOME` को एक persistent volume पर सेट करें और restart करें — आंशिक downloads अपने-आप resume हो जाती हैं |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.clore.ai/guides/guides_v2-hi/video-generation/cogvideox.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
