Ollama部署本地大模型DeepSeek-R1-Distill-Llama-70B

文章目录

  • 一、下模
  • 二、转模
    • 1. 下载转换工具
    • 2. 安装环境依赖
    • 3. llama.cpp
      • 1. 转换脚本依赖
      • 2. llama.cpp安装依赖包
      • 3. llama.cpp编译安装
      • 4. 格式转换
  • 三、Ollama部署
    • 1. 安装启动Ollama
    • 2. 添加模型
    • 3. 测试运行

一、下模

#模型下载
from modelscope import snapshot_download
model_dir = snapshot_download('deepseek-ai/DeepSeek-R1-Distill-Llama-70B')

示例:pandas 是基于NumPy 的一种工具,该工具是为了解决数据分析任务而创建的。

二、转模

如果模型是hf,需要转成gguf格式,如果在下模的时候想要的那个模型有gguf的,那就直接下,不用转。如果没有,需要转一下,因为ollama部署必须是gguf格式。

1. 下载转换工具

(base) defaultuser@qin-h100-jumper-server:/mnt/ollama/deepseek/llamacpp$ sudo git clone https://github.com/ggerganov/llama.cpp
Cloning into 'llama.cpp'...
remote: Enumerating objects: 44551, done.
remote: Counting objects: 100% (140/140), done.
remote: Compressing objects: 100% (98/98), done.
Receiving objects:  63% (28068/44551), 71.18 MiB | 2.54 MiB/s 

2. 安装环境依赖

(base) defaultuser@qin-h100-jumper-server:/mnt/ollama/deepseek/llamacpp/llama.cpp$ pip install -e .
WARNING: Ignoring invalid distribution ~riton (/home/defaultuser/anaconda3/lib/python3.12/site-packages)
WARNING: Ignoring invalid distribution ~orch (/home/defaultuser/anaconda3/lib/python3.12/site-packages)
Obtaining file:///mnt/ollama/deepseek/llamacpp/llama.cppInstalling build dependencies ... doneChecking if build backend supports build_editable ... doneGetting requirements to build editable ... done
Downloading protobuf-4.25.6-cp37-abi3-manylinux2014_x86_64.whl (294 kB)━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 294.6/294.6 kB 107.8 kB/s eta 0:00:00
Downloading torch-2.6.0-cp312-cp312-manylinux1_x86_64.whl (766.6 MB)━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 0.9/766.6 MB 60.9 kB/s eta 3:29:38

3. llama.cpp

1. 转换脚本依赖

安装convert_hf_to_gguf.py脚本所需的依赖包。

 (base) defaultuser@qin-h100-jumper-server:/mnt/ollama/deepseek/llamacpp/llama.cpp$ pip install -r requirements.txt
