2024-08-05 08:25:33 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# Ollama Docker image
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								### CPU only
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-02-08 01:55:07 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```shell
							 
						 
					
						
							
								
									
										
										
										
											2024-08-05 08:25:33 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								docker run -d -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollama
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								### Nvidia GPU
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Install the [NVIDIA Container Toolkit ](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html#installation ).
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#### Install with Apt
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								1.   Configure the repository 
						 
					
						
							
								
									
										
										
										
											2025-02-08 01:55:07 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ```shell
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    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
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-08-05 08:25:33 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								2.   Install the NVIDIA Container Toolkit packages 
						 
					
						
							
								
									
										
										
										
											2025-02-08 01:55:07 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ```shell
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    sudo apt-get install -y nvidia-container-toolkit
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ```
							 
						 
					
						
							
								
									
										
										
										
											2024-08-05 08:25:33 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#### Install with Yum or Dnf
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								1.   Configure the repository 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-02-08 01:55:07 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ```shell
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    curl -s -L https://nvidia.github.io/libnvidia-container/stable/rpm/nvidia-container-toolkit.repo \
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        | sudo tee /etc/yum.repos.d/nvidia-container-toolkit.repo
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ```
							 
						 
					
						
							
								
									
										
										
										
											2024-08-05 08:25:33 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								2.  Install the NVIDIA Container Toolkit packages 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-02-08 01:55:07 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ```shell
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    sudo yum install -y nvidia-container-toolkit
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ```
							 
						 
					
						
							
								
									
										
										
										
											2024-08-05 08:25:33 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#### Configure Docker to use Nvidia driver
  
						 
					
						
							
								
									
										
										
										
											2025-02-08 01:55:07 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```shell
							 
						 
					
						
							
								
									
										
										
										
											2024-08-05 08:25:33 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								sudo nvidia-ctk runtime configure --runtime=docker
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								sudo systemctl restart docker
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#### Start the container
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-02-08 01:55:07 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```shell
							 
						 
					
						
							
								
									
										
										
										
											2024-08-05 08:25:33 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								docker run -d --gpus=all -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollama
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-11-15 08:02:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								>  [!NOTE]  
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								>  If you're running on an NVIDIA JetPack system, Ollama can't automatically discover the correct JetPack version. Pass the environment variable JETSON_JETPACK=5 or JETSON_JETPACK=6 to the container to select version 5 or 6.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-08-05 08:25:33 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### AMD GPU
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								To run Ollama using Docker with AMD GPUs, use the `rocm`  tag and the following command:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-02-08 01:55:07 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```shell
							 
						 
					
						
							
								
									
										
										
										
											2024-08-05 08:25:33 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								docker run -d --device /dev/kfd --device /dev/dri -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollama:rocm
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								### Run model locally
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Now you can run a model:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-02-08 01:55:07 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```shell
							 
						 
					
						
							
								
									
										
										
										
											2024-09-26 02:11:22 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								docker exec -it ollama ollama run llama3.2
							 
						 
					
						
							
								
									
										
										
										
											2024-08-05 08:25:33 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								### Try different models
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								More models can be found on the [Ollama library ](https://ollama.com/library ).