数字人生成服务怎么部署

  1. 环境查看
    系统环境
# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.5 LTS
Release:        22.04
Codename:       jammy
# uname  -a
Linux AiServer003187 6.8.0-111-generic #111~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue Apr 14 17:13:45 UTC  x86_64 x86_64 x86_64 GNU/Linux

软件环境

# uv --version
uv 0.9.2
# python --version
Python 3.10.18
# nvidia-smi 
Wed Jun 24 17:05:13 2026       
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 580.159.03             Driver Version: 580.159.03     CUDA Version: 13.0     |
+-----------------------------------------+------------------------+----------------------+
| 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 GeForce RTX 4090        Off |   00000000:18:00.0 Off |                  Off |
| 30%   25C    P8             28W /  450W |   10924MiB /  24564MiB |      0%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+
|   1  NVIDIA GeForce RTX 4090        Off |   00000000:3B:00.0 Off |                  Off |
| 30%   25C    P8             23W /  450W |    2109MiB /  24564MiB |      0%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+
|   2  NVIDIA GeForce RTX 4090        Off |   00000000:86:00.0 Off |                  Off |
| 30%   24C    P8             21W /  450W |      18MiB /  24564MiB |      0%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+

+-----------------------------------------------------------------------------------------+
| Processes:                                                                              |
|  GPU   GI   CI              PID   Type   Process name                        GPU Memory |
|        ID   ID                                                               Usage      |
|=========================================================================================|
|    0   N/A  N/A            3512      G   /usr/lib/xorg/Xorg                        4MiB |
|    0   N/A  N/A           27256      C   python                                  906MiB |
|    0   N/A  N/A           42270      C   python                                  444MiB |
|    0   N/A  N/A           42271      C   python                                  538MiB |
|    0   N/A  N/A           42357      C   python                                 2108MiB |
|    0   N/A  N/A           43393      C   python                                  436MiB |
|    0   N/A  N/A           43397      C   python                                  538MiB |
|    0   N/A  N/A           43520      C   python                                 2098MiB |
|    0   N/A  N/A           61464      C   python                                 1916MiB |
|    0   N/A  N/A           66625      C   python                                  906MiB |
|    0   N/A  N/A           73081      G   ...m_detection/.venv/bin/python3         20MiB |
|    0   N/A  N/A          101530      C   python                                  902MiB |
|    1   N/A  N/A            3512      G   /usr/lib/xorg/Xorg                        4MiB |
|    1   N/A  N/A           73081      C   ...m_detection/.venv/bin/python3       2086MiB |
|    2   N/A  N/A            3512      G   /usr/lib/xorg/Xorg                        4MiB |
+-----------------------------------------------------------------------------------------+
  1. 下载代码
    代码目录
    未上传gitlab
/home/xiaoxing/data/latentsync-heygem
  1. 安装
    安装redis
apt install redis
# 使用默认配置不添加鉴权
systemctl start redis
systemctl enable redis

安装uv不详述
设置uv虚拟环境

# 在目录之外执行
# uv  init latentsync-heygem

使用uv安装python版本

# cd latentsync-heygem
# uv venv --python 3.10.18

激活进入虚拟环境

# source .venv/bin/activate

安装依赖

 uv pip install -r requirements.txt 

查看安装的所有依赖

 uv pip list
