> 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 वीडियो जनरेशन

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

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

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

* **टेक्स्ट-टू-वीडियो (T2V)** — एक सीन का वर्णन करें और 6-सेकंड का 720×480 क्लिप 8 fps (49 फ्रेम) पर प्राप्त करें।
* **इमेज-टू-वीडियो (I2V)** — एक रेफ़रेंस इमेज और प्रॉम्प्ट दें; मॉडल उसे समयगत सुसंगतता के साथ एनिमेट करता है।
* **दो स्केल** — CogVideoX-2B (तेज़, \~12 GB VRAM) और CogVideoX-5B (उच्च गुणवत्ता, \~20 GB VRAM)।
* **नेटिव diffusers समर्थन** — प्रथम-श्रेणी `CogVideoXPipeline` और `CogVideoXImageToVideoPipeline` क्लासेस।
* **3D causal VAE** — कुशल डिनॉइज़िंग के लिए 49 फ्रेम्स को एक संकुचित latent स्पेस में संपीड़ित करता है।
* **ओपन वेट्स** — 2B वेरिएंट के लिए Apache-2.0 लाइसेंस; 5B के लिए रिसर्च लाइसेंस।

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

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

**Clore.ai GPU सिफारिश:** एक **RTX 4090** (24 GB, \~$0.5–2/day) आराम से दोनों 2B और 5B वेरिएंट्स को संभालता है। एक **RTX 3090** (24 GB, \~$0.3–1/day) bf16 पर 5B के लिए समान रूप से अच्छा काम करता है और बजट विकल्प है।

## त्वरित प्रारम्भ

```bash
# एनवायरनमेंट बनाएं
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu124
pip install diffusers transformers accelerate sentencepiece imageio[ffmpeg]

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

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

### टेक्स्ट-टू-वीडियो (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 पीक VRAM बचाता है
pipe.vae.enable_tiling()             # 24 GB कार्ड पर 720x480 के लिए आवश्यक

prompt = (
    "सूर्यास्त पर सूरजमुखी के खेत में दौड़ता हुआ सुनहरा रिट्रीवर, "
    "सिनेमाई लाइटिंग, स्लो मोशन, 4K गुणवत्ता"
)

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("Saved retriever_sunset.mp4")
```

### इमेज-टू-वीडियो (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 टाइलिंग सक्षम करें** — बिना `pipe.vae.enable_tiling()` 3D VAE डिकोड के दौरान 24 GB कार्ड पर OOM होगा।
2. **उपयोग करें `enable_model_cpu_offload()`** — आइडल मॉड्यूल्स को स्वचालित रूप से RAM में स्थानांतरित करता है; दीवार-समय में \~10% जोड़ता है पर 4+ GB पीक VRAM बचाता है।
3. **5B के लिए bf16, 2B के लिए fp16** — 5B चेकपॉइंट bf16 में प्रशिक्षित था; fp16 का उपयोग NaN आउटपुट पैदा कर सकता है।
4. **मॉडल्स को बनी हुई रखें** — Clore.ai का पर्सिस्टेंट वॉल्यूम माउंट करें ताकि `/models` और सेट करें `HF_HOME=/models/hf` ताकि वेट्स कंटेनर रिस्टार्ट्स में भी बचें।
5. **रात भर बैच करें** — लंबे प्रॉम्प्ट सूचियों को एक साधारण Python लूप में कतारबद्ध करें; Clore.ai की बिलिंग प्रति-घंटा होती है, इसलिए GPU को संतृप्त करें।
6. **SSH + tmux** — के अंदर जनरेशन चलाएँ `tmux` ताकि एक टूटती कनेक्शन प्रक्रिया को न मार दे।
7. **सही GPU चुनें** — Clore.ai मार्केटप्लेस में ≥24 GB VRAM कार्ड फ़िल्टर करें; सबसे सस्ता उपलब्ध RTX 3090 / 4090 खोजने के लिए कीमत के अनुसार सॉर्ट करें।

## समस्याओं का निवारण

| समस्या                                | समाधान                                                                                                               |
| ------------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
| `OutOfMemoryError` VAE डिकोड के दौरान | कॉल करें `pipe.vae.enable_tiling()` इन्फेरेंस से पहले                                                                |
| 5B के साथ NaN / काले फ्रेम            | स्विच करें `torch.bfloat16`; 5B वेरिएंट के लिए fp16 समर्थित नहीं है                                                  |
| `ImportError: imageio`                | `pip install imageio[ffmpeg]` — MP4 एक्सपोर्ट के लिए ffmpeg प्लगइन आवश्यक है                                         |
| पहला रन बहुत धीमा                     | मॉडल डाउनलोड \~20 GB है; बाद के रन कैश्ड वेट्स का उपयोग करते हैं                                                     |
| CUDA संस्करण mismatch                 | सुनिश्चित करें कि PyTorch CUDA संस्करण ड्राइवर से मेल खाता है: `python -c "import torch; print(torch.version.cuda)"` |
| बिगड़ी हुई गति / फ्लिकरिंग            | बढ़ाएँ `num_inference_steps` 50 तक; कम `guidance_scale` 5.0 तक                                                       |
| डाउनलोड के बीच में कंटेनर बंद हुआ     | सेट करें `HF_HOME` एक पर्सिस्टेंट वॉल्यूम पर सेट करें और रिस्टार्ट करें — आंशिक डाउनलोड स्वतः पुन: आरंभ होते हैं     |


---

# 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.
