在Linux系统中安装Llama3模型可以通过多种方式实现,以下是使用Ollama工具和从GitHub直接部署的两种常见方法。
chmod +x ollama-linux-amd64
/usr/local/bin
目录,使其成为系统路径的一部分:sudo mv ollama-linux-amd64 /usr/local/bin/ollama
ollama run llama3:8b
这里的8b
指的是Llama3的80亿参数版本。您也可以使用ollama run llama3
来运行默认的8B模型。
git clone https://github.com/meta-llama/llama3.git
cd llama3
python3 -m venv venv
source venv/bin/activate
pip install -e .
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
注意:上述命令适用于带有特定CUDA版本的支持;如果目标机器不具备合适的硬件条件,则应选用CPU-only版本替代方案。
llama3/code/utils/init_process_group.py
文件中的nccl
为gloo
。export MASTER_ADDR=localhost
export MASTER_PORT=12355
export RANK=0
export WORLD_SIZE=1
chat.py
的文件,并粘贴必要的代码。python chat.py --ckpt_dir Meta-Llama-3-8B-Instruct/ --tokenizer_path Meta-Llama-3-8B-Instruct/tokenizer.model --max_seq_len 512 --max_batch_size 6
sudo apt-get update && sudo apt-get install -y apt-transport-https ca-certificates curl python-software-properties software-properties-common
curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/debian/gpg | sudo apt-key add -
# 根据您的Deepin Linux版本添加相应的Docker CE仓库
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
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
sudo systemctl start ollama
sudo systemctl status ollama
确认状态为“active (running)”。
ollama run llama3:8b
这将启动与模型的交互界面,您可以在浏览器中访问http://localhost:3000
来使用OpenWebUI。
以上步骤应该能帮助您在Linux系统上成功配置和运行Llama3模型。如果在安装过程中遇到问题,可以参考官方文档或相关社区支持。