modelscope download unsloth/DeepSeek-R1-GGUF --include "DeepSeek-R1-Q4_K_M/*" --cache_dir /home/user/new/models
微信扫码
添加专属顾问
我要投稿
低成本本地部署DeepSeek R1 671B大模型的详细实战指南。 核心内容: 1. 选择合适服务器配置实现低成本部署 2. 使用Ktransformers框架进行高效部署 3. 详细安装步骤及环境配置要求
NVIDIA驱动版本570.86.1x ,
CUDA版本12.8
然后Ktransfomers要使用0.2.2版本,目前最新版本0.3还存在很多的bug
git clone https://github.com/kvcache-ai/ktransformers.gitcd ktransformers git submodule init git submodule update git checkout 7a19f3b git rev-parse --short HEAD #应显示 7a19f3b
注意的是,git submodule update 主要是为了更新third_party中的项目
如果网络不好,可以直接github中下载这些项目并放到到third_party文件夹中
[submodule "third_party/llama.cpp"] path = third_party/llama.cpp url = https://github.com/ggerganov/llama.cpp.git[submodule "third_party/pybind11"] path = third_party/pybind11 url = https://github.com/pybind/pybind11.git
下载模型
modelscope download unsloth/DeepSeek-R1-GGUF --include "DeepSeek-R1-Q4_K_M/*" --cache_dir /home/user/new/models
curl -LsSf https://astral.sh/uv/install.sh | sh
uv venv ./venv --python 3.11 --python-preference=only-managedsource venv/bin/activate
$ uv pip install flashinfer-python
$ export TORCH_CUDA_ARCH_LIST="8.6"uv pip install https://github.com/ubergarm/ktransformers/releases/download/7a19f3b/ktransformers-0.2.2rc1+cu120torch26fancy.amd.ubergarm.7a19f3b.flashinfer-cp311-cp311-linux_x86_64.whl
uv pip install https://github.com/mjun0812/flash-attention-prebuild-wheels/releases/download/v0.0.5/flash_attn-2.6.3+cu124torch2.6-cp311-cp311-linux_x86_64.whl
支持多GPU配置及通过 `--optimize_config_path` 进行更细粒度的显存卸载设置
PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True python3 ktransformers/server/main.py
--gguf_path /mnt/ai/models/unsloth/DeepSeek-R1-GGUF/DeepSeek-R1-UD-Q2_K_XL/
--model_path deepseek-ai/DeepSeek-R1
--model_name unsloth/DeepSeek-R1-UD-Q2_K_XL
--cpu_infer 16
--max_new_tokens 8192
--cache_lens 32768
--total_context 32768
--cache_q4 true
--temperature 0.6
--top_p 0.95
--optimize_config_path ktransformers/optimize/optimize_rules/DeepSeek-R1-Chat.yaml
--force_think
--use_cuda_graph
--host 127.0.0.1
--port 8080
# 安装额外编译依赖项,包括CUDA工具链等,例如:# sudo apt-get install build-essential cmake ...source venv/bin/activateuv pip install -r requirements-local_chat.txtuv pip install setuptools wheel packaging# 建议跳过可选网站应用,使用`open-webui`或`litellm`等替代方案cd ktransformers/website/npm install @vue/clinpm run buildcd ../..# 如果拥有充足的CPU核心和内存资源,可显著提升构建速度# $ export MAX_JOBS=8# $ export CMAKE_BUILD_PARALLEL_LEVEL=8# 安装flash_attnuv pip install flash_attn --no-build-isolation# 可选实验性使用flashinfer替代triton# 除非您是已经成功上手的进阶用户,否则暂不建议使用# 使用以下命令安装:# $ uv pip install flashinfer-python# 仅适用于以下情况:# 配备Intel双路CPU且内存>1TB可容纳两份完整模型内存副本(每路CPU一份副本)# AMD EPYC NPS0双路平台可能无需此配置?# $ export USE_NUMA=1# 安装ktransformersKTRANSFORMERS_FORCE_BUILD=TRUE uv pip install . --no-build-isolation
KTRANSFORMERS_FORCE_BUILD=TRUE uv build
uv pip install ./dist/ktransformers-0.2.2rc1+cu120torch26fancy-cp311-cp311-linux_x86_64.whl
ktransformers --model_path /home/user/new/ktran0.2.2/ktransformers/models/deepseek-ai/DeepSeek-R1 --gguf_path /home/user/new/models/unsloth/DeepSeek-R1-GGUF/DeepSeek-R1-Q4_K_M --port 8080
/tmp/cc8uoJt1.s:23667: Error: no such instruction: `vpdpbusd %ymm3,%ymm15,%ymm1'的报错,File "<string>", line 327, in build_extension File "/usr/local/python3/lib/python3.11/subprocess.py", line 571, in run raise CalledProcessError(retcode, process.args, subprocess.CalledProcessError: Command '['cmake', '--build', '.', '--verbose', '--parallel=128']' returned non-zero exit status 1. [end of output]
-DLLAMA_NATIVE=OFF -DLLAMA_AVX=ON -DLLAMA_AVX2=ON -DLLAMA_AVX512=OFF -DLLAMA_AVXVNNI=OFF
写在最后
53AI,企业落地大模型首选服务商
产品:场景落地咨询+大模型应用平台+行业解决方案
承诺:免费场景POC验证,效果验证后签署服务协议。零风险落地应用大模型,已交付160+中大型企业
2025-04-12
什么是蒸馏技术
2025-04-12
30分钟开发完成!Trae+Claude 3.7 打造小程序全流程揭秘!
2025-04-11
6个MCP服务平台推荐,阿里百炼提供一键部署
2025-04-10
Grok3 API 已经全网上线了!附上免费使用Grok3 API的教程
2025-04-09
「扣子罗盘」全新上线,适合百万 Agent 创业者的搞钱神器
2025-04-09
从 0 开始,手把手教你开发第一个MCP服务!
2025-04-09
端到端的训练,怎么复现 Deep ReSearch(上) :先从 Deep Search 做起
2025-04-08
如何一键部署你的专属 MCP 服务
2025-02-04
2025-02-04
2024-09-18
2024-07-11
2024-07-09
2024-07-11
2024-07-26
2025-02-05
2025-01-27
2025-02-01
2025-04-01
2025-03-31
2025-03-20
2025-03-16
2025-03-16
2025-03-13
2025-03-13
2025-03-11