VM/Server Install(K3S)
Build a K3s cluster on your servers or virtual machines, then install TensorFusion on it
TensorFusion's GPU pool runs on Kubernetes. If you only have bare-metal servers or virtual machines, this guide turns them into a lightweight K3s cluster and joins the GPU servers as nodes. After that, you install TensorFusion the same way as on any other Kubernetes cluster.
K3s runs next to the services already on these machines. You don't need to containerize or move them.
If you already have a Kubernetes cluster, go straight to Kubernetes Install. To use a host's GPU from a VM without Kubernetes, see Host/GuestVM Install.
Prerequisites
- One Linux machine for the K3s server (the control plane). It may or may not have a GPU.
- One or more Linux machines with NVIDIA GPUs. The server machine can be one of them.
- The NVIDIA driver is installed on every GPU machine and
nvidia-smiworks. If it doesn't, install the driver first. - Root access on every machine. Run all commands in this guide as root.
- GPU machines can reach the server machine on port 6443.
- Every machine can pull images from Docker Hub, or uses the registry mirror in the next section.
Choose the download source
Run one of these blocks on every machine before the other steps. The later commands use $K3S_INSTALL_URL.
export K3S_INSTALL_URL=https://get.k3s.ioexport K3S_INSTALL_URL=https://rancher-mirror.rancher.cn/k3s/k3s-install.sh
export INSTALL_K3S_MIRROR=cn
# Pull images through registry mirrors, and pull tensorfusion/* images from a mirror registry in China
mkdir -p /etc/rancher/k3s/
cat > /etc/rancher/k3s/registries.yaml << 'EOF'
mirrors:
docker.io:
endpoint:
- "https://docker.m.daocloud.io"
- "https://docker.1ms.run"
gcr.io:
endpoint:
- "https://gcr.m.daocloud.io"
ghcr.io:
endpoint:
- "https://ghcr.m.daocloud.io"
registry.k8s.io:
endpoint:
- "https://k8s.m.daocloud.io"
nvcr.io:
endpoint:
- "https://nvcr.m.daocloud.io"
quay.io:
endpoint:
- "https://quay.m.daocloud.io"
configs:
"docker.io":
auth: {}
tls: {}
rewrite:
"^docker.io/tensorfusion/(.*)": "registry.cn-hangzhou.aliyuncs.com/tensorfusion/$1"
EOFStep 1. Prepare every GPU machine
Do this on each machine that has a GPU, including the server machine if it has one, before you install K3s on it.
-
Install the NVIDIA Container Toolkit. For other distributions, see the NVIDIA install guide.
curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list | \ sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \ tee /etc/apt/sources.list.d/nvidia-container-toolkit.list apt-get update apt-get install -y nvidia-container-toolkitcurl -s -L https://nvidia.github.io/libnvidia-container/stable/rpm/nvidia-container-toolkit.repo | \ tee /etc/yum.repos.d/nvidia-container-toolkit.repo dnf install -y nvidia-container-toolkit # If dnf is not available: yum install -y nvidia-container-toolkitcurl -fsSL https://mirrors.ustc.edu.cn/libnvidia-container/gpgkey | gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg curl -s -L https://mirrors.ustc.edu.cn/libnvidia-container/stable/deb/nvidia-container-toolkit.list | \ sed 's#deb https://nvidia.github.io#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://mirrors.ustc.edu.cn#g' | \ tee /etc/apt/sources.list.d/nvidia-container-toolkit.list apt-get update apt-get install -y nvidia-container-toolkitcurl -s -L https://mirrors.ustc.edu.cn/libnvidia-container/stable/rpm/nvidia-container-toolkit.repo | \ sed 's#nvidia.github.io/libnvidia-container/stable/#mirrors.ustc.edu.cn/libnvidia-container/stable/#g' | \ sed 's#nvidia.github.io/libnvidia-container/experimental/#mirrors.ustc.edu.cn/libnvidia-container/experimental/#g' | \ tee /etc/yum.repos.d/nvidia-container-toolkit.repo dnf install -y nvidia-container-toolkit # If dnf is not available: yum install -y nvidia-container-toolkit -
Make the NVIDIA runtime the default container runtime of K3s. K3s reads this template when it starts:
mkdir -p /var/lib/rancher/k3s/agent/etc/containerd/ cat > /var/lib/rancher/k3s/agent/etc/containerd/config.toml.tmpl << 'EOF' version = 2 [plugins."io.containerd.internal.v1.opt"] path = "/var/lib/rancher/k3s/agent/containerd" [plugins."io.containerd.grpc.v1.cri"] stream_server_address = "127.0.0.1" stream_server_port = "10010" enable_selinux = false enable_unprivileged_ports = true enable_unprivileged_icmp = true device_ownership_from_security_context = false sandbox_image = "rancher/mirrored-pause:3.6" [plugins."io.containerd.grpc.v1.cri".containerd] snapshotter = "overlayfs" disable_snapshot_annotations = true [plugins."io.containerd.grpc.v1.cri".cni] bin_dir = "/var/lib/rancher/k3s/data/cni" conf_dir = "/var/lib/rancher/k3s/agent/etc/cni/net.d" [plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc] runtime_type = "io.containerd.runc.v2" [plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc.options] SystemdCgroup = true BinaryName = "/usr/bin/nvidia-container-runtime" [plugins."io.containerd.grpc.v1.cri".registry] config_path = "/var/lib/rancher/k3s/agent/etc/containerd/certs.d" EOFThis template uses containerd configuration version 2. K3s releases that ship containerd 2.x read
config-v3.toml.tmplinstead. If GPU Pods cannot see the GPU after installation, check the K3s documentation on the NVIDIA container runtime for your K3s version.
Step 2. Install the K3s server
On the server machine, run the command that matches it. --tls-san adds the machine's public IP to the API server certificate so that you can use kubectl from outside; drop the flag if you only access the cluster from the private network.
curl -sfL $K3S_INSTALL_URL | sh -s - server --tls-san $(curl -s https://ifconfig.me)# Finish step 1 on this machine first
curl -sfL $K3S_INSTALL_URL | sh -s - server \
--node-label nvidia.com/gpu.present=true \
--tls-san $(curl -s https://ifconfig.me)The label nvidia.com/gpu.present=true is how TensorFusion recognizes a GPU node.
Check that the server node is Ready, then print the join token. You need the token in the next step.
export KUBECONFIG=/etc/rancher/k3s/k3s.yaml
kubectl get nodes
cat /var/lib/rancher/k3s/server/node-tokenStep 3. Join the GPU machines
On each remaining GPU machine, after finishing step 1 there, run:
export MASTER_IP=<private-ip-of-the-server-machine>
export K3S_TOKEN=<token-from-step-2>
curl -sfL $K3S_INSTALL_URL | K3S_URL=https://$MASTER_IP:6443 K3S_TOKEN=$K3S_TOKEN \
INSTALL_K3S_EXEC="--node-label nvidia.com/gpu.present=true" sh -s -If the installer fails on a container-selinux dependency, set this variable and run the install command again:
export INSTALL_K3S_SKIP_SELINUX_RPM=trueStep 4. Check the GPU nodes
On the server machine:
export KUBECONFIG=/etc/rancher/k3s/k3s.yaml
kubectl get nodes -l nvidia.com/gpu.present=trueEvery GPU machine is listed with status Ready:
NAME STATUS ROLES AGE VERSION
gpu-node-1 Ready <none> 2m v1.32.1+k3s1Step 5. Install TensorFusion
-
Install Helm on the server machine. K3s does not include it. Keep
KUBECONFIG=/etc/rancher/k3s/k3s.yamlexported so that Helm andkubectlreach the cluster. -
Install TensorFusion in one of two ways:
- Kubernetes Install connects the cluster to the TensorFusion Console.
- Helm Quick Install uses Helm only.
If you chose the mainland China mirror above, also add
-f https://download.tensor-fusion.ai/values-cn.yamlto the Helm command, as both guides describe. -
Follow the verification steps in the guide you chose. They end with a test Pod running on a vGPU.
Uninstall
-
Remove TensorFusion. See the uninstall section of Kubernetes Install.
-
Remove K3s from each GPU machine that joined as an agent:
/usr/local/bin/k3s-agent-uninstall.sh -
Remove K3s from the server machine:
/usr/local/bin/k3s-uninstall.sh
Next steps
- Create Workload: run your own application on a vGPU.
- Migrate Existing Workload: move services that use GPUs today onto TensorFusion.
- Architecture: how the components fit together.
TensorFusion Docs