Deploy a Private AI Platform on Your GPU Cluster
In this article
Yes, you can deploy a private AI platform on your own GPU cluster by installing NVIDIA drivers, configuring a container runtime, and orchestrating model services with Kubernetes or Docker Compose.
What You’ll Need
- Linux server (Ubuntu 20.04 LTS or newer recommended) with one or more NVIDIA GPUs.
- Supported NVIDIA driver matching the CUDA version you plan to use (e.g., driver 525 for CUDA 12).
- CUDA toolkit installed on each node if you plan to compile custom kernels.
- Docker Engine (19.03+) and nvidia-docker2 (NVIDIA Container Toolkit).
- Kubernetes (kubeadm, kubelet, kubectl) or Docker Compose, depending on your orchestration preference.
- Persistent storage solution (NFS, Ceph, or local SSDs) for model checkpoints and logs.
- Access to the model container images (e.g., Hugging Face, TensorFlow Serving, or custom Dockerfiles).
- Basic networking knowledge: firewall rules, DNS, and TLS certificates for secure access.
- Monitoring tools such as Prometheus node exporter and NVIDIA DCGM Exporter.
- A user account with sudo privileges on each node.
Step-by-Step
- Prepare the host OS. Update the package index, install
build-essential,curl, andgit. Reboot after any kernel updates. - Install NVIDIA drivers. Follow the official NVIDIA Linux driver installer or use the Ubuntu
aptrepository:sudo apt-get install nvidia-driver-525. Verify withnvidia-smi. - Install Docker Engine. Run the Docker convenience script or follow the Docker docs:
sudo apt-get install docker.io. Add your user to thedockergroup:sudo usermod -aG docker $USER. - Set up NVIDIA Container Toolkit. Add the NVIDIA package repository, install
nvidia-docker2, then restart Docker:sudo systemctl restart docker. Test withdocker run --gpus all nvidia/cuda:12.0-base nvidia-smi. - Choose an orchestration method. For production clusters, install Kubernetes with
kubeadm initon the master node and join workers. For smaller setups, Docker Compose is sufficient. - Configure GPU access in the orchestrator. In Kubernetes, enable the device plugin by installing the NVIDIA GPU Operator or the
nvidia.com/gpuresource definition. In Docker Compose, addruntime: nvidiaanddeploy: resources: reservations: devices:entries. - Pull or build your model image. Example for Hugging Face Transformers:
docker pull ghcr.io/huggingface/transformers-pytorch-gpu:latest. If you have custom code, write a Dockerfile that installs the required Python packages and copies the model files. - Create persistent volume claims. Define a
PersistentVolume(PV) that points to your NFS share or local SSD, then aPersistentVolumeClaim(PVC) that your model pod will mount at/models. - Deploy the model service. Write a Kubernetes
Deploymentmanifest that requestsresources: limits: nvidia.com/gpu: 1, mounts the PVC, and exposes the container port (e.g., 8080). Apply withkubectl apply -f deployment.yaml. For Docker Compose, define a service withdeploy:GPU reservations andports:mapping. - Expose the service securely. Create a
Serviceof typeLoadBalancerorNodePort, then place an ingress controller (NGINX or Traefik) in front. Generate TLS certificates via Let's Encrypt or use self‑signed certs, and enforce HTTPS. - Set up authentication. Use an API gateway (e.g., Kong, Ambassador) to require API keys or OAuth tokens before forwarding requests to the model pod. Store secrets in Kubernetes
Secretobjects. - Monitor and log. Deploy the NVIDIA DCGM Exporter and Prometheus to collect GPU utilization metrics. Forward container logs to a centralized system like Loki or Elasticsearch.
- Test the endpoint. Send a curl request with a JSON payload to
https://your‑domain.com/v1/predict. Verify the response and latency. Adjust replica count in the Deployment if needed.
Common Mistakes
- Installing a driver that does not match the CUDA version in the container image, leading to
CUDA driver version is insufficienterrors. - Forgetting to enable the NVIDIA runtime for Docker, which results in containers starting without GPU access.
- Allocating more GPU memory than the card provides, causing out‑of‑memory termination of the model server.
- Exposing the model port directly to the internet without authentication, opening the system to abuse.
- Neglecting to set resource limits in Kubernetes, which can cause the scheduler to place GPU‑heavy pods on nodes without GPUs.
Tips
- Use Helm charts (e.g., the official
gpu-operatorchart) to simplify GPU driver and runtime installation across many nodes. - Version your Docker images with both model and library tags (e.g.,
my‑model:1.2‑torch2.2‑cuda12.0) to avoid accidental upgrades. - Run
nvidia-smi -l 5on each node to continuously monitor GPU health during initial load testing. - Store large model files on a high‑throughput SSD or NVMe volume; network‑mounted storage can become a bottleneck for inference latency.
- Automate CI/CD pipelines that rebuild the container image when model weights are updated, then roll out the new Deployment with zero downtime.
Troubleshooting
GPU not visible inside containers: Verify that nvidia-docker2 is installed and Docker has been restarted. Run docker run --gpus all nvidia/cuda:12.0-base nvidia-smi. If it fails, check the driver version with nvidia-smi on the host.
Pod stays in Pending state: Ensure the node has the nvidia.com/gpu resource advertised. Run kubectl describe node and look for Capacity: nvidia.com/gpu. If missing, reinstall the GPU Operator.
Out‑of‑memory errors: Reduce the batch size in your inference code or request a node with a GPU that has more VRAM. You can also enable tensor‑core optimizations if the model supports them.
Network timeout when calling the API: Check firewall rules on the host and any cloud security groups. Confirm the ingress controller is listening on port 443 and that TLS certificates are valid.
Logs are empty or not rotating: Verify the logging driver in Docker is set to json-file or a centralized system. In Kubernetes, ensure the logrotate daemon is configured on each node.
Frequently Asked Questions
Do I need an internet connection for the deployment?
Only for pulling base images and optional TLS certificate issuance. Once the images are cached locally, the cluster can operate fully offline.
Can I use TensorFlow instead of PyTorch?
Yes. Pull a TensorFlow Serving GPU image (e.g., tensorflow/serving:2.13.0-gpu) and adjust the model path and input format accordingly.
How do I scale the platform to handle more requests?
Increase the replica count in the Deployment manifest and, if needed, add more GPU nodes to the Kubernetes cluster. The scheduler will place pods on any node with free GPUs.
What security measures should I enable?
Use HTTPS with valid certificates, enforce API‑key or OAuth authentication at the ingress level, and restrict inbound traffic to the load‑balancer IP ranges you control.
Can I back up model checkpoints while the service is running?
Yes. Mount the model directory on a read‑write volume and schedule regular snapshots (e.g., using rsync or a storage‑system snapshot feature). The inference server can continue serving from the same files.
Is it possible to run multiple different models on the same cluster?
Absolutely. Deploy each model as a separate Kubernetes Deployment with its own PVC and service name. Use namespace isolation if you need stricter resource segregation.