330 字
2 分钟
FastAPI-DLS 搭建(NVIDIA vGPU 激活)

参考项目:https://git.collinwebdesigns.de/oscar.krause/fastapi-dls

本文用于在局域网内搭建一个可用的 DLS 服务,给 vGPU 客户端下发激活 token。

1. 生成证书#

在 Docker 主机执行:

Terminal window
WORKING_DIR=/opt/docker/fastapi-dls/cert
mkdir -p "$WORKING_DIR"
cd "$WORKING_DIR"
# 客户端依赖 HTTPS,这里生成自签证书供 uvicorn 使用
openssl req -x509 -nodes -days 3650 -newkey rsa:2048 \
-keyout "$WORKING_DIR/webserver.key" \
-out "$WORKING_DIR/webserver.crt"

2. 启动容器#

准备 compose.yaml

version: "3.9"
x-dls-variables: &dls-variables
TZ: Asia/Shanghai # 必填,服务端和客户端时区要一致
DLS_URL: 192.168.31.52 # 必填,改成你的服务 IP 或域名
DLS_PORT: 443
LEASE_EXPIRE_DAYS: 90 # 最大 90 天
DATABASE: sqlite:////app/database/db.sqlite
DEBUG: false
services:
dls:
image: collinwebdesigns/fastapi-dls:latest
restart: always
environment:
<<: *dls-variables
ports:
- "443:443"
volumes:
- /opt/docker/fastapi-dls/cert:/app/cert
- dls-db:/app/database
logging:
driver: "json-file"
options:
max-file: 5
max-size: 10m
volumes:
dls-db:

启动:

Terminal window
docker compose up -d

3. 客户端 token 下发与授权检查#

<dls-hostname-or-ip> 替换成你的 DLS 地址。

Linux#

下载 client-token 到 /etc/nvidia/ClientConfigToken

Terminal window
curl --insecure -L -X GET \
https://<dls-hostname-or-ip>/-/client-token \
-o /etc/nvidia/ClientConfigToken/client_configuration_token_$(date '+%d-%m-%Y-%H-%M-%S').tok

或:

Terminal window
wget --no-check-certificate \
-O /etc/nvidia/ClientConfigToken/client_configuration_token_$(date '+%d-%m-%Y-%H-%M-%S').tok \
https://<dls-hostname-or-ip>/-/client-token

重启 nvidia-gridd 服务:

Terminal window
service nvidia-gridd restart

检查授权状态:

Terminal window
nvidia-smi -q | grep -A 2 "vGPU Software Licensed Product"

预期输出类似:

vGPU Software Licensed Product
License Status : Licensed (Expiry: YYYY-M-DD hh:mm:ss GMT)

Windows#

在 PowerShell(管理员)执行,下载 client-token 到
C:\Program Files\NVIDIA Corporation\vGPU Licensing\ClientConfigToken

Terminal window
curl.exe --insecure -L -X GET https://<dls-hostname-or-ip>/-/client-token -o "C:\Program Files\NVIDIA Corporation\vGPU Licensing\ClientConfigToken\client_configuration_token_$($(Get-Date).ToString('dd-MM-yy-hh-mm-ss')).tok"

重启服务:

Terminal window
Restart-Service NVDisplay.ContainerLocalSystem

检查授权状态:

Terminal window
& 'nvidia-smi' -q | Select-String "License"

预期输出类似:

vGPU Software Licensed Product
License Status : Licensed (Expiry: YYYY-M-DD hh:mm:ss GMT)

4. 配套项目#

需要配合使用:
https://git.collinwebdesigns.de/vgpu/gridd-unlock-patcher

FastAPI-DLS 搭建(NVIDIA vGPU 激活)
https://iiii.fun/posts/vgpu/fastapi-dls-activation/
作者
庆灵
发布于
2026-08-24
许可协议
CC BY-NC-SA 4.0