ollama+openwebui 部署本地自定义模型

ollama
https://github.com/ollama/ollama
open-webui
https://github.com/open-webui/open-webui

部署流程:

1**open-webui docker一键安装**
docker run -d -p 3000:8080 --gpus=all -v ollama:/root/.ollama -v open-webui:/app/backend/data --name open-webui --restart always ghcr.io/open-webui/open-webui:ollama

docker exec -it open-webui bash

2**下载ollama库**
git clone https://github.com/ollama/ollama.git
cd ollama

3**获取llama.cpp模块**
git submodule init 
git submodule update llm/llama.cpp

4**创建环境并安装依赖**
python -m venv llm/llama.cpp/.venv
source llm/llama.cpp/.venv/bin/activate

pip install -r llm/llama.cpp/requirements.txt

5**创建量化工具**
apt update
apt install make 
make -C llm/llama.cpp quantize

6**转换模型格式(如果模型是.safetensors)**./model 换成本地的模型目录)
python llm/llama.cpp/convert-hf-to-gguf.py ./model --outtype f16 --outfile converted.bin

7**量化模型**
(可选项)
llm/llama.cpp/quantize converted.bin quantized.bin q4_0

8**创建一个新的Modelfile**
apt install vim
vim xxx.Modelfile
**Modelfile内容**
:FROM llama3 # 替换成转换模型格式的模型路径,最简单的只需要这一行就够了
FROM llama3

# sets the temperature to 1 [higher is more creative, lower is more coherent]
PARAMETER temperature 1
 
# sets the context window size to 4096, this controls how many tokens the LLM can use as context to generate the next token
PARAMETER num_ctx 4096
 
# sets a custom system message to specify the behavior of the chat assistant
SYSTEM You are Mario from super mario bros, acting as an assistant.

9**创建并运行模型**
ollama create xxx -f  xxx.Modelfile
olama list
ollama run xxx

10,在open-webui 的docker容器中运行完上述命令之后,打开webui界面,在添加模型处就能看见创建的自定义模型

配置内网穿透,实现公网访问
1,服务器端配置

前提:阿里云云服务器,开放7000防火墙端口,阿里云服务器怎么搞,网上自己搜教程
wget https://github.com/fatedier/frp/releases/download/v0.48.0/frp_0.48.0_linux_amd64.tar.gz
tar -xzf frp_0.48.0_linux_amd64.tar.gz
cd frp_0.48.0_linux_amd64

添加可执行权限
chmod +x frps
启动命令:
nohup ./frps -c ./frps.ini &

2,客户端配置

wget https://github.com/fatedier/frp/releases/download/v0.48.0/frp_0.48.0_linux_amd64.tar.gz
tar -xzf frp_0.48.0_linux_amd64.tar.gz
cd frp_0.48.0_linux_amd64
vim frpc.ini
frpc.ini:
[common]
server_addr = 阿里云公网ip
server_port = 7000
privilege_token = xxxx,服务端和客户端的校验token,(可选项)

[ssh1]
type = tcp
local_ip = 客户端机器ip
local_port = 3000 web应用port
remote_port = 3000 

:wq 保存退出

添加可执行权限
chmod +x frpc
启动命令:
nohup ./frpc -c ./frpc.ini &

访问:阿里云公网ip+port,完成公网访问本地应用

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

zsh_abc

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值