[GH-ISSUE #1344] [Bug] 使用4个GPU部署模型DeepSeek-R1的Q4量化版本时出错 #904

Open
opened 2026-10-29 14:45:57 +00:00 by bsakaguchi · 0 comments
Owner

Originally created by @MacColdNET on GitHub (May 29, 2025).
Original GitHub issue: https://github.com/kvcache-ai/ktransformers/issues/1344

Originally assigned to: @qiyuxinlin on GitHub.

检查清单

  • 1. 我已经搜索过相关问题,但未能获得预期的帮助
  • 2. 该问题在最新版本中尚未修复
  • 3. 请注意,如果您提交的BUG相关 issue 缺少对应环境信息和最小可复现示例,我们将难以复现和定位问题,降低获得反馈的可能性
  • 4. 如果您提出的不是bug而是问题,请在讨论区发起讨论 https://github.com/kvcache-ai/ktransformers/discussions。否则该 issue 将被关闭
  • 5. 为方便社区交流,我将使用中文/英文或附上中文/英文翻译(如使用其他语言)。未附带翻译的非中文/英语内容可能会被关闭

问题描述

在 docker 容器环境下,使用4个 GPU 启动 DeepSeek-R1 的 Q4_K_M 版本模型时出现错误如下:

Image

复现步骤

我使用官方提供的镜像 approachingai/ktransformers:v0.3.1-AVX512 启动容器:
docker run --gpus all -d --name ktransformers-gpu-all-v5 -v /data:/app/models --network=host -e HF_ENDPOINT=https://hf-mirror.com -e NCCL_SOCKET_IFNAME=ens110f0 -e GLOO_SOCKET_IFNAME=ens110f0 --shm-size=64g approachingai/ktransformers:v0.3.1-AVX512
进入容器内,先把transformers版本降级为4.43.2(如果不降级,会出现“AttributeError: 'DeepseekV3ForCausalLM' object has no attribute '_get_logits_warper'”错误),然后启动 DeepSeek-R1 的 Q4_K_M 版本:
ktransformers --model_path /app/models/Model-Zoo/model_config/DeepSeek-R1/config/ --gguf_path /app/models/Model-Zoo/DeepSeek-R1-GGUF/DeepSeek-R1-Q4_K_M/ --model_name deepseek-r1 --port 10002 --optimize_config_path /workspace/ktransformers/ktransformers/optimize/optimize_rules/DeepSeek-V3-Chat-multi-gpu-4.yaml --max_new_tokens 4090 --cache_lens 40900
其中DeepSeek-V3-Chat-multi-gpu-4.yaml 就是官方提供的默认文件, DeepSeek-R1的Q4_K_M gguf文件我是在modelscope上下载的。模型启动成功,但是发送请求时报错:

Image

Image
请求语句如下:

 curl http://localhost:10002/v1/chat/completions -H "Content-Type: application/json" -d '{
"model": "deepseek-r1",
"messages": [
{"role": "user", "content": "Who are you?"}
]
}'

完整的报错日志如下:

报错日志.txt

GPU显存占用如下(GPU0上有别的进程,所以占用得多一些):

Image

请问是因为模型量化版本不适配吗?如果我哪一步操作不妥,还请指明。

环境信息

操作系统:

PRETTY_NAME="Ubuntu 22.04.3 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.3 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy

CPU信息:

Architecture:             x86_64
  CPU op-mode(s):         32-bit, 64-bit
  Address sizes:          46 bits physical, 57 bits virtual
  Byte Order:             Little Endian
CPU(s):                   104
  On-line CPU(s) list:    0-103
