DEV Community

Cover image for Running Nvidia COSMOS on A100 80Gb
Juan Felipe Lujan
Juan Felipe Lujan

Posted on

Running Nvidia COSMOS on A100 80Gb

Video Example
https://youtube.com/shorts/9dOihUzSSho

How to run Nvidia Cosmos on Ubuntu 22.04

In this tutorial, you'll learn how to quickly set up Ubuntu 22.04 to run Nvidia Cosmos. This involves installing the necessary drivers, Docker, and CUDA dependencies.

Thanks to the Google Developers Experts program for providing the infra for this experiment 🧪

Prequisites

  1. Ubuntu 22.04 doh.
  2. A beefy Nvidia GPU. 30Gb+ of VRAM. Either Blackwell, Hopper, or Ampere.
  3. 200Gb+ of local storage.

Step1: Run Script 1

curl -o- https://raw.githubusercontent.com/FelipeLujan/GCPexperiments/refs/heads/master/NvidiaCosmos/prepare_ubuntu%20_part1.sh | bash
Enter fullscreen mode Exit fullscreen mode

Script 1 updates Ubuntu, installs Nvidia drivers, and reboots to finalize changes.

Script 2

Run once your is back up.

curl -o- https://raw.githubusercontent.com/FelipeLujan/GCPexperiments/refs/heads/master/NvidiaCosmos/prepare_ubuntu_part2.sh | bash
Enter fullscreen mode Exit fullscreen mode

Script 2 installs Docker, configures the Nvidia toolkit, then clones and builds the Cosmos repository.

If you see something like this at the end of Script 2, congratulations, your docker container is almost ready to run Cosmos.

+---------------------------------------------------------------------------------------+
| NVIDIA-SMI 535.216.03             Driver Version: 535.216.03   CUDA Version: 12.6     |
|-----------------------------------------+----------------------+----------------------+
| GPU  Name                 Persistence-M | Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |         Memory-Usage | GPU-Util  Compute M. |
|                                         |                      |               MIG M. |
|=========================================+======================+======================|
|   0  NVIDIA A100-SXM4-80GB          Off | 00000000:00:05.0 Off |                    0 |
| N/A   32C    P0              57W / 400W |      0MiB / 81920MiB |     24%      Default |
|                                         |                      |             Disabled |
+-----------------------------------------+----------------------+----------------------+

+---------------------------------------------------------------------------------------+
| Processes:                                                                            |
|  GPU   GI   CI        PID   Type   Process name                            GPU Memory |
|        ID   ID                                                             Usage      |
|=======================================================================================|
|  No running processes found                                                           |
+---------------------------------------------------------------------------------------+
Enter fullscreen mode Exit fullscreen mode

Downloading cosmos models in Docker Container.

At this point, your command line is attached to the costmos_container docker, run huggingface-cli login and insert your Hugging Face Token.

Generate it here https://huggingface.co/settings/tokens you only need to Check grant Read access to contents of all public gated repos you can access

Download only the 7B Text2Video model by running this command.

PYTHONPATH=$(pwd) python cosmos1/scripts/download_diffusion.py --model_sizes 7B 14B --model_types Text2World Video2World
Enter fullscreen mode Exit fullscreen mode

This download is over 50Gb. Give it a few minutes.

Generate a video from a text prompt.

PROMPT="A sleek, humanoid robot stands in a vast warehouse filled with neatly stacked cardboard boxes on industrial shelves. \
The robot's metallic body gleams under the bright, even lighting, highlighting its futuristic design and intricate joints. \
A glowing blue light emanates from its chest, adding a touch of advanced technology. The background is dominated by rows of boxes, \
suggesting a highly organized storage system. The floor is lined with wooden pallets, enhancing the industrial setting. \
The camera remains static, capturing the robot's poised stance amidst the orderly environment, with a shallow depth of \
field that keeps the focus on the robot while subtly blurring the background for a cinematic effect."

# Example using 7B model
PYTHONPATH=$(pwd) python cosmos1/models/diffusion/inference/text2world.py \
    --checkpoint_dir checkpoints \
    --diffusion_transformer_dir Cosmos-1.0-Diffusion-7B-Text2World \
    --prompt "$PROMPT" \
    --offload_prompt_upsampler \
    --video_save_name Cosmos-1.0-Diffusion-7B-Text2World

Enter fullscreen mode Exit fullscreen mode

Top comments (0)