Skip to content

Deployment Overview of CogVideo on Server

Prerequisites and Basic Requirements

The server must meet the following requirements to successfully deploy the CogVideo application:

  • Operating System: Ubuntu 22.04 LTS.

  • Privileges: Root access is required for installation and configuration.

  • Hardware: NVIDIA GPU with support for CUDA toolkit.

  • Network: Access to the public internet for downloading repositories and dependencies.

  • Ports: Port 443 (HTTPS) for external access and Port 7860 for internal service communication.

FQDN of the Final Panel

The application is accessible via the following Fully Qualified Domain Name (FQDN) format:

  • cogvideo<Server ID>.hostkey.in:443

File and Directory Structure

The application and its configuration files are organized in the following directories:

  • /opt/CogVideo: The main directory containing the application source code, Python virtual environment, and inference scripts.

  • /opt/CogVideo/env: The Python virtual environment directory containing installed packages.

  • /root/nginx: The directory containing the Docker Compose configuration for the reverse proxy.

  • /root/nginx/compose.yml: The Docker Compose file for the Nginx and Certbot service.

  • /data/nginx/user_conf.d: The directory containing Nginx site-specific configuration files.

  • /etc/systemd/system/cogvideo.service: The Systemd service unit file.

Application Installation Process

The application is deployed using a custom installation script and a Python virtual environment. The process involves:

  1. Updating the system packages and installing the Linux Hardware Enablement (HWE) stack for Ubuntu 22.04.

  2. Installing the GCC compiler and the NVIDIA CUDA toolkit.

  3. Configuring environment variables for CUDA in ~/.bashrc.

  4. Loading NVIDIA kernel modules and verifying GPU access.

  5. Installing Docker and NVIDIA-Docker2 for GPU support within containers.

  6. Cloning the CogVideo repository from https://github.com/THUDM/CogVideo.git into /opt/CogVideo.

  7. Creating a Python 3.10 virtual environment at /opt/CogVideo/env.

  8. Installing Python dependencies including PyTorch with CUDA 11.8 support and moviepy.

Access Rights and Security

Security and access controls are managed through the following mechanisms:

  • The application runs as the root user via a Systemd service.

  • External access is restricted to the configured FQDN over HTTPS (Port 443).

  • Internal traffic is routed from the reverse proxy to the application on localhost via Port 7860.

Docker Containers and Their Deployment

A Docker container is used to run the Nginx reverse proxy and manage SSL certificates. The deployment is managed via docker compose in the /root/nginx directory.

  • Image: jonasal/nginx-certbot:latest

  • Service Name: nginx

  • Restart Policy: unless-stopped

  • Network Mode: host

  • Volumes:

  • nginx_secrets (external): Mounted to /etc/letsencrypt for certificate storage.

  • /data/nginx/user_conf.d: Mounted to /etc/nginx/user_conf.d for custom site configurations.

  • Environment:

  • CERTBOT_EMAIL: Set to [email protected].

Proxy Servers

The Nginx reverse proxy handles SSL termination and forwards traffic to the application.

  • SSL/Certificates: Managed automatically by Certbot via the nginx-certbot Docker container.

  • Configuration Location: /data/nginx/user_conf.d/cogvideo<Server ID>.hostkey.in.conf.

  • Proxy Pass: Configured to forward requests to http://127.0.0.1:7860.

  • External Path: / maps to the internal application root.

Location of Configuration Files and Data

Key configuration files and data directories are located at:

  • /etc/systemd/system/cogvideo.service: Systemd service definition.

  • /root/nginx/compose.yml: Docker Compose configuration for the proxy.

  • /data/nginx/nginx-certbot.env: Environment variables for the Nginx container.

  • /opt/CogVideo/requirements.txt: Python package dependencies.

  • /opt/CogVideo/inference/gradio_composite_demo/cogstudio.py: The main entry point script.

Available Ports for Connection

The following ports are utilized in the deployment:

  • Port 443: HTTPS traffic for external user access.

  • Port 7860: Internal communication port for the Gradio interface used by the CogVideo application.

Starting, Stopping, and Updating

The application is managed as a Systemd service named cogvideo. Use the following commands to control the service:

  • Start Service: systemctl start cogvideo

  • Stop Service: systemctl stop cogvideo

  • Restart Service: systemctl restart cogvideo

  • Enable on Boot: systemctl enable cogvideo

  • Check Status: systemctl status cogvideo

To update the Nginx proxy configuration or certificates, run the following command from the /root/nginx directory: docker compose up -d

To reload Systemd after modifying the service file: systemctl daemon-reload

question_mark
Is there anything I can help you with?
question_mark
AI Assistant ×