Looking in indexes: https://pypi.org/simple, https://download.pytorch.org/whl/cpu, https://download.pytorch.org/whl/cpu, https://download.pytorch.org/whl/cpu, https://download.pytorch.org/whl/cpu
Requirement already satisfied: numpy~=1.26.4 in /home/defaultuser/anaconda3/lib/python3.12/site-packages (from -r ./requirements/requirements-convert_legacy_llama.txt (line 1)) (1.26.4)
/home/defaultuser/anaconda3/lib/python3.12/site-packages (from -r ./requirements/requirements-convert_legacy_llama.txt (line 4)) (0.10.0)
Collecting protobuf<5.0.0,>=4.21.0 (from -r Downloading https://download.pytorch.org/whl/cpu/torch-2.2.2%2Bcpu-cp312-cp312-linux_x86_64.whl (186.7 MB)━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 186.7/186.7 MB 6.1 MB/s eta 0:00:00
Requirement already satisfied: filelock in /home/defaultuser/anaconda3/lib/python3.12/site-packages (from transformers<5.0.0,>=4.45.1->-r ./requirements/requirements-convert_legacy_llama.txt (line 3)) (3.17.0)

2. llama.cpp安装依赖包

接下来需要安装convert_hf_to_gguf.py脚本所需的依赖包。

(base) defaultuser@qin-h100-jumper-server:/mnt/ollama/deepseek/llamacpp/llama.cpp$ pip install -r requirements/requirements-convert_hf_to_gguf.txt
WARNING: Ignoring invalid distribution ~riton (/home/defaultuser/anaconda3/lib/python3.12/site-packages)
Looking in indexes: https://pypi.org/simple, https://download.pytorch.org/whl/cpu
Requirement already satisfied: numpy~=1.26.4 in /home/defaultuser/anaconda3/lib/python3.12/site-packages (from -r requirements/./requirements-convert_legacy_llama.txt (line 1)) (1.26.4)
Requirement already satisfied: sentencepiece~=0.2.0 in /home/defaultuser/anaconda3/lib/python3.12/site-packages (from -r requirements/./requirements-convert_legacy_llama.txt (line 2)) (0.2.0)
Requirement already satisfied: transformers<5.0.0,>=4.45.1 in /home/defaultuser/anaconda3/lib/python3.12/site-packages (from -r requirements/./requirements-convert_legacy_llama.txt (line 3)) (4.49.0)
Requirement already satisfied: gguf>=0.1.0 in /home/defaultuser/anaconda3/lib/python3.12/site-packages (from -r requirements/./requirements-convert_legacy_llama.txt (line 4)) (0.10.0)

3. llama.cpp编译安装

直接make

(base) defaultuser@qin-h100-jumper-server:/mnt/ollama/deepseek/llamacpp/llama.cpp$ make
Makefile:2: *** The Makefile build is deprecated. Use the CMake build instead. For more details, see https://github.com/ggml-org/llama.cpp/blob/master/docs/build.md.  Stop.
(base) defaultuser@qin-h100-jumper-server:/mnt/ollama/deepseek/llamacpp/llama.cpp$ 

报错后需要先装cmake

(base) defaultuser@qin-h100-jumper-server:/mnt/ollama/deepseek/llamacpp/llama.cpp$ sudo apt install cmake
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:cmake-data dh-elpa-helper emacsen-common libjsoncpp25 librhash0
Suggested packages:cmake-doc ninja-build cmake-format

使用cmake配置构建

defaultuser@qin-h100-jumper-server:/mnt/ollama/deepseek/llamacpp/llama.cpp/build$ sudo cmake ..
-- The C compiler identification is GNU 11.4.0
-- The CXX compiler identification is GNU 11.4.0
-- Detecting C compiler ABI info
-- CMAKE_SYSTEM_PROCESSOR: x86_64
-- Including CPU backend
-- Found OpenMP_C: -fopenmp (found version "4.5") 
-- Found OpenMP_CXX: -fopenmp (found version "4.5") 
-- Found OpenMP: TRUE (found version "4.5")  
-- x86 detected
-- Adding CPU backend variant ggml-cpu: -march=native 
-- Configuring done
-- Generating done
-- Build files have been written to: /mnt/ollama/deepseek/llamacpp/llama.cpp/build
(base) defaultuser@qin-h100-jumper-server:/mnt/ollama/deepseek/llamacpp/llama.cpp/build$ 

构建项目

(base) defaultuser@qin-h100-jumper-server:/mnt/ollama/deepseek/llamacpp/llama.cpp/build$ sudo cmake --build . --config Release
[  0%] Building C object ggml/src/CMakeFiles/ggml-base.dir/ggml.c.o
[  1%] Building C object ggml/src/CMakeFiles/ggml-base.dir/ggml-alloc.c.o
[  1%] Building CXX object ggml/src/CMakeFiles/ggml-base.dir/ggml-backend.cpp.o
[  2%] Building CXX object ggml/src/CMakeFiles/ggml-base.dir/ggml-opt.cpp.o
[  2%] Building CXX object ggml/src/CMakeFiles/ggml-base.dir/ggml-threading.cpp.o
[  3%] Building C object ggml/src/CMakeFiles/ggml-base.dir/ggml-quants.c.o
[  3%] Building CXX object ggml/src/CMakeFiles/ggml-base.dir/gguf.cpp.o
[  4%] Linking CXX shared library ../../bin/libggml-base.so

4. 格式转换

python convert_hf_to_gguf.py  /mnt/ollama/deepseek/deepseek-ai/DeepSeek-R1-Distill-Llama-70B  --outtype f16 --outfile /mnt/ollama/deepseek/deepseek-ai/DeepSeek-R1-Distill-Llama-70B.gguf 

开始转换,等待转换完成

INFO:hf-to-gguf:gguf: embedding length = 8192
INFO:hf-to-gguf:gguf: feed forward length = 28672
INFO:hf-to-gguf:gguf: head count = 64
INFO:hf-to-gguf:gguf: key-value head count = 8
INFO:hf-to-gguf:gguf: rope theta = 500000.0
INFO:hf-to-gguf:gguf: rms norm epsilon = 1e-05
INFO:hf-to-gguf:gguf: file type = 1
INFO:hf-to-gguf:Set model tokenizer
INFO:gguf.vocab:Adding 280147 merge(s).
INFO:gguf.vocab:Setting special token type bos to 128000
INFO:gguf.vocab:Setting special token type eos to 128001
INFO none %}{%- set ns.is_tool = false -%}{%- for tool in message['tool_calls']%}{%- if not ns.is_first %}{{'<|Assistant|><|tool▁calls▁begin|><|tool▁call▁begin|>' + tool['type'] +>'}}{%- endif %}{%- endif %}{%- endfor -%}{% if ns.is_tool %}{{'<|tool▁outputs▁end|>'}}{% endif %}{% if add_generation_prompt and not ns.is_tool %}{{'<|Assistant|><think>\n'}}{% endif %}
INFO:hf-to-gguf:Set model quantization version
INFO:gguf.gguf_writer:Writing the following files:
INFO:gguf.gguf_writer:/mnt/ollama/deepseek/deepseek-ai/DeepSeek-R1-Distill-Llama-70B.gguf: n_tensors = 724, total_size = 141.1G
NFO:hf-to-gguf:Set model quantization version
INFO:gguf.gguf_writer:Writing the following files:
INFO:gguf.gguf_writer:/mnt/ollama/deepseek/deepseek-ai/DeepSeek-R1-Distill-Llama-70B.gguf: n_tensors = 724, total_size = 141.1G
Writing:  12%|██████████▏                                                                       | 17.6G/141G [01:33<12:08, 170Mbyte/s

三、Ollama部署

1. 安装启动Ollama

curl https://ollama.com/install.sh | sh
ollama serve

2. 添加模型

在模型同级目下创建一个文件Modefile,把模型名字写入

(base) root@test-6U8X-EGS2:/mnt/ollama/deepseek# ls
anaconda3.tgz  DeepSeek-R1                    DeepSeek-R1-Distill-Llama-70B.gguf  home
code           DeepSeek-R1-Distill-Llama-70B  DeepSeek-R1-Distill-Qwen-1___5B     vllm
(base) root@test-6U8X-EGS2:/mnt/ollama/deepseek# touch Modelfile
(base) root@test-6U8X-EGS2:/mnt/ollama/deepseek# nano Modelfile  
(base) root@test-6U8X-EGS2:/mnt/ollama/deepseek# cat Modelfile 
FROM ./DeepSeek-R1-Distill-Llama-70B.gguf
(base) root@test-6U8X-EGS2:/mnt/ollama/deepseek# 

把模型导入ollama,然后list查看是有已有,可以看到latest就是最新导入的。

(base) root@test-6U8X-EGS2:/home/test/ollama-main/bin# ./ollama create DeepSeek-R1-Distill-Llama-70B -f /mnt/ollama/deepseek/M
odelfile
gathering model components 
copying file sha256:bf5df985d4bcfffe15c57780fe7b362b320c6d3d86b07ca16976d511374ed970 100% 
parsing GGUF 
using existing layer sha256:bf5df985d4bcfffe15c57780fe7b362b320c6d3d86b07ca16976d511374ed970 
writing manifest 
success 
(base) root@test-6U8X-EGS2:/home/test/ollama-main/bin# ./ollama list
NAME                                    ID              SIZE      MODIFIED       
DeepSeek-R1-Distill-Llama-70B:latest    22bd5a29702f    141 GB    45 seconds ago    
deepseek-r1-q2:671b                     bf71f995ebf9    226 GB    38 hours ago      
deepseek-r1:671b                        739e1b229ad7    404 GB    4 days ago        
deepseek-r1:70b                         0c1615a8ca32    42 GB     5 days ago        
(base) root@test-6U8X-EGS2:/home/test/ollama-main/bin# 

3. 测试运行

 (base) root@test-6U8X-EGS2:/home/test/ollama-main/bin# ./ollama run DeepSeek-R1-Distill-Llama:70b>>> 介绍下上海
<think>
嗯,用户让我“介绍下上海”。首先,我需要明确他们对上海的兴趣点是什么,是历史、经济、文化还是旅游景点?可能是一个概括性的介绍,所以我得全
面一点。上海作为中国的第一大城市,有很多值得说的。国际化大都市、经济中心,这些基本信息是必须提到的。然后,地理位置在哪儿,人口多不多,这些基本
数据能帮助用户建立一个整体印象。接下来,可以介绍一下上海的历史,比如开埠的时间,以及改革开放后的发展,这样用户能了解它的成长轨迹和现在的地位。经济方面,金融中心、港口和产业布局是关键点。提到黄浦江两岸的变化,可以形象地展示城市的繁荣。文化多样性也是上海的一大特点,东西方文化交融,这一点挺吸引人的。适合生活和旅游,可能用户也在考虑是否要去那里玩,所以可以稍微提一下著名
景点,比如外滩、城隍庙等,但不要展开太多,保持简洁。最后,加上一些个人见解,说明上海的魅力所在,这样介绍会更生动。总之,要全面但不过于冗长,让用户对上海有一个清晰而丰富的了解。
</think>上海是中国的一个国际化大都市,也是中国经济、金融、贸易和航运中心。以下是一些关于上海的基本介绍:1. **地理位置**- 上海位于中国东部,长江入海口以北,黄浦江两岸,是中国人口最多的城市之一。2. **历史与发展**- 上海自1843年开埠以来,就成为了中国对外开放的重要窗口。- 20世纪90年代改革开放后,上海迅速发展成为全球重要的经济中心。3. **经济与金融**- 上海是中国最大的经济中心,也是全球主要金融中心之一。上海证券交易所是中国最重要的股票交易市场之一。- 上海港口是世界上最繁忙的港口之一,货物吞吐量和集装箱吞吐量位居世界前列。4. **文化与多样性**- 上海是一个国际化城市,融合了中西方的文化。老城隍庙、城隍街等传统场所与外滩、南京路步行街等现代商业区相映成趣。- 上海人以开放包容著称,适应各种文化和生活方式。5. **旅游景点**- 外滩:上海的标志性景观之一,夜晚灯光璀璨。- 城隍庙:传统美食和小吃集中地,也是上海文化的象征。- 上海迪士尼乐园:适合家庭游玩。- 珠宝阁:在东方明珠塔上,可以俯瞰整个上海的全景。6. **生活**- 上海是一个充满活力的城市,拥有丰富的娱乐、购物和文化活动。同时,这里也吸引了大量外来务工人员和外籍人士。总之,上海是一座既有传统韵味又充满现代气息的国际化都市,是一个值得探索的地方。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/25084.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

domain 网络安全 网络安全域

&#x1f345; 点击文末小卡片 &#xff0c;免费获取网络安全全套资料&#xff0c;资料在手&#xff0c;涨薪更快 文章目录 1、域的概述 1.1、工作组与域1.2、域的特点1.3、域的组成1.4、域的部署概述1.5、活动目录1.6、组策略GPO 2、域的部署实验 2.1、建立局域网&#xf…

VSCode轻松调试运行.Net 8.0 Web API项目

1.背景 我一直都是用VS来开发.NetCore项目的&#xff0c;用的比较顺手&#xff0c;也习惯了。看其他技术文章有介绍VS Code更轻量&#xff0c;更方便。所以我专门花时间来使用VS Code&#xff0c;看看它是如何调试代码、如何运行.Net 8.0 WebAPI项目。这篇文章是一个记录的过程…

【fnOS飞牛云NAS本地部署DeepSeek-R1结合内网穿透远程访问告别服务器繁忙】

&#x1f49d;&#x1f49d;&#x1f49d;欢迎来到我的博客&#xff0c;很高兴能够在这里和您见面&#xff01;希望您在这里可以感受到一份轻松愉快的氛围&#xff0c;不仅可以获得有趣的内容和知识&#xff0c;也可以畅所欲言、分享您的想法和见解。 推荐:kwan 的首页,持续学…

Python学习第十七天之PyTorch保姆级安装

PyTorch安装与部署 一、准备工作二、pytorch介绍三、CPU版本pytorch安装1. 创建虚拟环境2. 删除虚拟环境1. 通过环境名称删除2. 通过环境路径删除 3. 配置镜像源4. 安装pytorch1. 首先激活环境变量2. 进入pytorch官网&#xff0c;找到安装指令 5. 验证pytorch是否安装成功 四、…

内存管理+模板基础知识

在前面的博客中&#xff0c;我们已经基本学习完了类和对象有关知识&#xff0c;在这篇博客中&#xff0c;我们将要学习C/C内存管理与模板的一些基础知识。 目录 一、C/C内存管理 1.1 C/C内存分布 1.2 C内存管理方式 1.2.1 new/delete操作内置类型 1.2.2 new和delete操作自…

新建菜单项的创建之CmpGetValueListFromCache函数分析

第一部分&#xff1a; PCELL_DATA CmpGetValueListFromCache( IN PHHIVE Hive, IN PCACHED_CHILD_LIST ChildList, OUT BOOLEAN *IndexCached, OUT PHCELL_INDEX ValueListToRelease ) 0: kd> dv KeyControlBlock 0xe1…

《无畏契约》运行时提示“d3dcompiler_43.dll丢失”是什么原因?“找不到d3dcompiler_43.dll文件”如何解决?

--- 使用DLL修复工具&#xff08;懒人专用&#xff09; https://file-xfqdx-cdn.fanqiesoft.cn/package/XFQDXTool_21121_tg.exe 逐步说明&#xff1a; 步骤1&#xff1a;重新安装《无畏契约》 - 操作指南&#xff1a; - 打开“控制面板” → “程序和功能”。 - 在列表…

蓝牙接近开关模块感应开锁手机靠近解锁支持HID低功耗

ANS-BT101M是安朔科技推出的蓝牙接近开关模块&#xff0c;低功耗ble5.1&#xff0c;采用UART通信接口&#xff0c;实现手机自动无感连接&#xff0c;无需APP&#xff0c;人靠近车门自动开锁&#xff0c;支持苹果、安卓、鸿蒙系统&#xff0c;也可以通过手机手动开锁或上锁&…

Ubuntu 22.04 安装Nvidia驱动加速deepseek

一键安装22.04 nvidia 驱动 nvidia 官网下载驱动我的环境是NVIDIA RTX A5000nvidia 文档参考没有安装驱动之前确认自己的型号 lspci | grep -i vga &#xff08;如数字2231&#xff09; 参考docker 支持nvidia &#xff0c;注释了需要的取消注释即可 42行-92行一定要重启服务器…

数据结构——双链表

1. 双向带头循环链表 1. 双链表的功能 1. 初始化 2. 销毁 3. 打印 4. 检查链表是否为空 5. 尾插 6. 尾删 7. 头插 8. 头删 9. 在目标节点之后插入数据 10. 删除目标节点 11. 查找 2. 双链表的定义 结构体需要包含三个成员&#xff0c;一个成员存储数据&#xff0c;一个成员存储…

微服务2025/2/15

微服务是一种软件架构风格&#xff0c;它是以专注于单一职责的很多小型项目为基础&#xff0c;组合出复杂的大型应用。 微服务是一种架构。 微服务是一种架构。 微服务是一种架构。 以前自己做项目最常用的架构是单体架构。单体项目不适合开发大型项目。 学习微服务技术来解…

Locust性能压测工具使用指南

Locust是一款用Python编写的开源性能测试工具&#xff0c;主要用于对网站或其他系统进行负载测试和性能测试&#xff0c;以下是关于它的详细介绍&#xff1a; 特点 高可扩展性&#xff1a;能够轻松模拟大量用户并发访问&#xff0c;通过简单增加节点&#xff0c;可以在短时间…

DaoCloud 亮相 2025 GDC丨开源赋能 AI 更多可能

2025 年 2 月 21 日至 23 日&#xff0c;上海徐汇西岸&#xff0c;2025 全球开发者先锋大会以 “模塑全球&#xff0c;无限可能” 的主题&#xff0c;围绕云计算、机器人、元宇宙等多元领域&#xff0c;探讨前沿技术创新、应用场景拓展和产业生态赋能&#xff0c;各类专业论坛、…

Linux 环境“从零”部署 MongoDB 6.0:mongosh 安装与数据操作全攻略

前提 完成linux平台部署MongoDB【部署教程】且完成mongosh的安装 由于本人使用的是6.0版本的MongoDB&#xff0c;新版本 MongoDB&#xff08;尤其是 6.0 及以上版本&#xff09;已经不再默认捆绑传统的 mongo shell&#xff0c;而改用新的 MongoDB Shell&#xff08;mongosh&am…

SQL注入之二次注入

1、概述 二次注入是指已存储&#xff08;数据库、文件&#xff09;的用户输入被读取后再次进入到 SQL 查询语句中导致的注入。 二次注入是sql注入的一种&#xff0c;但是比普通sql注入利用更加困难&#xff0c;利用门槛更高。普通注入数据直接进入到 SQL 查询中&#xff0c;而…

AORO M6北斗短报文终端:将“太空黑科技”转化为安全保障

在卫星导航领域&#xff0c;北斗系统作为我国自主研发的全球卫星导航系统&#xff0c;正以其独特的短报文通信功能引发全球范围内的广泛关注。这一突破性技术不仅使北斗系统在全球四大导航系统中独树一帜&#xff0c;具备了双向通信能力&#xff0c;更通过遨游通讯推出的AORO M…

xss-lab

xss XSS全称跨站脚本(Cross Site Scripting)&#xff0c;为避免与层叠样式表(Cascading Style Sheets, CSS)的缩写混淆&#xff0c;故缩写为XSS。这是一种将任意 Javascript 代码插入到其他Web用户页面中执行以达到攻击目的的漏洞。攻击者利用浏览器的动态展示数据功能&#x…

服务器为什么会禁止 Ping?服务器禁止 Ping 的好处

在网络管理和服务器运维中&#xff0c;经常会遇到服务器禁止 Ping 的情况。为了确保网络安全和减少不必要的风险&#xff0c;管理员可能会选择禁止 Ping 命令&#xff0c;即禁止服务器响应 ICMP 请求。尽管 Ping 命令是网络诊断中常用的工具&#xff0c;但禁止 Ping 也有其合理…

课程2. 用PyTorch训练神经网络与梯度下降

课程2. 用PyTorch训练神经网络与梯度下降 Pytorchtorch.TensorPytorch 上的神经网络用于余弦函数逼近的全连接神经网络 训练神经网络 梯度下降最小化一个变量的函数最小化多个变量的函数使用梯度下降训练神经网络在 Pytorch 中训练神经网络从 nn.Module 类继承 将计算传输到显卡…

IP-----动态路由OSPF(2)

这只是IP的其中一块内容&#xff0c;IP还有更多内容可以查看IP专栏&#xff0c;前一章内容为动态路由OSPF &#xff0c;可通过以下路径查看IP-----动态路由OSPF-CSDN博客,欢迎指正 注意&#xff01;&#xff01;&#xff01;本部分内容较多所以分成了两部分在上一章 5.动态路…