Using Python 3.10.18 environment at: /home/xiaoxing/data/latentsync-heygem/.venv
Package                  Version
------------------------ -----------
absl-py                  2.3.1
accelerate               0.26.1
aiofiles                 24.1.0
albucore                 0.0.24
albumentations           2.0.8
amqp                     5.3.1
annotated-types          0.7.0
antlr4-python3-runtime   4.9.3
anyio                    4.10.0
appdirs                  1.4.4
async-timeout            5.0.1
attrs                    25.3.0
audioread                3.0.1
billiard                 4.2.1
blinker                  1.9.0
celery                   5.5.1
certifi                  2025.8.3
cffi                     2.0.0
charset-normalizer       3.4.3
click                    8.2.1
click-didyoumean         0.3.1
click-plugins            1.1.1.2
click-repl               0.3.0
coloredlogs              15.0.1
contourpy                1.3.2
cycler                   0.12.1
cython                   3.1.3
decorator                4.4.2
decord                   0.6.0
diffusers                0.32.2
easydict                 1.13
einops                   0.7.0
exceptiongroup           1.3.0
face-alignment           1.4.1
fastapi                  0.116.1
ffmpeg-python            0.2.0
ffmpy                    0.6.1
filelock                 3.19.1
flask                    3.1.0
flatbuffers              25.2.10
fonttools                4.59.2
fsspec                   2025.9.0
future                   1.0.0
gradio                   5.24.0
gradio-client            1.8.0
groovy                   0.1.2
h11                      0.16.0
httpcore                 1.0.9
httpx                    0.28.1
huggingface-hub          0.30.2
humanfriendly            10.0
idna                     3.10
imageio                  2.31.1
imageio-ffmpeg           0.5.1
importlib-metadata       8.7.0
insightface              0.7.3
itsdangerous             2.2.0
jax                      0.6.2
jaxlib                   0.6.2
jinja2                   3.1.6
joblib                   1.5.2
kiwisolver               1.4.9
kombu                    5.5.4
kornia                   0.8.0
kornia-rs                0.1.9
lazy-loader              0.4
librosa                  0.10.1
llvmlite                 0.44.0
lpips                    0.1.4
markdown-it-py           4.0.0
markupsafe               3.0.2
matplotlib               3.10.6
mdurl                    0.1.2
mediapipe                0.10.11
ml-dtypes                0.5.3
moviepy                  1.0.3
mpmath                   1.3.0
msgpack                  1.1.1
networkx                 3.4.2
numba                    0.61.2
numpy                    1.26.4
nvidia-cublas-cu12       12.8.4.1
nvidia-cuda-cupti-cu12   12.8.90
nvidia-cuda-nvrtc-cu12   12.8.93
nvidia-cuda-runtime-cu12 12.8.90
nvidia-cudnn-cu12        9.10.2.21
nvidia-cufft-cu12        11.3.3.83
nvidia-cufile-cu12       1.13.1.3
nvidia-curand-cu12       10.3.9.90
nvidia-cusolver-cu12     11.7.3.90
nvidia-cusparse-cu12     12.5.8.93
nvidia-cusparselt-cu12   0.7.1
nvidia-nccl-cu12         2.27.3
nvidia-nvjitlink-cu12    12.8.93
nvidia-nvtx-cu12         12.8.90
omegaconf                2.3.0
onnx                     1.17.0
onnxruntime-gpu          1.21.0
opencv-contrib-python    4.11.0.86
opencv-python            4.9.0.80
opencv-python-headless   4.11.0.86
opt-einsum               3.4.0
orjson                   3.11.3
packaging                25.0
pandas                   2.3.2
pillow                   11.3.0
platformdirs             4.4.0
pooch                    1.8.2
prettytable              3.16.0
proglog                  0.1.12
prompt-toolkit           3.0.52
protobuf                 3.20.3
psutil                   7.0.0
pycparser                2.23
pydantic                 2.11.7
pydantic-core            2.33.2
pydub                    0.25.1
pygments                 2.19.2
pyparsing                3.2.3
python-dateutil          2.9.0.post0
python-multipart         0.0.20
python-speech-features   0.6
pytz                     2025.2
pyyaml                   6.0.2
redis                    5.2.1
regex                    2025.9.1
requests                 2.32.5
rich                     14.1.0
ruff                     0.13.0
safehttpx                0.1.6
safetensors              0.6.2
scenedetect              0.6.1
scikit-image             0.22.0
scikit-learn             1.7.2
scipy                    1.15.3
semantic-version         2.10.0
shellingham              1.5.4
simsimd                  6.5.3
six                      1.17.0
sniffio                  1.3.1
sounddevice              0.5.2
soundfile                0.13.1
soxr                     1.0.0
starlette                0.47.3
stringzilla              4.0.7
sympy                    1.14.0
threadpoolctl            3.6.0
tifffile                 2025.5.10
tokenizers               0.21.4
tomlkit                  0.13.3
torch                    2.8.0
torchvision              0.23.0
tqdm                     4.67.1
transformers             4.48.0
triton                   3.4.0
typer                    0.17.4
typing-extensions        4.15.0
typing-inspection        0.4.1
tzdata                   2025.2
urllib3                  2.5.0
uvicorn                  0.35.0
vine                     5.1.0
wcwidth                  0.2.13
websockets               15.0.1
werkzeug                 3.1.3
zipp                     3.23.0
  1. 启动
    使用tumx启动
