在Linux中怎样安装Llama3服务

AI技术
小华
2025-06-20

在Linux中安装Llama3服务可以通过Ollama工具来实现,以下是详细的步骤:

环境准备

  1. 安装依赖软件包
sudo apt update && sudo apt install -y gcc make tar
  1. 安装Docker(如果尚未安装):
curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/debian/gpg | sudo apt-key add -
deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/debian buster stable
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io
sudo systemctl start docker
sudo systemctl enable docker

安装Ollama

  1. 下载并运行Ollama安装脚本
curl -fsSL https://ollama.com/install.sh | sh

或者,您可以先下载脚本查看内容,确认无误后再执行:

curl -fsSL https://ollama.com/install.sh -o install_ollama.sh
cat install_ollama.sh
bash install_ollama.sh
  1. 启动Ollama服务
  • 使用Docker方式启动Ollama服务:
docker run -d --gpus=all -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollama
  • 或者使用CLI命令启动Ollama服务:
ollama serve

下载并运行Llama3模型

  1. 拉取并运行Llama3模型
  • 进入Ollama容器并拉取Llama3模型:
docker exec -it ollama ollama run llama3

或者,如果你已经通过CLI启动了Ollama服务,可以使用以下命令:

ollama run llama3:instruct

使用OpenWebUI进行交互(可选)

  1. 安装OpenWebUI
docker run -d -p 3000:8080 --add-host=host.docker.internal:host-gateway -v open-webui:/app/backend/data --name open-webui --restart always ghcr.io/open-webui/open-webui:main

或者使用国内下载源:

docker run -d -p 3000:8080 --network=host -v open-webui:/app/backend/data -e OLLAMA_BASE_URL=http://127.0.0.1:11434 --name open-webui --restart always ghcr.io/open-webui/open-webui:main
  1. 验证安装
  • 启动Ollama服务:
sudo systemctl start ollama
sudo systemctl status ollama

确认状态为“active (running)”。

  • 运行模型:
ollama run llama3:8b

这将启动与模型的交互界面,您可以在浏览器中访问http://localhost:3000来使用OpenWebUI。
以上步骤应该能帮助您在Linux系统上成功配置并运行Llama3模型。如果在安装过程中遇到问题,可以参考Ollama的官方文档或相关社区支持。

亿速云提供售前/售后服务

售前业务咨询

售后技术保障

400-100-2938

7*24小时售后电话

官方微信小程序