安装Ollama通过Open-Webui运行访问llama2、GPT大模型

安装Ollama并运行

本地安装Ollama并运行

shell 复制代码
mkdir -p /data/

curl -fsSL https://ollama.com/install.sh | sh
>>> Downloading ollama...
######################################################################## 100.0%
>>> Installing ollama to /usr/local/bin...
>>> Creating ollama user...
>>> Adding ollama user to video group...
>>> Adding current user to ollama group...
>>> Creating ollama systemd service...
>>> Enabling and starting ollama service...
Created symlink from /etc/systemd/system/default.target.wants/ollama.service to /etc/systemd/system/ollama.service.
>>> The Ollama API is now available at 127.0.0.1:11434.
>>> Install complete. Run "ollama" from the command line.
WARNING: No NVIDIA/AMD GPU detected. Ollama will run in CPU-only mode.

运行大模型

安装完,即可 支持命令行交互 对话

shell 复制代码
ollama run llama2
> 这时系统会自动下载对应的大模型文件。

pulling manifest
pulling 8934d96d3f08... 100% ▕██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▏ 3.8 GB
pulling 8c17c2ebb0ea... 100% ▕██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▏ 7.0 KB
pulling 7c23fb36d801... 100% ▕██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▏ 4.8 KB
pulling 2e0493f67d0c... 100% ▕██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▏   59 B
pulling fa304d675061... 100% ▕██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▏   91 B
pulling 42ba7f8a01dd... 100% ▕██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▏  557 B
verifying sha256 digest
writing manifest
removing any unused layers
success

>>> hello
Hello! It's nice to meet you. Is there something I can help you with or would you like to chat?

>>> Send a message (/? for help)

大模型的models

安装运行70b版本模型测试

shell 复制代码
ollama run llama2:70b

通过Web访问模型

不可能一直通过命令行交互实现chat

通过web控制台,类似chatgpt

更改Ollama运行模式

首先,修改Ollama运行模式为后端模式

shell 复制代码
screen
ollama serve
netstat -antp | grep ollama

安装open-webui依赖

安装docker「已安装则可选」

shell 复制代码
# docker 依赖
yum install -y yum-utils device-mapper-persistent-data  lvm2 --skip-broken
yum install screen

yum-config-manager     --add-repo     https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

sed -i 's/download.docker.com/mirrors.aliyun.com\/docker-ce/g' /etc/yum.repos.d/docker-ce.repo

yum makecache fast

yum install -y docker-ce

chkconfig docker on
service docker restart
service docker status

安装open-webui

用于在web交互ollama

shell 复制代码
docker run -d -p 3000:8080 -e OLLAMA_BASE_URL=http://172.31.130.74:11434 -v open-webui:/app/backend/data --name open-webui --restart always ghcr.io/open-webui/open-webui:main

允许访问open-webui API

shell 复制代码
vi /etc/systemd/system/ollama.service
增加
Environment="OLLAMA_HOST=0.0.0.0:11434"


systemctl daemon-reload
systemctl restart ollama

可能还需要开通防火墙 最终访问 http://172.31.130.74:11434/api 即可

通过api访问ollama

验证通过api可访问ollama

shell 复制代码
curl http://localhost:11434/api/generate -d '{   "model": "llama2:70b",   "prompt":"Why is the sky blue?" }'

验证和访问open-webui

访问页面,注册账号。models列表可见即可。

添加其他模型

Q&A

Models

  • gemma:2b,这是 Google 及其 DeepMind 团队开发的新型开放模型。
  • qwen:0.5b,这是阿里云推出的基于 Transformer 的大型语言模型

「可选扩容磁盘」

shell 复制代码
阿里云在线扩容系统盘

# 第二步 在线扩容分区
fdisk -lu

Disk /dev/vda: 274.9 GB, 274877906944 bytes, 536870912 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000c6592

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048    83886046    41941999+  83  Linux


type growpart || sudo yum install -y cloud-utils-growpart
growpart is /usr/bin/growpart

sudo LC_ALL=en_US.UTF-8 growpart /dev/vda 1
CHANGED: partition=1 start=2048 old: size=83883999 end=83886047 new: size=536868831 end=536870879


# 第三步 在线扩容文件系统
df -Th
Filesystem     Type      Size  Used Avail Use% Mounted on
devtmpfs       devtmpfs   31G     0   31G   0% /dev
tmpfs          tmpfs      31G     0   31G   0% /dev/shm
tmpfs          tmpfs      31G  608K   31G   1% /run
tmpfs          tmpfs      31G     0   31G   0% /sys/fs/cgroup
/dev/vda1      ext4       40G   25G   14G  65% /
tmpfs          tmpfs     6.2G     0  6.2G   0% /run/user/0

sudo resize2fs /dev/vda1
resize2fs 1.42.9 (28-Dec-2013)
Filesystem at /dev/vda1 is mounted on /; on-line resizing required
old_desc_blocks = 3, new_desc_blocks = 16
The filesystem on /dev/vda1 is now 67108603 blocks long.

df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs         31G     0   31G   0% /dev
tmpfs            31G     0   31G   0% /dev/shm
tmpfs            31G  608K   31G   1% /run
tmpfs            31G     0   31G   0% /sys/fs/cgroup
/dev/vda1       252G   25G  218G  10% /
tmpfs           6.2G     0  6.2G   0% /run/user/0
相关推荐
Qhumaing1 分钟前
C++学习:【PTA】数据结构 7-1 实验7-1(最小生成树-Prim算法)
c++·学习·算法
十二AI编程1 小时前
Anthropic 封杀 OpenCode,OpenAI 闪电接盘:AI 编程生态的 48 小时闪电战
人工智能·chatgpt
CCC:CarCrazeCurator1 小时前
从 APA 到 AVP:汽车自动泊车系统技术演进与产业发展深度研究
人工智能
OpenMiniServer2 小时前
当 AI 成为 Git 里的一个“人”
人工智能·git
Z1Jxxx2 小时前
01序列01序列
开发语言·c++·算法
bryant_meng2 小时前
【DLNR】《High-frequency Stereo Matching Network》
人工智能·深度学习·计算机视觉·stereo matching·dlnr
梦雨羊2 小时前
Base-NLP学习
人工智能·学习·自然语言处理
丝斯20112 小时前
AI学习笔记整理(42)——NLP之大规模预训练模型Transformer
人工智能·笔记·学习
实战项目2 小时前
大语言模型幻觉抑制方法的研究与实现
人工智能·语言模型·自然语言处理