README.md 2.19 KB
Newer Older
xuxzh1's avatar
init  
xuxzh1 committed
1
# <div align="center"><strong>Ollama</strong></div>
mashun1's avatar
mashun1 committed
2

xuxzh1's avatar
init  
xuxzh1 committed
3
## 简介
mashun1's avatar
mashun1 committed
4

xuxzh1's avatar
init  
xuxzh1 committed
5
1 Ollama是以llama.cpp为后端的前端大模型推理框架,可快速部署主流模型。
mashun1's avatar
v1  
mashun1 committed
6

xuxzh1's avatar
init  
xuxzh1 committed
7
## 安装
mashun1's avatar
v1  
mashun1 committed
8

xuxzh1's avatar
init  
xuxzh1 committed
9
### 1、使用dockerfile方式安装
mashun1's avatar
mashun1 committed
10

xuxzh1's avatar
init  
xuxzh1 committed
11
直接下载本仓库中的`v0.3.5`分支,然后执行`docker build xxxxx`相关命令(具体需自行查阅相关资料)。
mashun1's avatar
v1  
mashun1 committed
12

xuxzh1's avatar
init  
xuxzh1 committed
13
如遇到卡数检测错误,请参考 https://developer.hpccube.com/codes/OpenDAS/ollama/-/issues/1 ,也可以提前进行修复。
mashun1's avatar
v1  
mashun1 committed
14

xuxzh1's avatar
init  
xuxzh1 committed
15
### 2、使用源码编译方式安装
mashun1's avatar
v1  
mashun1 committed
16

xuxzh1's avatar
init  
xuxzh1 committed
17
#### 环境准备
mashun1's avatar
mashun1 committed
18

xuxzh1's avatar
init  
xuxzh1 committed
19
##### Docker
mashun1's avatar
mashun1 committed
20

xuxzh1's avatar
init  
xuxzh1 committed
21
22
23
    docker pull docker pull image.sourcefind.cn:5000/dcu/admin/base/pytorch:2.1.0-py3.10-dtk24.04.3-ubuntu20.04
    
    docker run -i -t -d  --device=/dev/kfd --privileged --network=host --device=/dev/dri --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -v 项目地址(绝对路径):/home  -v /opt/hyhal:/opt/hyhal:ro -v --group-add video --shm-size 16G --name {容器名} {镜像ID}
mashun1's avatar
mashun1 committed
24

mashun1's avatar
v1  
mashun1 committed
25

xuxzh1's avatar
init  
xuxzh1 committed
26
1、下载源码
mashun1's avatar
v1  
mashun1 committed
27

xuxzh1's avatar
init  
xuxzh1 committed
28
29
    git clone -b v0.3.5 http://developer.sourcefind.cn/codes/OpenDAS/ollama.git --depth=1
    cd ollama
mashun1's avatar
v1  
mashun1 committed
30

xuxzh1's avatar
init  
xuxzh1 committed
31
2、安装依赖包
mashun1's avatar
v1  
mashun1 committed
32

xuxzh1's avatar
init  
xuxzh1 committed
33
34
    cd llm/llama.cpp
    pip install -r requirements.txt
mashun1's avatar
v1  
mashun1 committed
35

xuxzh1's avatar
init  
xuxzh1 committed
36
#### 编译
mashun1's avatar
v1  
mashun1 committed
37

xuxzh1's avatar
init  
xuxzh1 committed
38
39
40
41
##### 环境设置
    export AMDGPU_TARGETS=当前设备型号(如:gfx906,gfx928等)
    export HSA_OVERRIDE_GFX_VERSION=设备型号(如: gfx906对应9.0.6;gfx928对应9.2.8)
    export HIP_VISIBLE_DEVICES=所有设备号(0,1,2,3,4,5,6,...)/选择设备号
mashun1's avatar
v1  
mashun1 committed
42

xuxzh1's avatar
init  
xuxzh1 committed
43
安装go
mashun1's avatar
v1  
mashun1 committed
44

xuxzh1's avatar
init  
xuxzh1 committed
45
https://golang.google.cn/dl/
mashun1's avatar
v1  
mashun1 committed
46

xuxzh1's avatar
init  
xuxzh1 committed
47
48
49
50
51
52
53
54
    # 请替换[]中下载的go文件
    cd ../..
    tar -C /usr/local -xzf [go-xxxx.tar.gz](ollama目录下)
    export PATH=$PATH:/usr/local/go/bin
    
    # 修改go下载源,提升速度(按需设置)
    go env -w GO111MODULE=on
    go env -w GOPROXY=https://goproxy.cn,direct
mashun1's avatar
v1  
mashun1 committed
55

xuxzh1's avatar
init  
xuxzh1 committed
56
##### 运行编译
mashun1's avatar
v1  
mashun1 committed
57

xuxzh1's avatar
init  
xuxzh1 committed
58
59
    cd llm/generate && bash gen_linux.sh
    cd ../.. && go build
mashun1's avatar
v1  
mashun1 committed
60

xuxzh1's avatar
init  
xuxzh1 committed
61
## 验证
mashun1's avatar
v1  
mashun1 committed
62

xuxzh1's avatar
init  
xuxzh1 committed
63
64
    ./ollama serve  (选择可用设备,可通过上条命令输出结果查看)
    ./ollama run llama3.1
mashun1's avatar
v1  
mashun1 committed
65

xuxzh1's avatar
init  
xuxzh1 committed
66
更多使用方式请参考[原项目](https://github.com/ollama/ollama)
mashun1's avatar
v1  
mashun1 committed
67

xuxzh1's avatar
init  
xuxzh1 committed
68
注意:每次运行前请检查环境变量`HSA_OVERRIDE_GFX_VERSION`是否正确设置。
mashun1's avatar
v1  
mashun1 committed
69

xuxzh1's avatar
init  
xuxzh1 committed
70
## 参考资料
mashun1's avatar
v1  
mashun1 committed
71

xuxzh1's avatar
init  
xuxzh1 committed
72
73
* https://github.com/ollama/ollama
* https://github.com/ggerganov/llama.cpp