Deployment Overview of CogVideoX-5b on Server¶
Prerequisites and Basic Requirements¶
To ensure the successful deployment and operation of the application, the following system requirements must be met:
-
Operating System: Ubuntu 22.04 (recommended for HWE kernel support).
-
Privileges: Root or sudo access is required for all installation steps.
-
Hardware Requirement: An NVIDIA GPU is mandatory for CUDA acceleration.
-
Network Ports:
-
443(HTTPS) - External access via Nginx proxy. -
7860- Internal application port.
FQDN of the final panel on the hostkey.in domain¶
The application is accessible through a specific subdomain template based on the server ID.
| Parameter | Value |
|---|---|
| Prefix | cogvideo |
| Domain | hostkey.in |
| Full template | cogvideo{Server_ID_from_Invapi}.hostkey.in |
File and Directory Structure¶
The following directories are used for application data, configurations, and system services:
-
/opt/CogVideo: Main application directory containing the source code and Python virtual environment. -
/opt/CogVideo/env: Python virtual environment. -
/root/nginx: Configuration directory for the Nginx proxy container. -
/data/nginx/user_conf.d: Directory containing Nginx site configurations. -
/data/nginx/nginx-certbot.env: Environment file for Certbot configuration.
Application installation process¶
The application is installed using a combination of system-level package management, manual script execution, and service configuration:
-
System Preparation: The system is updated and upgraded via
apt. Thelinux-generic-hwe-22.04kernel andgcccompiler are installed to support specialized drivers. -
NVIDIA Driver & CUDA Setup:
-
A CUDA keyring is added to the package manager.
-
cuda-toolkitandnvidia-cuda-toolkitare installed. -
The system environment variables (
PATHandLD_LIBRARY_PATH) are updated in.bashrc. -
NVIDIA drivers are initialized, and
nvidia-docker2is installed to enable GPU support within Docker containers. -
Application Source: The CogVideo repository is cloned from GitHub into
/opt/CogVideo. -
Python Environment Setup:
-
Python 3.10 and
venvmodules are installed. -
A virtual environment is created at
/opt/CogVideo/env. -
Required dependencies are installed via
pip, including specific versions oftorch,torchvision, andtorchaudiocompiled for CUDA 11.8, as well asmoviepy. -
Service Configuration: A systemd service named
cogvideo.serviceis created to manage the application process using the Gradio composite demo script.
Access Rights and Security¶
-
Firewall/Access: The application is exposed via an Nginx reverse proxy on port 443.
-
User Permissions: The CogVideo service runs under the
rootuser within its working directory/opt/CogVideo. -
Docker Security: NVIDIA container runtime is configured to allow the application to interface with host GPU hardware securely.
Docker Containers and Their Deployment¶
The deployment utilizes a single Nginx container managed via Docker Compose for SSL termination and reverse proxying.
| Container Name | Image | Ports (Host:Container) | Volumes | Environment Variables | Restart Policy |
|---|---|---|---|---|---|
nginx | jonasal/nginx-certbot:latest | host_network | - nginx_secrets:/etc/letsencrypt- /data/nginx/user_conf.d:/etc/nginx/user_conf.d | [email protected] (plus custom env file) | unless-stopped |
Custom Scripts and Additional Setup¶
The installation process includes an automated initialization script (install_script.sh) located in /tmp during the setup phase. This script performs the following critical actions:
-
Updates system repositories.
-
Installs necessary build tools (GCC).
-
Configures NVIDIA CUDA repositories and toolkits.
-
Modifies shell configuration files to set up the CUDA environment path.
-
Removes the
nouveaudriver to allow the NVIDIA proprietary driver to load.
Application Update Instructions¶
To update the main application, follow these steps:
-
Update Source Code: Navigate to
/opt/CogVideoand pull the latest changes from the repository. -
Update Dependencies: Activate the virtual environment and upgrade packages:
-
Restart Service: Apply changes by restarting the systemd service:
Location of configuration files and data¶
-
Nginx Configuration:
/data/nginx/user_conf.d/{prefix}{server_id}.hostkey.in.conf -
Docker Compose File:
/root/nginx/compose.yml -
Application Source:
/opt/CogVideo
Available ports for connection¶
-
HTTPS (External):
443 -
Internal Application Port:
7860
Starting and Stopping the application¶
The application is managed as a systemd service:
-
Start the application:
systemctl start cogvideo -
Stop the application:
systemctl stop cogvideo -
Check status:
systemctl status cogvideo -
Enable on boot:
systemctl enable cogvideo
Proxy Servers¶
The system uses an Nginx container (jonasal/nginx-certbot) acting as a reverse proxy. It handles SSL certificates via Certbot and routes incoming traffic from port 443 to the internal application running on http://127.0.0.1:7860.