Skip to content

Deployment Overview of CogVideo on Server

Prerequisites and Basic Requirements

The deployment of the CogVideo application requires a Linux server environment with specific hardware and software configurations. The system must meet the following criteria:

  • Operating System: Ubuntu 22.04 LTS.

  • Privileges: Root access or sudo privileges are required for installation and configuration.

  • Hardware: NVIDIA GPU with compatible drivers for CUDA acceleration.

  • Network: Access to the internet for downloading dependencies and obtaining SSL certificates.

  • Ports: Port 443 for external HTTPS access and port 7860 for internal application communication.

FQDN of the Final Panel

The application is accessible via the following Fully Qualified Domain Name (FQDN) format on the hostkey.in domain:

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

Replace <Server ID> with the specific identifier assigned to the server instance.

File and Directory Structure

The application and its supporting components are organized within the following directory structure:

  • /opt/CogVideo: Main application directory containing the source code cloned from the repository.

  • /opt/CogVideo/env: Python virtual environment directory.

  • /root/nginx: Directory containing the Docker Compose configuration for the Nginx proxy.

  • /data/nginx/user_conf.d: Directory storing custom Nginx configuration files for the specific domain.

  • /data/nginx/nginx-certbot.env: Environment file for Nginx and Certbot configuration.

  • /etc/systemd/system/cogvideo.service: Systemd service unit file for managing the application.

Application Installation Process

The CogVideo application is installed directly on the host operating system using a combination of system packages, Python virtual environments, and systemd services. The installation involves the following steps:

  1. System Updates: The system is updated and upgraded using apt.

  2. Kernel and Drivers: The linux-generic-hwe-22.04 package is installed, followed by the installation of GCC, CUDA toolkit, and NVIDIA drivers.

  3. Environment Setup: Python 3.10 and python3.10-venv are installed. A virtual environment is created at /opt/CogVideo/env.

  4. Dependencies: Required Python packages are installed within the virtual environment, including:

    • torch==2.0.1+cu118

    • torchvision==0.15.2+cu118

    • torchaudio==2.0.2+cu118

    • moviepy==1.0.3

    • Packages listed in /opt/CogVideo/requirements.txt.

  5. Service Creation: A systemd service file is created to manage the application lifecycle.

Docker Containers and Their Deployment

The reverse proxy and SSL certificate management are handled via Docker containers using Docker Compose. The deployment utilizes the following configuration:

  • Compose File Location: /root/nginx/compose.yml.

  • Image: jonasal/nginx-certbot:latest.

  • Network Mode: Host.

  • Volumes:

  • nginx_secrets (external) mounted to /etc/letsencrypt.

  • /data/nginx/user_conf.d mounted to /etc/nginx/user_conf.d.

  • Execution: The container is started using the command docker compose up -d within the /root/nginx directory.

Proxy Servers

Nginx is configured as a reverse proxy to handle incoming traffic and manage SSL certificates via Certbot.

  • Internal Proxy Target: Traffic is proxied to http://127.0.0.1:7860.

  • Configuration File: The specific domain configuration is located at /data/nginx/user_conf.d/cogvideo<Server ID>.hostkey.in.conf.

  • SSL Management: Certbot is integrated within the Nginx container to automatically obtain and renew SSL certificates.

  • Email: Certificate notifications are sent to [email protected].

Permission Settings

The following permission settings are applied to ensure proper access and security:

  • /root/nginx: Owned by root:root with mode 0755.

  • /root/nginx/compose.yml: Owned by root:root with mode 0644.

  • /opt/CogVideo: Application directory accessible by the root user as defined in the systemd service.

  • /etc/systemd/system/cogvideo.service: System service file owned by root.

Location of Configuration Files and Data

Key configuration files and data locations are as follows:

  • Nginx Compose: /root/nginx/compose.yml.

  • Nginx Environment: /data/nginx/nginx-certbot.env.

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

  • Application Source: /opt/CogVideo.

  • Python Virtual Environment: /opt/CogVideo/env.

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

Available Ports for Connection

The following ports are configured for the application:

  • Port 443: External HTTPS access via Nginx proxy.

  • Port 7860: Internal port used by the CogVideo application (Gradio interface).

Starting, Stopping, and Updating

The CogVideo application is managed as a systemd service. Use the following commands to control the service:

  • Start the service:

    systemctl start cogvideo
    

  • Stop the service:

    systemctl stop cogvideo
    

  • Restart the service:

    systemctl restart cogvideo
    

  • Enable service on boot:

    systemctl enable cogvideo
    

  • Check service status:

    systemctl status cogvideo
    

To update the application, the source code in /opt/CogVideo must be updated manually, followed by restarting the service. The Docker proxy container can be updated by running docker compose pull and docker compose up -d in the /root/nginx directory.

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