ubuntu22.04部署ragflow和ollama

安装驱动和CUDA

参考下面这个链接
安装NVIDIA驱动
安装过程中可能会出现下面这个报错:
an error occurred while performing building kernel modules see /var/log/nvidia-installer.log for details. unrecognized command-line option…

原因是系统gcc版本和内核gcc版本不一致,安装gcc-12
That’s an issue with the Ubuntu kernel. For whatever reasons, the ubuntu kernel team decided to use gcc-12 for kernel compilation while the 22.04 system compiler is gcc-11. Please install gcc-12 from ubuntu repo to be able to compile the nvidia modules again.

sudo apt update
sudo apt install gcc-12 g++-12

并将gcc-12设置为默认编译器

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 12
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-12 12

验证gcc版本

gcc --version

部署ollama(本地)

打开ollama官网,选择linux,直接下载
ollama官网

下载完成之后,可以在官网下载模型,搜索你想下载的模型,复制右边的命令即可下载模型

ollama配置

需要修改ollama配置,如果不修改ragflow没办法访问到ollama
由于默认ollama绑定在127.0.0.1的11434端口,其他IP都拒绝
使用docker只能访问到自己不能访问到宿主机上,所以需要将ollama服务暴露给网络
方法修改如下文件:

vim /etc/systemd/system/ollama.service

在[Service]下继续添加如下内容,使ollama绑定到0.0.0.0的11434端口

Environment="OLLAMA_HOST=0.0.0.0"

填入的基础URL为

http://host.docker.internal:11434/

参考链接
ragflow无法访问ollama

解决linux中待机时间过长导致ollama回退到cpu处理模式的问题

笔记本电脑挂起恢复
在 Linux 上,经过一次挂起/恢复周期后,有时 Ollama 会无法发现你的 NVIDIA GPU,并回退到在 CPU 上运行。你可以通过重新加载 NVIDIA UVM 驱动来解决这个驱动程序错误,命令为 sudo rmmod nvidia_uvm && sudo modprobe nvidia_uvm。

出现这个问题后,复制下面四条命令重启ollama即可
The 999 error is a generic “unknown error” code, which isn’t super helpful.

What happens if you try removing the uvm module:

sudo systemctl stop ollama
sudo rmmod nvidia_uvm
sudo modprobe nvidia_uvm
sudo systemctl start ollama

如何找到这个问题呢,停止ollama然后重新启动ollama就会有log出来

sudo systemctl stop ollama
ollama serve

会有这些log出来,说明GPU找不到了,所以ollama又使用cpu来跑模型了

msg="unknown error initializing cuda driver library /usr/lib/x86_64-linux-gnu/libcuda.so.550.144.03: cuda driver library init failure: 999"
msg="no compatible GPUs were discovered"
msg="inference compute" id=0 library=cpu variant=avx2

解决方法参考链接
Unknown error initializing cuda driver library

部署ragflow(docker)

搜索ragflow,在github上面clone下来

git clone https://github.com/infiniflow/ragflow.git

ragflow有两个镜像版本,一个迷你版,一个完整版,推荐下载完整版本

如果要下载完整版本,打开ragflow/docker/.env,把完整版本取消注释,slim版本注释

然后执行下面这条命令即可拉取镜像

docker compose -f docker-compose.yml up -d

完成后,在浏览器输入0.0.0.0即可打开ragflow的网页

加入ollama里的模型

ollama list,复制模型名字

如图填即可

暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