LogoTensorFusion 文档
LogoTensorFusion 文档
首页

快速开始

TensorFusion 概览在 Kubernetes 安装在虚拟机/服务器安装(K3S)Helm 快速安装在宿主机/虚拟机安装TensorFusion 架构

应用操作

创建 AI 应用注解使用场景配置自动扩缩容迁移现有应用最佳实践

自定义AI基础设施

生产级部署指南QoS 级别与计价云厂商集成(BYOC)管理许可证

维护与优化

组件更新配置告警GPU 热迁移预加载模型优化 GPU 效率

故障排除

问题处理手册链路追踪/性能分析查询指标和日志

参考

对比

与 NVIDIA vGPU 对比与 MIG/MPS 对比与趋动科技对比与 NVIDIA Run:ai 对比与 HAMi 的对比

Helm 快速安装

只用 Helm 安装 TensorFusion,不安装 cluster agent,也不接入 TensorFusion 控制台

本文介绍只用 Helm 安装 TensorFusion 的方法。集群不连接 TensorFusion 控制台,所有管理操作通过 kubectl 和 Helm values 完成。适合内网隔离环境、私有化部署,或者不需要控制台的场景。

如果希望在控制台里管理集群,请改看在 Kubernetes 安装。

前置条件

  • 一个 Kubernetes 集群,至少有一个 GPU 节点。默认安装面向 NVIDIA GPU,其他厂商见其他厂商的加速卡。

  • 每个 GPU 节点已安装 NVIDIA 驱动,容器运行时能挂载 GPU 设备。自建节点需要安装 NVIDIA Container Toolkit。

  • 每个 GPU 节点带有标签 nvidia.com/gpu.present=true。TensorFusion 不会自动添加这个标签。用下面的命令检查,没有列出节点时手动打标签:

    kubectl get nodes -l nvidia.com/gpu.present=true
    kubectl label node <gpu-node-name> nvidia.com/gpu.present=true
  • 本机已安装 kubectl 和 helm,账号有权限创建 Namespace、CRD、ClusterRole 和 MutatingWebhookConfiguration。

  • 节点能从 Docker Hub、quay.io、registry.k8s.io 或它们的镜像站拉取镜像。

第 1 步:安装 chart

helm upgrade --install --create-namespace --namespace tensor-fusion-sys \
  --repo https://download.tensor-fusion.ai \
  tensor-fusion-sys tensor-fusion
helm upgrade --install --create-namespace --namespace tensor-fusion-sys \
  --repo https://download.tensor-fusion.ai \
  -f https://download.tensor-fusion.ai/values-cn.yaml \
  tensor-fusion-sys tensor-fusion

