TL;DR
|
A single GPU server for machine learning setup raises two questions before the first model runs. Will the model fit in the card’s memory? And can containers on the server actually reach the GPU? This guide answers both for a person or small team that runs its own server.
It is written against Ubuntu 24.04 LTS, the NVIDIA open kernel module driver, NVIDIA Container Toolkit 1.20.2-1 and Docker Engine from Docker’s apt repository, which supports Ubuntu Noble 24.04 (LTS). If the server is new to you, start with our owner’s checklist for managing your own dedicated server. This post assumes SSH access, updates and the firewall are already in place.
BEFORE YOU START
|
| CRITICAL Step 2 ends with a reboot: run it only after the remote console has been tested and works without SSH. Step 3 restarts the Docker daemon: run it only inside the maintenance window, with running containers allowed to stop. Steps 2 and 3: run them only after the restic snapshot and the daemon.json copy exist. |
Step 1: Check What Fits on One GPU
For short inputs, Hugging Face’s guide says inference memory is dominated by the memory needed to load the weights. Its rule of thumb is that a model with X billion parameters needs roughly 2 * X GB of video memory (VRAM) in bfloat16 or float16, and roughly 4 * X GB in float32.
The 7B and 13B rows below are our calculations from that rule. The other figures come from Hugging Face’s examples.
| Workload | Weight memory | 24 GB card | 48 GB card | 80 GB card |
|---|---|---|---|---|
| Inference, 7B model, bfloat16 | About 14 GB | Weights fit | Fits | Fits |
| Inference, 13B model, bfloat16 | About 26 GB | Does not fit | Fits | Fits |
| Inference, 15.5B code model, bfloat16 | 31 GB | Does not fit | Fits | Fits |
| Same model, 8-bit quantised | A bit over 15 GB peak | Fits | Fits | Fits |
| Inference, 70B model, bfloat16 | 140 GB | Does not fit | Does not fit | Does not fit |
Source: Hugging Face, Optimizing LLMs for Speed and Memory.
Apart from the 8-bit row, which is a measured peak, every figure in the table counts weights only. The same guide says peak self-attention memory grows quadratically with the number of input tokens, and becomes a serious problem at around 16,000 tokens. So a model whose weights only just fit leaves little room for long prompts.
Throughput is the second check. Quantisation saves memory but, as Hugging Face notes, inference time is often not reduced and can even increase.
If a row says does not fit, would a smaller or quantised model fit?
Step 2: Install the NVIDIA Driver for Compute Only
NVIDIA’s Ubuntu driver instructions cover Ubuntu 22.04, 24.04 and 26.04 . Lines starting with # run as root, as in NVIDIA’s guide. Replace <distribution> in the URL with ubuntu2404 for Ubuntu 24.04, the directory name in NVIDIA’s CUDA repository index.
# apt install linux-headers-$(uname -r)
$ wget https://developer.download.nvidia.com/compute/cuda/repos/<distribution>/x86_64/cuda-keyring_1.1-1_all.deb
# dpkg -i cuda-keyring_1.1-1_all.deb
# apt update
# apt -V install libnvidia-compute nvidia-dkms-open
# reboot
Check: after the reboot, run nvidia-smi. The header should show a Driver Version and a CUDA (Compute Unified Device Architecture) Version. Below it, your GPU should appear with a Memory-Usage column.
Step 3: Let Docker Containers Use the GPU
These are the apt steps for Ubuntu from the NVIDIA Container Toolkit install guide, with the toolkit version pinned.
sudo apt-get update && sudo apt-get install -y --no-install-recommends ca-certificates curl gnupg2
curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo 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' | \
sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
sudo apt-get update
export NVIDIA_CONTAINER_TOOLKIT_VERSION=1.20.2-1
sudo apt-get install -y \
nvidia-container-toolkit=${NVIDIA_CONTAINER_TOOLKIT_VERSION} \
nvidia-container-toolkit-base=${NVIDIA_CONTAINER_TOOLKIT_VERSION} \
libnvidia-container-tools=${NVIDIA_CONTAINER_TOOLKIT_VERSION} \
libnvidia-container1=${NVIDIA_CONTAINER_TOOLKIT_VERSION}
sudo nvidia-ctk runtime configure --runtime=docker
sudo systemctl restart docker
The nvidia-ctk command modifies /etc/docker/daemon.json so that Docker can use the NVIDIA Container Runtime.
Check: run the sample workload that the install guide’s Next Steps point to, sudo docker run --rm --runtime=nvidia --gpus all ubuntu nvidia-smi. It should print the same GPU table as the host.
Wrong result and undo: if the container reports no GPU, restore the copy, if one was made, with sudo cp /etc/docker/daemon.json.bak /etc/docker/daemon.json and run sudo systemctl restart docker.

Figure 1. The layers on the Ubuntu host after Steps 2 and 3: the NVIDIA driver sits on the GPU, and the NVIDIA Container Toolkit lets Docker Engine pass the GPU to a model container.
Step 4: Watch Utilisation and Memory While a Job Runs
Two views help while a job runs, as the nvidia-smi documentation shows. The first command prints one line per second until Ctrl+C is pressed. The second repeats the query every 5 seconds by default.
nvidia-smi dmon -s pu
nvidia-smi -l
In dmon, the p group reports power and temperature, and the u group reports utilisation. NVIDIA defines GPU utilisation as the percent of time over the sample period during which one or more kernels ran. Memory utilisation is the share of time device memory was being read or written.
What to Check After Setup
| Check | Command | Expected result |
|---|---|---|
| Driver loaded | nvidia-smi |
GPU listed with Driver Version and CUDA Version |
| GPU inside a container | sudo docker run --rm --runtime=nvidia --gpus all ubuntu nvidia-smi |
The same GPU table as on the host |
| Utilisation during a job | nvidia-smi dmon -s pu |
Utilisation above zero while the job runs |
| Memory headroom | nvidia-smi |
Memory-Usage below the total, with room for longer inputs |
Sources: NVIDIA Driver Installation Guide, NVIDIA Container Toolkit documentation, nvidia-smi documentation.
When a Single GPU Server for Machine Learning Is the Wrong Fit
One card stops being enough when the weights alone exceed its memory, as the 70B row shows. Our guide on why AI workloads need dedicated bare metal servers covers the case for dedicated hardware.
Will several teams share the GPUs? Our comparison of bare metal GPU servers and virtual GPUs for AI sets out that choice. Who applies driver updates and answers a GPU memory alert, or does managed support take that over?
FAQs
Why does a Docker container lose GPU access after systemctl daemon-reload?
NVIDIA lists this as a known issue on systems that use systemd cgroup drivers. Running systemctl daemon-reload can cause containers to lose access to the GPUs they requested. The install guide refers readers to the Container Toolkit troubleshooting documentation for more information.
Does nvidia-smi persistence mode stay on after a reboot?
No. The nvidia-smi documentation says setting persistence mode with -pm needs root and takes effect at once. After each reboot, persistence mode defaults to Disabled, so it has to be set again.
Where This Leaves Your Server
The server now has a compute-only driver, a tested container path to the GPU and two commands for reading utilisation and memory.
| NEXT STEP Choosing a GPU server to run yourself? Compare configurations on our AI Metal GPU bare metal servers page. |