Deployment Overview of HunyuanVideo on Server¶
Prerequisites and Basic Requirements¶
The deployment of HunyuanVideo requires a Linux environment based on Ubuntu 22.04. The system must have root privileges to install system packages, configure Docker, and manage services. The following hardware and software prerequisites are necessary:
- Operating System: Ubuntu 22.04 LTS.
- Hardware: NVIDIA GPU with compatible drivers for CUDA acceleration.
- Network Access: Internet connectivity is required to download the repository, Python dependencies, and model checkpoints.
- Ports: Port 8080 is used internally for the application service. Ports 80 and 443 are required for the Nginx proxy and SSL certificate management.
File and Directory Structure¶
The application and its supporting components are organized in specific directories on the server. The primary locations for configuration, data, and application files are as follows:
- Application Source:
/opt/HunyuanVideo - Python Virtual Environment:
/opt/HunyuanVideo/venv - Model Checkpoints:
/opt/HunyuanVideo/models - Nginx Configuration Directory:
/root/nginx - Nginx User Configuration:
/data/nginx/user_conf.d - Docker Daemon Configuration:
/etc/docker/daemon.json - Let's Encrypt Secrets:
/etc/letsencrypt(mounted via Docker volume)
Application Installation Process¶
The installation process involves cloning the source code, setting up a Python environment, installing dependencies, and downloading the necessary model weights.
- System Package Installation: Essential tools such as
git,python3,python3-venv,python3-dev,python3-pip,curl, andwgetare installed via theaptpackage manager. - Repository Cloning: The HunyuanVideo repository is cloned from
https://github.com/Tencent/HunyuanVideo.gitto the/opt/HunyuanVideodirectory, targeting themainbranch. - Virtual Environment Setup: A Python virtual environment is created at
/opt/HunyuanVideo/venvusing thepython3 -m venvcommand. - Dependency Installation: Python dependencies listed in
/opt/HunyuanVideo/requirements.txtare installed within the virtual environment. - Model Download: The
huggingface-hubpackage with CLI support is installed. The model checkpoints are downloaded using thehuggingface-clicommand to the/opt/HunyuanVideo/modelsdirectory, specifically including thehunyuan-video-t2v-720passets.
Docker Containers and Their Deployment¶
The deployment utilizes Docker containers for the web proxy and SSL management. The NVIDIA Docker runtime is configured to enable GPU acceleration for the application.
- NVIDIA Docker Configuration: The Docker daemon is configured to use the NVIDIA runtime by default. The configuration file
/etc/docker/daemon.jsonis updated with the following content: - Docker Restart: The Docker service is restarted to apply the new runtime configuration.
- Nginx and Certbot Deployment: A Docker Compose setup is used to deploy the Nginx proxy and Certbot for SSL certificate management.
- The
docker compose up -dcommand is executed from the/root/nginxdirectory. - The
compose.ymlfile defines thenginxservice using thejonasal/nginx-certbot:latestimage. - The service runs in
hostnetwork mode. - Volumes are mounted for
nginx_secrets(external) and the user configuration directory/data/nginx/user_conf.d. - Environment variables are loaded from
/data/nginx/nginx-certbot.env.
- The
Proxy Servers¶
The Nginx proxy server handles incoming traffic and manages SSL certificates via Certbot.
- Image: The proxy uses the
jonasal/nginx-certbot:latestDocker image. - Configuration: Custom server configurations are stored in
/data/nginx/user_conf.d. - Proxy Pass: The Nginx configuration includes a
proxy_passdirective that forwards requests to the local application running onhttp://127.0.0.1:8080. - SSL Management: Certbot is integrated to automatically obtain and renew SSL certificates. The email address for certificate notifications is configured as
[email protected]. - Secrets Storage: SSL certificates and keys are stored in the external Docker volume
nginx_secrets, mounted at/etc/letsencryptinside the container.
Starting, Stopping, and Updating¶
The application and its services are managed through specific commands and Docker operations.
- Application Execution: The HunyuanVideo generation script is executed using the Python interpreter from the virtual environment. The command structure is:
- Docker Service Management:
- To start or restart the proxy services, run
docker compose up -dfrom the/root/nginxdirectory. - To stop the services, run
docker compose downfrom the same directory.
- To start or restart the proxy services, run
- Docker Daemon Restart: If changes are made to the Docker configuration (e.g., enabling NVIDIA runtime), the Docker service must be restarted using
systemctl restart docker.