# 启动api
tmux new -s latentsync_heygem_api
python api_server.py
# 启动队列
tmux new -s latentsync_heygem_celery
celery -A api_server.celery worker

使用systemctl管理
两个配置文件
api

# cat /usr/lib/systemd/system/latentsync_heygem_api.service 
[Unit]
Description=latentsync-heygem-api
After=network.target

[Service]
Type=simple
User=root
# 工作目录
WorkingDirectory=/home/xiaoxing/data/latentsync-heygem
# 启动脚本,使用完整路径
ExecStart=/home/xiaoxing/data/latentsync-heygem/.venv/bin/python /home/xiaoxing/data/latentsync-heygem/api_server.py

Restart=always
RestartSec=5

# 防止 OOM 被 kill
LimitNOFILE=65535
LimitNPROC=65535

# GPU 环境变量(可选但建议加)
Environment="CUDA_VISIBLE_DEVICES=0"

[Install]
WantedBy=multi-user.target

celery

root@AiServer003088:/home/xiaoxing/data/latentsync-heygem# cat /usr/lib/systemd/system/latentsync_heygem_celery.service 
[Unit]
Description=latentsync-heygem-celery
After=network.target

[Service]
Type=simple
User=root
# 工作目录
WorkingDirectory=/home/xiaoxing/data/latentsync-heygem
# 启动脚本,使用完整路径
ExecStart=/home/xiaoxing/data/latentsync-heygem/.venv/bin/celery  -A api_server.celery worker

Restart=always
RestartSec=5

# 防止 OOM 被 kill
LimitNOFILE=65535
LimitNPROC=65535

# GPU 环境变量(可选但建议加)
Environment="CUDA_VISIBLE_DEVICES=0"

[Install]
WantedBy=multi-user.target

启动

systemctl daemon-reload
systemctl enable latentsync_heygem_api.service 
systemctl enable latentsync_heygem_celery.service
systemctl start latentsync_heygem_api.service 
systemctl start latentsync_heygem_celery.service

使用podman启动其他服务
安装podman

apt instal podman
pip install podman-compose

下载镜像

podman pull  harbor.xiaoxingcloud.com/foundation/docker.io/guiji2025/duix.avatar

docker-compose配置文件
有两个配置文件,都需要启动

# pwd
/home/xiaoxing/data/Duix.Heygem/deploy
# cat docker-compose-linux.yml 
networks:
  ai_network:
    driver: bridge
services:
  heygem-gen-video:
    image: guiji2025/duix.avatar
    container_name: heygem-gen-video
    restart: always
    #runtime: nvidia
    gpus: all 
    security_opt:
      - label=disable
      - seccomp=unconfined
    volumes:
      - /home/xiaoxing/data/latentsync-heygem/heygem_data/face2face:/code/data
    environment:
      - LD_LIBRARY_PATH=/usr/local/nvidia/lib:/usr/local/nvidia/lib64:/host/usr/lib/nvidia:/host/usr/lib/x86_64-linux-gnu:/usr/local/lib:/usr/lib
      - NVIDIA_VISIBLE_DEVICES=0
      - PYTORCH_CUDA_ALLOC_CONF=max_split_size_mb:512
    devices:
      - /dev/nvidia0:/dev/nvidia0
      - /dev/nvidiactl:/dev/nvidiactl
      - /dev/nvidia-uvm:/dev/nvidia-uvm
      - /dev/nvidia-uvm-tools:/dev/nvidia-uvm-tools
    shm_size: '8g'
    ports:
      - '8383:8383'
    command: python /code/app_local.py
    networks:
      - ai_network
	  
