自学内容网 自学内容网

ubuntu离线部署ollama

一、ollama部署
1、ollama官网安装教程,可以参考这个进行部署,下载对应版本
以intel为例下载安装包

curl -L https://ollama.com/download/ollama-linux-amd64.tgz -o ollama-linux-amd64.tgz
sudo tar -C /usr -xzf ollama-linux-amd64.tgz

2、运行安装包

ollama serve

查看是否已经运行

ollama -v

3、修改配置文件,使其他主机也可以访问,修改/etc/systemd/system/ollama.service文件
将原有的127.0.0.1,修改为0.0.0.0

sudo useradd -r -s /bin/false -U -m -d /usr/share/ollama ollama
sudo usermod -a -G ollama $(whoami)
[Unit]
Description=Ollama Service
After=network-online.target

[Service]
ExecStart=/usr/local/bin/ollama serve
User=ollama
Group=ollama
Restart=always
RestartSec=3
Environment="PATH=/home/ubuntu/.nvm/versions/node/v22.6.0/bin:/opt/anaconda3/bin:/opt/anaconda3/condabin:/opt/FFMPEG/bin:/opt/fdk-aac/bin:/opt/x265/bin:/opt/x264/bin:/opt/libssh2/bin:/opt/libtorch/bin:/opt/TensorRT/bin:/opt/cuda/bin:/opt/opencv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin"
Environment="OLLAMA_HOST=0.0.0.0"

[Install]
WantedBy=default.target

4、重载并重启服务

systemctl daemon-reload 
systemctl restart ollama.service

5、验证是否正常运行

curl localhost:11434
执行后显示Ollama is running说明服务运行正常

二、docker部署
1、依赖库安装

sudo apt install apt-transport-https ca-certificates curl software-properties-common gnupg lsb-release
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update

2、docker安装

sudo apt install docker-ce docker-ce-cli containerd.io docker-compose-plugin
systemctl status docker
sudo systemctl start docker
sudo systemctl enable docker

3、查看是否安装成功

sudo docker version
sudo docker run hello-world

三、open-webui部署
1、open-webui下载链接,将下载后的文件移动到/var/lib/docker/volumes/下,对应的文件结构为/var/lib/docker/volumes/open-webui。2、其中3000为对外端口号,可以根据自己的需求进行设置

 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

说明:
–add-host:将host.docker.internal=host-gateway添加到容器内/etc/hosts中,即容器内的hosts文件会增加一条记录172.17.0.1 host.docker.internal。host.docker.internal=host-gateway是固定用法。
-v open-webui:/app/backend/data : 将宿主机的open-webui目录映射到容器/app/backend/data目录。

3、在浏览器地址栏输入http://ip:port

针对性对中文优化的llama3:Llama3-Chinese-8B


原文地址:https://blog.csdn.net/OEMT_301/article/details/143492299

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!