1、一台有 NVIDIA GPU 驱动的机器
2、Docker CE安装
# 删除旧版本的 Docker(如果存在)
sudo yum remove -y docker docker-common docker-selinux docker-engine
# 安装必要的软件包:
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
# 添加 Docker CE 存储库:
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
# 安装 Docker CE
sudo yum install -y docker-ce
# 启动 Docker 服务
sudo systemctl start docker
# 设置 Docker 开机自启
sudo systemctl enable docker
3、安装NVIDIA docker Container Toolkit
# 添加 NVIDIA Container Toolkit 存储库密钥
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.repo | sudo tee /etc/yum.repos.d/nvidia-docker.repo
# 安装 NVIDIA Container Toolkit
sudo yum install -y nvidia-docker2
4、安装NVIDIA docker Container Toolkit
#创建或编辑 Docker 配置文件 /etc/docker/daemon.json
vi /etc/docker/daemon.json
# 添加以下内容到文件中,保存:
{
"default-runtime": "nvidia",
"runtimes": {
"nvidia": {
"path": "nvidia-container-runtime",
"runtimeArgs": []
}
}
}
5、重启 Docker 服务
sudo systemctl restart docker
6、安装ollama,用gpu,docker
docker run -d --gpus=all -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollama
7、使用案例
docker exec -it ollama ollama run llama3
参考来源:
https://hub.docker.com/r/ollama/ollama
GitHub - ollama/ollama: Get up and running with Llama 3, Mistral, Gemma, and other large language models.
centOS 快速安装和配置 NVIDIA docker Container Toolkit_nvidia container toolkit-CSDN博客