# cat docker-compose-linux-v1.yml 
networks:
  ai_network_v1:
    driver: bridge
services:
  heygem-gen-video-v1:
    image: guiji2025/duix.avatar
    container_name: heygem-gen-video-v1
    restart: always
    #runtime: nvidia
    gpus: all
    security_opt:
      - label=disable
      - seccomp=unconfined
    volumes:
      - /home/xiaoxing/data/latentsync-heygem/heygem_data/face2face:/code/data
    environment:
      - LD_LIBRARY_PATH=/usr/local/nvidia/lib:/usr/local/nvidia/lib64:/host/usr/lib/nvidia:/host/usr/lib/x86_64-linux-gnu:/usr/local/lib:/usr/lib
      - NVIDIA_VISIBLE_DEVICES=1
      - PYTORCH_CUDA_ALLOC_CONF=max_split_size_mb:512
    devices:
      - /dev/nvidia0:/dev/nvidia0
      - /dev/nvidiactl:/dev/nvidiactl
      - /dev/nvidia-uvm:/dev/nvidia-uvm
      - /dev/nvidia-uvm-tools:/dev/nvidia-uvm-tools
    shm_size: '8g'
    ports:
      - '8384:8383'
    command: python /code/app_local.py
    networks:
      - ai_network_v1

启动podman镜像

podman-compose -f docker-compose-linux.yml up -d
podman-compose -f docker-compose-linux-v1.yml up -d

注意:原配置文件启动失败,需要修改以下配置为gpus: all

#runtime: nvidia
gpus: all 

把podman设置为开机自启动
两个配置文件
heygem-gen-video

# cat /usr/lib/systemd/system/heygem-gen-video.service 
[Unit]
Description=heygem-gen-video
After=network-online.target
Wants=network-online.target

[Service]
Type=oneshot
RemainAfterExit=yes
# 工作目录放置docker-compose.yml配置文件
WorkingDirectory=/home/xiaoxing/data/Duix.Heygem/deploy
ExecStart=/usr/bin/podman-compose -f docker-compose-linux.yml  up -d
ExecStop=/usr/bin/podman-compose -f  docker-compose-linux.yml down

[Install]
WantedBy=default.target

heygem-gen-video-v1

# cat /usr/lib/systemd/system/heygem-gen-video-v1.service 
[Unit]
Description=heygem-gen-video-v1
After=network-online.target
Wants=network-online.target

[Service]
Type=oneshot
RemainAfterExit=yes
# 工作目录放置docker-compose.yml配置文件
WorkingDirectory=/home/xiaoxing/data/Duix.Heygem/deploy
ExecStart=/usr/bin/podman-compose -f docker-compose-linux-v1.yml  up -d
ExecStop=/usr/bin/podman-compose -f  docker-compose-linux-v1.yml down

[Install]
WantedBy=default.target

启动和设置开机自启动

systemctl daemon-reload
systemctl enable heygem-gen-video
systemctl enable heygem-gen-video-v1
systemctl start heygem-gen-video
systemctl start heygem-gen-video-v1

api默认启动端口为8009,可以修改配置文件api_server.py修改端口
5. 测试
使用curl测试

curl --location --request POST 'http://192.168.8.90:8009/create/video' \
--form 'audio_file=@"/root/test.wav"' \
--form 'avatar_id="d5ab7e81672a4ddf94d93fb1ecf2f663"' \
--form 'audio_url=""' \
--form 'callback_url=""'

传递一个音频文件作为参数,再传递一个avatar_id这个id是在目录的app.log日志文件找到的
查看接口日志
image
查看队列日志
image

如配置了域名则使用域名测试

posted @ 2026-06-29 11:54  minseo  阅读(3)  评论(0)    收藏  举报