values-cn.yaml 把 operator、agent、GreptimeDB、Vector、Alertmanager 和 webhook 证书工具的镜像换成国内镜像仓库的地址。hypervisor、vGPU provider、client、worker 这几个镜像仍然从 Docker Hub 的 tensorfusion/* 拉取。可以在容器运行时里配置镜像加速,或者覆盖 cluster.hypervisorImage 和 providerConfigs.nvidia.images.*。

release 名称和命名空间都保持 tensor-fusion-sys。需要固定 chart 版本时加上 --version <chart-version>。

chart 会安装:

  • TensorFusion 的 CRD、RBAC 和 controller Deployment。operator、Pod webhook、调度器都运行在这个 Deployment 里。
  • 存放指标的 GreptimeDB 单机版(命名空间 greptimedb),以及 Alertmanager(命名空间 tensor-fusion-sys)。
  • NVIDIA ProviderConfig、名为 tf-scheduling-config 的 SchedulingConfigTemplate,以及名为 tensor-fusion、带一个资源池的默认 TensorFusionCluster。不需要再手动应用集群清单。

agent.agentId 默认为空,所以不会安装 cluster agent。

最常需要调整的参数:

参数默认值作用
initialGpuNodeLabelSelectornvidia.com/gpu.present=trueoperator 用这个标签选择器识别 GPU 节点。
cluster.pool.nodeSelectorKeynvidia.com/gpu.present默认资源池选择节点用的标签键,标签值必须是 true。
cluster.pool.defaultIsolationModesoft默认资源池中节点的隔离模式:soft、hard 或 partitioned。
cluster.enabledtrue是否创建默认的 NVIDIA TensorFusionCluster。自己提供集群清单时设为 false。
controller.compatibleWithNvidiaContainerToolkitfalse集群装有 NVIDIA GPU Operator,且 GPU 节点上存在 /run/nvidia/validations/toolkit-ready 和 driver-ready 时设为 true。
greptime.installStandalonetrue是否安装内置的 GreptimeDB。使用外部 GreptimeDB 时设为 false。
alert.enabledtrue是否安装 Alertmanager。

全部参数见 Helm values 参考。高可用和外部 GreptimeDB 的配置见生产级部署指南。

第 2 步:验证安装

  1. 检查系统 Pod:

    kubectl get pods -n tensor-fusion-sys
    kubectl get pods -n greptimedb

    tensor-fusion-sys-controller-* 处于 Running 状态,每个 GPU 节点对应一个 hypervisor-<node-name> Pod。没有 hypervisor Pod 时,参考没有 hypervisor Pod。

  2. 检查默认集群和资源池:

    kubectl get tensorfusioncluster,gpupool
    kubectl get gpunode,gpu

    TensorFusionCluster 名为 tensor-fusion,资源池名为 tensor-fusion-shared(资源池的名称是 <集群名>-<池名>)。两者的 Phase 都变为 Running。每张物理 GPU 对应一个 GPU 资源,并显示它的 TFLOPS 和 VRAM。

    如果集群里没有匹配的 GPU 节点,controller 仍然正常运行,不会创建 hypervisor Pod,集群和资源池可能一直停在 Updating。

第 3 步:运行测试负载

  1. 部署一个只申请部分 GPU 的小参数量大模型。下面的 Deployment 用 vLLM 运行 Qwen3-0.6B:

    # qwen3-demo.yaml
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: qwen3-demo
      namespace: default
    spec:
      replicas: 1
      progressDeadlineSeconds: 3600
      selector:
        matchLabels:
          app: qwen3-demo
      template:
        metadata:
          labels:
            app: qwen3-demo
            tensor-fusion.ai/enabled: "true"
          annotations:
            tensor-fusion.ai/tflops-request: "10"
            tensor-fusion.ai/tflops-limit: "30"
            tensor-fusion.ai/vram-request: "4Gi"
            tensor-fusion.ai/vram-limit: "5Gi"
        spec:
          containers:
            - name: app
              image: vllm/vllm-openai:v0.11.0
              command:
                - vllm
                - serve
                - Qwen/Qwen3-0.6B
                - --served-model-name
                - qwen3-0.6b
                - --port
                - "8000"
                - --dtype
                - half
                - --max-model-len
                - "2048"
                - --gpu-memory-utilization
                - "0.7"
                - --max-num-seqs
                - "32"
              env:
                - name: VLLM_USE_FLASHINFER_SAMPLER
                  value: "0"
              ports:
                - name: http
                  containerPort: 8000
              readinessProbe:
                httpGet:
                  path: /health
                  port: 8000
                periodSeconds: 5
                failureThreshold: 120
              volumeMounts:
                - name: dshm
                  mountPath: /dev/shm
          volumes:
            - name: dshm
              emptyDir:
                medium: Memory
                sizeLimit: 2Gi
    kubectl apply -f qwen3-demo.yaml

    标签 tensor-fusion.ai/enabled: "true" 表示这个 Pod 交给 TensorFusion 管理。注解向一张 GPU 申请 10 TFLOPS 算力和 4 GiB 显存,上限为 30 TFLOPS 和 5 GiB。不写其他注解时,Pod 调度到默认资源池的 GPU 节点上,以 soft 隔离模式共享 GPU。这张 GPU 至少要有 4 GiB 尚未分配的显存。

    vLLM 启动时会按固定比例预留它看到的显存。--gpu-memory-utilization 0.7 把预留量控制在 5 GiB 上限的 70%,--max-model-len 和 --max-num-seqs 按小规模测试设置服务规格。VLLM_USE_FLASHINFER_SAMPLER=0 让 vLLM 使用内置的采样器。

  2. 等待模型服务就绪:

    kubectl rollout status deployment/qwen3-demo --timeout=30m
    kubectl get pod -l app=qwen3-demo -o wide

    首次启动要拉取几个 GB 的 vLLM 镜像,并从 Hugging Face 下载模型权重,可能需要几分钟。模型加载进显存、/health 可以访问之后,Pod 才会变为 Ready。可以用 kubectl logs -f deployment/qwen3-demo 查看进度。

    如果节点访问不了 Hugging Face,给容器加上环境变量 HF_ENDPOINT,值为镜像站地址。

  3. 进入容器检查 vGPU:

    kubectl exec deploy/qwen3-demo -- nvidia-smi

    nvidia-smi 显示的总显存约为 5120 MiB,也就是显存上限,而不是整张卡的显存。进程列表里能看到 vLLM 进程和它预留的显存。

  4. 向模型发送一次对话请求:

    kubectl port-forward deploy/qwen3-demo 8000:8000 &
    
    curl -s http://127.0.0.1:8000/v1/chat/completions \
      -H 'Content-Type: application/json' \
      -d '{
        "model": "qwen3-0.6b",
        "max_tokens": 80,
        "messages": [{"role": "user", "content": "Give me a short introduction to large language model."}],
        "chat_template_kwargs": {"enable_thinking": false}
      }'
    
    kill %1   # 停止端口转发

    返回的是 OpenAI 格式的 JSON。choices[0].message.content 是 Qwen3-0.6B 生成的回答,usage.completion_tokens 大于 0。这一步才是真正的验证:Pod 处于 Running 不代表 GPU 链路可用,而一次完整的推理说明模型已经加载进 vGPU 的显存,每个 token 都是经过 TensorFusion 计算出来的。

  5. 删除测试负载:

    kubectl delete deployment qwen3-demo

其他厂商的加速卡

chart 默认创建的集群只面向 NVIDIA。使用 Ascend、MooreThreads 或 PPU 设备时,先关掉 NVIDIA 的默认配置,把 operator 的节点标签选择器改成对应厂商的标签,再应用该厂商的 ProviderConfig 和 TensorFusionCluster 样例。以 Ascend 为例:

helm upgrade --install --create-namespace --namespace tensor-fusion-sys \
  --repo https://download.tensor-fusion.ai \
  --set cluster.enabled=false \
  --set providerConfigs.nvidia.enabled=false \
  --set initialGpuNodeLabelSelector=huawei.com/npu.present=true \
  tensor-fusion-sys tensor-fusion

RAW=https://raw.githubusercontent.com/NexusGPU/tensor-fusion/main/config/samples
kubectl apply -f $RAW/provider-ascend.yaml -f $RAW/tensorfusioncluster-ascend.yaml

换成其他厂商时,只需要改选择器和两个文件名:

厂商initialGpuNodeLabelSelector样例文件
Ascendhuawei.com/npu.present=trueprovider-ascend.yaml、tensorfusioncluster-ascend.yaml
MooreThreadsmthreads.com/gpu.present=trueprovider-mthreads.yaml、tensorfusioncluster-mthreads.yaml
PPUaliyun.com/ppu.present=trueprovider-ppu.yaml、tensorfusioncluster-ppu.yaml

一个集群里混用多个厂商的卡时,仍然只创建一个 TensorFusionCluster,每个厂商一个资源池。以同目录下的 tensorfusioncluster-multi-vendor.yaml 为起点,把 initialGpuNodeLabelSelector 设为 tensor-fusion.ai/watch-node=true,并手动给每个 GPU 节点打上 tensor-fusion.ai/watch-node=true 标签。

接入私有化部署的控制台

私有化部署了控制台的企业用户,再设置三个参数即可安装 cluster agent。接入令牌和 agent ID 由控制台生成:

helm upgrade --install --create-namespace --namespace tensor-fusion-sys \
  --repo https://download.tensor-fusion.ai \
  --set agent.enrollToken=<enroll-token> \
  --set agent.agentId=<agent-id> \
  --set agent.cloudEndpoint=wss://<your-console-domain> \
  tensor-fusion-sys tensor-fusion

故障排查

没有 hypervisor Pod

只有同时匹配 initialGpuNodeLabelSelector 和资源池节点选择器的节点,operator 才会在上面启动 hypervisor Pod。先看哪些节点带有默认标签:

kubectl get nodes -l nvidia.com/gpu.present=true

如果 GPU 节点不在列表里,任选一种方式处理:

  • 给每个 GPU 节点打上标签:

    kubectl label node <gpu-node-name> nvidia.com/gpu.present=true
  • 或者沿用自己的标签,让 TensorFusion 按这个标签识别节点。标签值必须是 true:

    helm upgrade --install --create-namespace --namespace tensor-fusion-sys \
      --repo https://download.tensor-fusion.ai \
      --set initialGpuNodeLabelSelector=<your-label-key>=true \
      --set cluster.pool.nodeSelectorKey=<your-label-key> \
      tensor-fusion-sys tensor-fusion

节点标签正确但仍然没有 hypervisor Pod 时,查看 controller 日志:

kubectl logs -n tensor-fusion-sys deploy/tensor-fusion-sys-controller -c controller --tail=100

其他问题见问题处理手册。

卸载

卸载脚本会删除 TensorFusion 创建的全部内容:所有 TensorFusion 自定义资源和 CRD、controller、webhook、tensor-fusion-sys 和 greptimedb 两个命名空间及其中的 PVC,以及节点上的 TensorFusion 标签。nvidia.com/gpu.present 这类厂商标签会保留。正在使用 TensorFusion vGPU 的业务会失去 GPU,卸载前先迁移或停止这些业务。

curl -sfLO https://raw.githubusercontent.com/NexusGPU/tensor-fusion/main/scripts/uninstall.sh
bash uninstall.sh --help   # 查看参数和删除范围
bash uninstall.sh

脚本对当前 kubectl context 指向的集群执行,不会二次确认。它会等待资源删除完成,可能需要几分钟。

下一步

  • 创建 AI 应用:估算资源,把自己的应用跑在 vGPU 上。
  • 工作负载注解参考:全部 Pod 注解。
  • 生产级部署指南:高可用和外部 GreptimeDB。
  • TensorFusion 架构:各组件如何协作。

在虚拟机/服务器安装(K3S)

在服务器或虚拟机上用 K3s 搭建集群,再安装 TensorFusion

在宿主机/虚拟机安装

在宿主机上运行 tensor-fusion-worker,在虚拟机内加载 tensor-fusion-client,虚拟机不需要 GPU 直通就能使用宿主机的物理 GPU。这种模式称为 TensorFusion HyperGPU。

目录

前置条件
第 1 步:安装 chart
第 2 步:验证安装
第 3 步:运行测试负载
其他厂商的加速卡
接入私有化部署的控制台
故障排查
没有 hypervisor Pod
卸载
下一步