[GH-ISSUE #1092] [Bug] 编译失败:cmake --build . 在 Ubuntu + CUDA12.6 + PyTorch2.6 环境中返回非零退出码 #767

Open
opened 2026-10-29 14:44:12 +00:00 by bsakaguchi · 6 comments
Owner

Originally created by @xuhaodegithub on GitHub (Apr 9, 2025).
Original GitHub issue: https://github.com/kvcache-ai/ktransformers/issues/1092

Checklist

  • 1. I have searched related issues but cannot get the expected help.
  • 2. The bug has not been fixed in the latest version.
  • 3. Please note that if the bug-related issue you submitted lacks corresponding environment info and a minimal reproducible demo, it will be challenging for us to reproduce and resolve the issue, reducing the likelihood of receiving feedback.
  • 4. If the issue you raised is not a bug but a question, please raise a discussion at https://github.com/kvcache-ai/ktransformers/discussions. Otherwise, it will be closed.
  • 5. To help the community, I will use Chinese/English or attach an Chinese/English translation if using another language. Non-Chinese/English content without translation may be closed.

Describe the bug

我在尝试从源码安装 ktransformers(使用 CUDA 编译)时遇到了构建失败的问题,pip 调用 CMake 编译时报错:
subprocess.CalledProcessError: Command '['cmake', '--build', '.', '--verbose', '--parallel=112']' returned non-zero exit status 1.
error: subprocess-exited-with-error

× Building wheel for ktransformers (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> See above for output.
我已尝试使用 KTRANSFORMERS_FORCE_BUILD=TRUE pip install -v . --no-build-isolation 并开启详细日志查看,但编译失败的位置仍然不明确。

🔁 复现步骤
克隆源码并进入目录

更新子模块:git submodule update --init --recursive

确保 CUDA 环境变量已配置

安装依赖后执行:USE_BALANCE_SERVE=1 USE_NUMA=1 bash ./install.sh

Reproduction

USE_BALANCE_SERVE=1 USE_NUMA=1 bash ./install.sh

Environment

操作系统 | Ubuntu 22.04 / Linux Kernel 5.15.0-136-generic
Python 版本 | 3.11.11
Python 路径 | /mnt/data/py311/bin/python
PyTorch 版本 | 2.6.0+cu124
CUDA Available | ✅ 是
PyTorch 用的 CUDA 版本 | 12.4
系统安装的 CUDA 版本 (nvcc) | 12.6 (V12.6.20)
CUDA_HOME | /usr/local/cuda
PATH 中的 CUDA 路径 | /usr/local/cuda/bin(已设置)
GCC / G++ | 11.4.0
CMake 版本 | 3.22.1

Originally created by @xuhaodegithub on GitHub (Apr 9, 2025). Original GitHub issue: https://github.com/kvcache-ai/ktransformers/issues/1092 ### Checklist - [x] 1. I have searched related issues but cannot get the expected help. - [x] 2. The bug has not been fixed in the latest version. - [x] 3. Please note that if the bug-related issue you submitted lacks corresponding environment info and a minimal reproducible demo, it will be challenging for us to reproduce and resolve the issue, reducing the likelihood of receiving feedback. - [x] 4. If the issue you raised is not a bug but a question, please raise a discussion at https://github.com/kvcache-ai/ktransformers/discussions. Otherwise, it will be closed. - [x] 5. To help the community, I will use Chinese/English or attach an Chinese/English translation if using another language. Non-Chinese/English content without translation may be closed. ### Describe the bug 我在尝试从源码安装 ktransformers(使用 CUDA 编译)时遇到了构建失败的问题,pip 调用 CMake 编译时报错: subprocess.CalledProcessError: Command '['cmake', '--build', '.', '--verbose', '--parallel=112']' returned non-zero exit status 1. error: subprocess-exited-with-error × Building wheel for ktransformers (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> See above for output. 我已尝试使用 KTRANSFORMERS_FORCE_BUILD=TRUE pip install -v . --no-build-isolation 并开启详细日志查看,但编译失败的位置仍然不明确。 🔁 复现步骤 克隆源码并进入目录 更新子模块:git submodule update --init --recursive 确保 CUDA 环境变量已配置 安装依赖后执行:USE_BALANCE_SERVE=1 USE_NUMA=1 bash ./install.sh ### Reproduction USE_BALANCE_SERVE=1 USE_NUMA=1 bash ./install.sh ### Environment 操作系统 | Ubuntu 22.04 / Linux Kernel 5.15.0-136-generic Python 版本 | 3.11.11 Python 路径 | /mnt/data/py311/bin/python PyTorch 版本 | 2.6.0+cu124 CUDA Available | ✅ 是 PyTorch 用的 CUDA 版本 | 12.4 系统安装的 CUDA 版本 (nvcc) | 12.6 (V12.6.20) CUDA_HOME | /usr/local/cuda PATH 中的 CUDA 路径 | /usr/local/cuda/bin(已设置) GCC / G++ | 11.4.0 CMake 版本 | 3.22.1
Author
Owner

@yeungtuzi commented on GitHub (Apr 9, 2025):

问题太多,不知道如何定位,看各种说法都有,包括

  1. git submodules update --init --recursive 没有完整正确下载整个代码树(魔法上网,或者开发组弄个国内镜像)
  2. 22.04-lts自带cmake版本太低
    好像比较看脸
<!-- gh-comment-id:2790097314 --> @yeungtuzi commented on GitHub (Apr 9, 2025): 问题太多,不知道如何定位,看各种说法都有,包括 1. git submodules update --init --recursive 没有完整正确下载整个代码树(魔法上网,或者开发组弄个国内镜像) 2. 22.04-lts自带cmake版本太低 好像比较看脸
Author
Owner

@Zzzer0o commented on GitHub (Apr 10, 2025):

遇到一样的问题,使用的docker 镜像pytorch/pytorch:2.6.0-cuda12.6-cudnn9-devel,报错根本看不出原因。

<!-- gh-comment-id:2791348980 --> @Zzzer0o commented on GitHub (Apr 10, 2025): 遇到一样的问题,使用的docker 镜像pytorch/pytorch:2.6.0-cuda12.6-cudnn9-devel,报错根本看不出原因。
Author
Owner

@Zhiwei-Dai commented on GitHub (Apr 10, 2025):

也遇到了这个问题,0.2.3正常,升级到0.2.4报出一堆异常,也定位不到原因。我做了两点尝试,通过了,供参考:
1、cmake可使用pip安装升级到最新4.0
2、看了B站的视频之后,参考脚本执行正常:env USE_BALANCE_SERVE=1 USE_NUMA=1 PYTHONPATH="$(which python)" PATH="$(dirname $(which python)):$PATH" bash ./install.sh。(参考官方的就是不行:USE_BALANCE_SERVE=1 USE_NUMA=1 bash ./install.sh)

<!-- gh-comment-id:2791794662 --> @Zhiwei-Dai commented on GitHub (Apr 10, 2025): 也遇到了这个问题,0.2.3正常,升级到0.2.4报出一堆异常,也定位不到原因。我做了两点尝试,通过了,供参考: 1、cmake可使用pip安装升级到最新4.0 2、看了[B站的视频](https://www.bilibili.com/video/BV1czZDYaEZ5?spm_id_from=333.788.player.switch&p=3)之后,参考脚本执行正常:env USE_BALANCE_SERVE=1 USE_NUMA=1 PYTHONPATH="$(which python)" PATH="$(dirname $(which python)):$PATH" bash ./install.sh。(参考[官方](https://kvcache-ai.github.io/ktransformers/en/install.html)的就是不行:USE_BALANCE_SERVE=1 USE_NUMA=1 bash ./install.sh)
Author
Owner

@yeungtuzi commented on GitHub (Apr 10, 2025):

再补充一些内容,编译前执行
export CUDA_HOME=/usr/local/cuda
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
export CUDA_PATH=/usr/local/cuda
export TORCH_CUDA_ARCH_LIST="8.9" #"8.9" for 4090, "8.0" for A100
pip install cmake --upgrade

<!-- gh-comment-id:2792136669 --> @yeungtuzi commented on GitHub (Apr 10, 2025): 再补充一些内容,编译前执行 export CUDA_HOME=/usr/local/cuda export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH export CUDA_PATH=/usr/local/cuda export TORCH_CUDA_ARCH_LIST="8.9" #"8.9" for 4090, "8.0" for A100 pip install cmake --upgrade
Author
Owner

@QThans commented on GitHub (Apr 10, 2025):

也遇到了这个问题,0.2.3正常,升级到0.2.4报出一堆异常,也定位不到原因。我做了两点尝试,通过了,供参考: 1、cmake可使用pip安装升级到最新4.0 2、看了B站的视频之后,参考脚本执行正常:env USE_BALANCE_SERVE=1 USE_NUMA=1 PYTHONPATH="$(which python)" PATH="$(dirname $(which python)):$PATH" bash ./install.sh。(参考官方的就是不行:USE_BALANCE_SERVE=1 USE_NUMA=1 bash ./install.sh)

这样 ok 了。cmake 4.0 很重要

<!-- gh-comment-id:2794424083 --> @QThans commented on GitHub (Apr 10, 2025): > 也遇到了这个问题,0.2.3正常,升级到0.2.4报出一堆异常,也定位不到原因。我做了两点尝试,通过了,供参考: 1、cmake可使用pip安装升级到最新4.0 2、看了[B站的视频](https://www.bilibili.com/video/BV1czZDYaEZ5?spm_id_from=333.788.player.switch&p=3)之后,参考脚本执行正常:env USE_BALANCE_SERVE=1 USE_NUMA=1 PYTHONPATH="$(which python)" PATH="$(dirname $(which python)):$PATH" bash ./install.sh。(参考[官方](https://kvcache-ai.github.io/ktransformers/en/install.html)的就是不行:USE_BALANCE_SERVE=1 USE_NUMA=1 bash ./install.sh) 这样 ok 了。cmake 4.0 很重要
Author
Owner

@CYSTEV-chn commented on GitHub (Apr 16, 2025):

铲掉克隆的kt文件下,重新克隆一遍,应该可以跑通

<!-- gh-comment-id:2807969722 --> @CYSTEV-chn commented on GitHub (Apr 16, 2025): 铲掉克隆的kt文件下,重新克隆一遍,应该可以跑通
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#767
No description provided.