Vendor ID:                GenuineIntel
  Model name:             Intel(R) Xeon(R) Gold 5320 CPU @ 2.20GHz
    CPU family:           6
    Model:                106
    Thread(s) per core:   2
    Core(s) per socket:   26
    Socket(s):            2
    Stepping:             6
    CPU max MHz:          3400.0000
    CPU min MHz:          800.0000
    BogoMIPS:             4400.00
    Flags:                fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rd
                          tscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 ds_cpl vmx smx est t
                          m2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowpre
                          fetch cpuid_fault epb cat_l3 intel_ppin ssbd mba ibrs ibpb stibp ibrs_enhanced tpr_shadow flexpriority ept vpid ept_ad fsgsbase tsc_adjust bm
                          i1 avx2 smep bmi2 erms invpcid cqm rdt_a avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb intel_pt avx512cd sha_ni avx512bw avx512
                          vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local split_lock_detect wbnoinvd dtherm ida arat pln pts vnmi a
                          vx512vbmi umip pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg tme avx512_vpopcntdq la57 rdpid fsrm md_clear pconfig fl
                          ush_l1d arch_capabilities
Virtualization features:
  Virtualization:         VT-x
Caches (sum of all):
  L1d:                    2.4 MiB (52 instances)
  L1i:                    1.6 MiB (52 instances)
  L2:                     65 MiB (52 instances)
  L3:                     78 MiB (2 instances)
NUMA:
  NUMA node(s):           2
  NUMA node0 CPU(s):      0-25,52-77
  NUMA node1 CPU(s):      26-51,78-103
Vulnerabilities:
  Gather data sampling:   Mitigation; Microcode
  Itlb multihit:          Not affected
  L1tf:                   Not affected
  Mds:                    Not affected
  Meltdown:               Not affected
  Mmio stale data:        Mitigation; Clear CPU buffers; SMT vulnerable
  Reg file data sampling: Not affected
  Retbleed:               Not affected
  Spec rstack overflow:   Not affected
  Spec store bypass:      Mitigation; Speculative Store Bypass disabled via prctl
  Spectre v1:             Mitigation; usercopy/swapgs barriers and __user pointer sanitization
  Spectre v2:             Mitigation; Enhanced / Automatic IBRS; IBPB conditional; RSB filling; PBRSB-eIBRS SW sequence; BHI SW loop, KVM SW loop
  Srbds:                  Not affected
  Tsx async abort:        Not affected

GPU:

Image

