linux远端部署llama3测试

2024-6-25 89 6/25

linux远端部署llama3测试

ollama的链接: https://ollama.com/

open webui的链接: https://github.com/open-webui/open-webui

github:https://github.com/ollama/ollama

docker:https://hub.docker.com/r/ollama/ollama

linux部署ollama参考:https://ollama.fan/getting-started/linux/

一、下载

(linux由于国内网络环境下载会失败,使用魔法从github下载,然后再上传到服务器)

linux远端部署llama3测试

linux远端部署llama3测试

二、安装。

sudo curl -L https://ollama.com/download/ollama-linux-amd64 -o /usr/bin/ollama
sudo chmod +x /usr/bin/ollama

将 Ollama 添加为启动服务

为 Ollama 创建一个用户:

sudo useradd -r -s /bin/false -m -d /usr/share/ollama ollama

/etc/systemd/system/ollama.service 中创建一个服务文件:

[Unit]
Description=Ollama Service
After=network-online.target

[Service]
Environment="OLLAMA_HOST=0.0.0.0:11434"
ExecStart=/usr/bin/ollama serve
User=ollama
Group=ollama
Restart=always
RestartSec=3
Environment="PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin"

[Install]
WantedBy=default.target

#然后启动服务:
sudo systemctl daemon-reload
sudo systemctl enable ollama

三、使用ollama运行llama3模型。

Model Parameters Size Download
Llama 3 8B 4.7GB ollama run llama3

linux远端部署llama3测试

linux远端部署llama3测试

本地部署Open WebUI (Formerly Ollama WebUI)

open webui的链接: https://github.com/open-webui/open-webui

一、Open WebUI基于docker启动,安装docker,docker-compose

#阿里源 
curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -

sudo add-apt-repository "deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"

sudo apt-get update
sudo apt-get install -y docker-ce

curl -sL https://mydata:mydata@cloud-images.chinamye.com/software/docker-compose/v2.17.2/docker-compose > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose

#ward  一个基于docker启动的小小的服务器状态监控软件
http://172.100.70.47:4000/

linux远端部署llama3测试

二、使用docker启动Open WebUI

Installation with Default Configuration

  • If Ollama is on your computer, use this command:

    #参考文档
    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镜像源
    docker run -d -p 8080:8080 --add-host=host.docker.internal:host-gateway -v open-webui:/app/backend/data --name open-webui --restart always ghcr.nju.edu.cn/open-webui/open-webui:main 
    
    #根据docker run命令编辑docker-compose 文件
    version: "3"
    services:
    open-webui:
      image: ghcr.nju.edu.cn/open-webui/open-webui:main
      restart: unless-stopped
      container_name: open-webui
      ports:
        - '8080:8080' 
      extra_hosts:
        - host.docker.internal:host-gateway
      volumes:
        - open-webui:/app/backend/data
    
    volumes:
      open-webui:
          external: true
          name: open-webui
    
    #手动创建卷
    docker volume create open-webui
  • If Ollama is on a Different Server, use this command:(如果ollama在本地启动)

    To connect to Ollama on another server, change the OLLAMA_BASE_URL to the server's URL:

    docker run -d -p 3000:8080 -e OLLAMA_BASE_URL=https://example.com -v open-webui:/app/backend/data --name open-webui --restart always ghcr.io/open-webui/open-webui:main

    To run Open WebUI with Nvidia GPU support, use this command:(Open WebUI 使用GPU)

    docker run -d -p 3000:8080 --gpus all --add-host=host.docker.internal:host-gateway -v open-webui:/app/backend/data --name open-webui --restart always ghcr.io/open-webui/open-webui:cuda

三、访问web页面

直接访问IP:8080

http://172.100.70.47:8080
账户:test@mye.hk
密码:test@mye.hk

注册并登陆

linux远端部署llama3测试

- THE END -

iyuyi12138

6月25日11:13

最后修改:2024年6月25日
1

非特殊说明,本博所有文章均为博主原创。