Chỉ dùng CPU
shell
docker run -d -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollamaGPU Nvidia
Cài đặt NVIDIA Container Toolkit.
Cài đặt bằng Apt
Cấu hình kho lưu trữ
shellcurl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey \ | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg curl -fsSL 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 updateCài đặt các gói NVIDIA Container Toolkit
shellsudo apt-get install -y nvidia-container-toolkit
Cài đặt bằng Yum hoặc Dnf
Cấu hình kho lưu trữ
shellcurl -fsSL https://nvidia.github.io/libnvidia-container/stable/rpm/nvidia-container-toolkit.repo \ | sudo tee /etc/yum.repos.d/nvidia-container-toolkit.repoCài đặt các gói NVIDIA Container Toolkit
shellsudo yum install -y nvidia-container-toolkit
Cấu hình Docker để sử dụng trình điều khiển Nvidia
shell
sudo nvidia-ctk runtime configure --runtime=docker
sudo systemctl restart dockerKhởi động container
shell
docker run -d --gpus=all -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollamaLưu ý
Nếu bạn đang chạy trên hệ thống NVIDIA JetPack, Ollama không thể tự động phát hiện phiên bản JetPack chính xác. Truyền biến môi trường JETSON_JETPACK=5 hoặc JETSON_JETPACK=6 vào container để chọn phiên bản 5 hoặc 6.
GPU AMD
Để chạy Ollama bằng Docker với GPU AMD, hãy sử dụng thẻ rocm và lệnh sau:
shell
docker run -d --device /dev/kfd --device /dev/dri -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollama:rocmHỗ trợ Vulkan
Vulkan được đóng gói sẵn trong hình ảnh ollama/ollama và được bật theo mặc định khi container có thể truy cập các thiết bị GPU.
shell
docker run -d --device /dev/kfd --device /dev/dri -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollamaSử dụng OLLAMA_VULKAN=0 để tắt Vulkan, hoặc GGML_VK_VISIBLE_DEVICES=<ids> để chọn các thiết bị Vulkan cụ thể.
Chạy mô hình cục bộ
Bây giờ bạn có thể chạy một mô hình:
shell
docker exec -it ollama ollama run llama3.2Thử các mô hình khác nhau
Bạn có thể tìm thêm nhiều mô hình khác trên Thư viện Ollama.