Originally created by @MacColdNET on GitHub (May 29, 2025). Original GitHub issue: https://github.com/kvcache-ai/ktransformers/issues/1344 Originally assigned to: @qiyuxinlin on GitHub. ### 检查清单 - [x] 1. 我已经搜索过相关问题,但未能获得预期的帮助 - [x] 2. 该问题在最新版本中尚未修复 - [x] 3. 请注意,如果您提交的BUG相关 issue 缺少对应环境信息和最小可复现示例,我们将难以复现和定位问题,降低获得反馈的可能性 - [x] 4. 如果您提出的不是bug而是问题,请在讨论区发起讨论 https://github.com/kvcache-ai/ktransformers/discussions。否则该 issue 将被关闭 - [x] 5. 为方便社区交流,我将使用中文/英文或附上中文/英文翻译(如使用其他语言)。未附带翻译的非中文/英语内容可能会被关闭 ### 问题描述 在 docker 容器环境下,使用4个 GPU 启动 DeepSeek-R1 的 Q4_K_M 版本模型时出现错误如下: ![Image](https://github.com/user-attachments/assets/d031a4b7-b054-48ca-88fb-c88816767bac) ### 复现步骤 我使用官方提供的镜像 approachingai/ktransformers:v0.3.1-AVX512 启动容器: `docker run --gpus all -d --name ktransformers-gpu-all-v5 -v /data:/app/models --network=host -e HF_ENDPOINT=https://hf-mirror.com -e NCCL_SOCKET_IFNAME=ens110f0 -e GLOO_SOCKET_IFNAME=ens110f0 --shm-size=64g approachingai/ktransformers:v0.3.1-AVX512` 进入容器内,先把transformers版本降级为4.43.2(如果不降级,会出现“AttributeError: 'DeepseekV3ForCausalLM' object has no attribute '_get_logits_warper'”错误),然后启动 DeepSeek-R1 的 Q4_K_M 版本: `ktransformers --model_path /app/models/Model-Zoo/model_config/DeepSeek-R1/config/ --gguf_path /app/models/Model-Zoo/DeepSeek-R1-GGUF/DeepSeek-R1-Q4_K_M/ --model_name deepseek-r1 --port 10002 --optimize_config_path /workspace/ktransformers/ktransformers/optimize/optimize_rules/DeepSeek-V3-Chat-multi-gpu-4.yaml --max_new_tokens 4090 --cache_lens 40900` 其中DeepSeek-V3-Chat-multi-gpu-4.yaml 就是官方提供的默认文件, DeepSeek-R1的Q4_K_M gguf文件我是在modelscope上下载的。模型启动成功,但是发送请求时报错: ![Image](https://github.com/user-attachments/assets/7e534de0-9359-4d24-bf66-57dcfbbf2108) ![Image](https://github.com/user-attachments/assets/4f0b5aee-71c5-4ea9-a8dd-f862ee730c31) 请求语句如下: ``` curl http://localhost:10002/v1/chat/completions -H "Content-Type: application/json" -d '{ "model": "deepseek-r1", "messages": [ {"role": "user", "content": "Who are you?"} ] }' ``` 完整的报错日志如下: [报错日志.txt](https://github.com/user-attachments/files/20500397/default.txt) GPU显存占用如下(GPU0上有别的进程,所以占用得多一些): ![Image](https://github.com/user-attachments/assets/154ec3e9-c94d-4789-91e6-55cddc3b1e6c) 请问是因为模型量化版本不适配吗?如果我哪一步操作不妥,还请指明。 ### 环境信息 操作系统: ``` PRETTY_NAME="Ubuntu 22.04.3 LTS" NAME="Ubuntu" VERSION_ID="22.04" VERSION="22.04.3 LTS (Jammy Jellyfish)" VERSION_CODENAME=jammy ID=ubuntu ID_LIKE=debian HOME_URL="https://www.ubuntu.com/" SUPPORT_URL="https://help.ubuntu.com/" BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" UBUNTU_CODENAME=jammy ``` CPU信息: ``` Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Address sizes: 46 bits physical, 57 bits virtual Byte Order: Little Endian CPU(s): 104 On-line CPU(s) list: 0-103 Vendor ID: GenuineIntel Model name: Intel(R) Xeon(R) Gold 5320 CPU @ 2.20GHz CPU family: 6 Model: 106 Thread(s) per core: 2 Core(s) per socket: 26 Socket(s): 2 Stepping: 6 CPU max MHz: 3400.0000 CPU min MHz: 800.0000 BogoMIPS: 4400.00 Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rd tscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 ds_cpl vmx smx est t m2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowpre fetch cpuid_fault epb cat_l3 intel_ppin ssbd mba ibrs ibpb stibp ibrs_enhanced tpr_shadow flexpriority ept vpid ept_ad fsgsbase tsc_adjust bm i1 avx2 smep bmi2 erms invpcid cqm rdt_a avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb intel_pt avx512cd sha_ni avx512bw avx512 vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local split_lock_detect wbnoinvd dtherm ida arat pln pts vnmi a vx512vbmi umip pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg tme avx512_vpopcntdq la57 rdpid fsrm md_clear pconfig fl ush_l1d arch_capabilities Virtualization features: Virtualization: VT-x Caches (sum of all): L1d: 2.4 MiB (52 instances) L1i: 1.6 MiB (52 instances) L2: 65 MiB (52 instances) L3: 78 MiB (2 instances) NUMA: NUMA node(s): 2 NUMA node0 CPU(s): 0-25,52-77 NUMA node1 CPU(s): 26-51,78-103 Vulnerabilities: Gather data sampling: Mitigation; Microcode Itlb multihit: Not affected L1tf: Not affected Mds: Not affected Meltdown: Not affected Mmio stale data: Mitigation; Clear CPU buffers; SMT vulnerable Reg file data sampling: Not affected Retbleed: Not affected Spec rstack overflow: Not affected Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization Spectre v2: Mitigation; Enhanced / Automatic IBRS; IBPB conditional; RSB filling; PBRSB-eIBRS SW sequence; BHI SW loop, KVM SW loop Srbds: Not affected Tsx async abort: Not affected ``` GPU: ![Image](https://github.com/user-attachments/assets/6f86848c-9132-4d01-94f0-0d194e2c1d6e)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
kvcache-ai/ktransformers#904
No description provided.