Assuming you start with a vanilla Ubuntu, you need to install Nvidia stuff
Add Nvidia apt
registries:
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
Install and configure docker to use Nvidia:
sudo apt-get update
sudo apt-get install -y nvidia-container-toolkit
sudo nvidia-ctk runtime configure --runtime=docker
sudo systemctl restart docker
Create a directory to store ollama's model files. Make sure you have at least a few 100 Gb free on a fast drive:
mkdir -p ollama/ollama-data
Copy the docker-compose.yml
file into the ollama/
directory you create.
cd ollama
docker compose up -d