[GH-ISSUE #1322] [Bug] when compiling: Unknown CMake command "pybind11_add_module" #890

Closed
opened 2026-10-29 14:45:48 +00:00 by bsakaguchi · 4 comments
Owner

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

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

当前版本(031)编译过程中遇到的问题 , 按照install 的流程, 可能是cmake版本导致的? 报错信息为:

-- enabling CUDA
-- The CUDA compiler identification is NVIDIA 12.2.91 with host compiler GNU 11.4.0
-- Detecting CUDA compiler ABI info
-- Detecting CUDA compiler ABI info - done
-- Check for working CUDA compiler: /usr/local/cuda/bin/nvcc - skipped
-- Detecting CUDA compile features
-- Detecting CUDA compile features - done
-- CMAKE_CXX_FLAGS: -O3 -ffast-math -fopenmp
-- ARCH_FLAGS: -mfma;-mavx;-mavx2;-march=native
CMake Error at CMakeLists.txt:354 (pybind11_add_module):
Unknown CMake command "pybind11_add_module".

-- Configuring incomplete, errors occurred!
CMake args: ['-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/home/JinghuaGao/ktransformers/build/lib.linux-x86_64-cpython-311/', '-DPYTHON_EXECUTABLE=/home/JinghuaGao/anaconda3/envs/ktransformers/bin/python3.11', '-DCMAKE_BUILD_TYPE=Release', '-DKTRANSFORMERS_USE_CUDA=ON', '-D_GLIBCXX_USE_CXX11_ABI=1']
CMake args: ['-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/home/JinghuaGao/ktransformers/build/lib.linux-x86_64-cpython-311/', '-DPYTHON_EXECUTABLE=/home/JinghuaGao/anaconda3/envs/ktransformers/bin/python3.11', '-DCMAKE_BUILD_TYPE=Release', '-DKTRANSFORMERS_USE_CUDA=ON', '-D_GLIBCXX_USE_CXX11_ABI=1', '-DLLAMA_NATIVE=ON', '-DEXAMPLE_VERSION_INFO=0.3+cu122torch27fancy']
build_temp: /home/JinghuaGao/ktransformers/csrc/ktransformers_ext/build
Traceback (most recent call last):
File "/home/JinghuaGao/anaconda3/envs/ktransformers/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 389, in
main()
File "/home/JinghuaGao/anaconda3/envs/ktransformers/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 373, in main
json_out["return_val"] = hook(**hook_input["kwargs"])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/JinghuaGao/anaconda3/envs/ktransformers/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 280, in build_wheel
return _build_backend().build_wheel(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/JinghuaGao/anaconda3/envs/ktransformers/lib/python3.11/site-packages/setuptools/build_meta.py", line 438, in build_wheel
return _build(['bdist_wheel', '--dist-info-dir', str(metadata_directory)])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/JinghuaGao/anaconda3/envs/ktransformers/lib/python3.11/site-packages/setuptools/build_meta.py", line 426, in _build
return self._build_with_temp_dir(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/JinghuaGao/anaconda3/envs/ktransformers/lib/python3.11/site-packages/setuptools/build_meta.py", line 407, in _build_with_temp_dir
self.run_setup()
File "/home/JinghuaGao/anaconda3/envs/ktransformers/lib/python3.11/site-packages/setuptools/build_meta.py", line 320, in run_setup
exec(code, locals())
File "", line 668, in
File "/home/JinghuaGao/anaconda3/envs/ktransformers/lib/python3.11/site-packages/setuptools/init.py", line 117, in setup
return distutils.core.setup(**attrs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/JinghuaGao/anaconda3/envs/ktransformers/lib/python3.11/site-packages/setuptools/_distutils/core.py", line 186, in setup
return run_commands(dist)
^^^^^^^^^^^^^^^^^^
File "/home/JinghuaGao/anaconda3/envs/ktransformers/lib/python3.11/site-packages/setuptools/_distutils/core.py", line 202, in run_commands
dist.run_commands()
File "/home/JinghuaGao/anaconda3/envs/ktransformers/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 1002, in run_commands
self.run_command(cmd)
File "/home/JinghuaGao/anaconda3/envs/ktransformers/lib/python3.11/site-packages/setuptools/dist.py", line 1104, in run_command
super().run_command(command)
File "/home/JinghuaGao/anaconda3/envs/ktransformers/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 1021, in run_command
cmd_obj.run()
File "", line 263, in run
File "/home/JinghuaGao/anaconda3/envs/ktransformers/lib/python3.11/site-packages/setuptools/command/bdist_wheel.py", line 370, in run
self.run_command("build")
File "/home/JinghuaGao/anaconda3/envs/ktransformers/lib/python3.11/site-packages/setuptools/_distutils/cmd.py", line 357, in run_command
self.distribution.run_command(command)
File "/home/JinghuaGao/anaconda3/envs/ktransformers/lib/python3.11/site-packages/setuptools/dist.py", line 1104, in run_command
super().run_command(command)
File "/home/JinghuaGao/anaconda3/envs/ktransformers/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 1021, in run_command
cmd_obj.run()
File "/home/JinghuaGao/anaconda3/envs/ktransformers/lib/python3.11/site-packages/setuptools/_distutils/command/build.py", line 135, in run
self.run_command(cmd_name)
File "/home/JinghuaGao/anaconda3/envs/ktransformers/lib/python3.11/site-packages/setuptools/_distutils/cmd.py", line 357, in run_command
self.distribution.run_command(command)
File "/home/JinghuaGao/anaconda3/envs/ktransformers/lib/python3.11/site-packages/setuptools/dist.py", line 1104, in run_command
super().run_command(command)
File "/home/JinghuaGao/anaconda3/envs/ktransformers/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 1021, in run_command
cmd_obj.run()
File "/home/JinghuaGao/anaconda3/envs/ktransformers/lib/python3.11/site-packages/setuptools/command/build_ext.py", line 99, in run
_build_ext.run(self)
File "/home/JinghuaGao/anaconda3/envs/ktransformers/lib/python3.11/site-packages/setuptools/_distutils/command/build_ext.py", line 368, in run
self.build_extensions()
File "/home/JinghuaGao/anaconda3/envs/ktransformers/lib/python3.11/site-packages/torch/utils/cpp_extension.py", line 1010, in build_extensions
build_ext.build_extensions(self)
File "/home/JinghuaGao/anaconda3/envs/ktransformers/lib/python3.11/site-packages/setuptools/_distutils/command/build_ext.py", line 484, in build_extensions
self._build_extensions_serial()
File "/home/JinghuaGao/anaconda3/envs/ktransformers/lib/python3.11/site-packages/setuptools/_distutils/command/build_ext.py", line 510, in _build_extensions_serial
self.build_extension(ext)
File "", line 591, in build_extension
File "", line 370, in run_command_with_live_tail
File "/home/JinghuaGao/anaconda3/envs/ktransformers/lib/python3.11/subprocess.py", line 571, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['cmake', '/home/JinghuaGao/ktransformers/csrc/ktransformers_ext', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/home/JinghuaGao/ktransformers/build/lib.linux-x86_64-cpython-311/', '-DPYTHON_EXECUTABLE=/home/JinghuaGao/anaconda3/envs/ktransformers/bin/python3.11', '-DCMAKE_BUILD_TYPE=Release', '-DKTRANSFORMERS_USE_CUDA=ON', '-D_GLIBCXX_USE_CXX11_ABI=1', '-DLLAMA_NATIVE=ON', '-DEXAMPLE_VERSION_INFO=0.3+cu122torch27fancy']' 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.

note: This error originates from a subprocess, and is likely not a problem with pip.
full command: /home/JinghuaGao/anaconda3/envs/ktransformers/bin/python3.11 /home/JinghuaGao/anaconda3/envs/ktransformers/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py build_wheel /tmp/tmpv88rzseg
cwd: /home/JinghuaGao/ktransformers
Building wheel for ktransformers (pyproject.toml) ... error
ERROR: Failed building wheel for ktransformers
Failed to build ktransformers
ERROR: Failed to build installable wheels for some pyproject.toml based projects (ktransformers)

Reproduction

安装脚本
sh install.sh
or
USE_BALANCE_SERVE=1 bash ./install.sh
同样的bug
已经尝试过安装pybind11, 使用以下命令, 没有效果:
sudo apt install python3-pybind11
pip install pybind11[global]

Environment

ubuntu 22.04
conda python=3.11
cuda=12.6
torch=2.7
cmake=3.31.7
gcc=11.4

Originally created by @JinghuaGao on GitHub (May 19, 2025). Original GitHub issue: https://github.com/kvcache-ai/ktransformers/issues/1322 ### 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 当前版本(031)编译过程中遇到的问题 , 按照install 的流程, 可能是cmake版本导致的? 报错信息为: -- enabling CUDA -- The CUDA compiler identification is NVIDIA 12.2.91 with host compiler GNU 11.4.0 -- Detecting CUDA compiler ABI info -- Detecting CUDA compiler ABI info - done -- Check for working CUDA compiler: /usr/local/cuda/bin/nvcc - skipped -- Detecting CUDA compile features -- Detecting CUDA compile features - done -- CMAKE_CXX_FLAGS: -O3 -ffast-math -fopenmp -- ARCH_FLAGS: -mfma;-mavx;-mavx2;-march=native CMake Error at CMakeLists.txt:354 (pybind11_add_module): Unknown CMake command "pybind11_add_module". -- Configuring incomplete, errors occurred! CMake args: ['-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/home/JinghuaGao/ktransformers/build/lib.linux-x86_64-cpython-311/', '-DPYTHON_EXECUTABLE=/home/JinghuaGao/anaconda3/envs/ktransformers/bin/python3.11', '-DCMAKE_BUILD_TYPE=Release', '-DKTRANSFORMERS_USE_CUDA=ON', '-D_GLIBCXX_USE_CXX11_ABI=1'] CMake args: ['-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/home/JinghuaGao/ktransformers/build/lib.linux-x86_64-cpython-311/', '-DPYTHON_EXECUTABLE=/home/JinghuaGao/anaconda3/envs/ktransformers/bin/python3.11', '-DCMAKE_BUILD_TYPE=Release', '-DKTRANSFORMERS_USE_CUDA=ON', '-D_GLIBCXX_USE_CXX11_ABI=1', '-DLLAMA_NATIVE=ON', '-DEXAMPLE_VERSION_INFO=0.3+cu122torch27fancy'] build_temp: /home/JinghuaGao/ktransformers/csrc/ktransformers_ext/build Traceback (most recent call last): File "/home/JinghuaGao/anaconda3/envs/ktransformers/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 389, in <module> main() File "/home/JinghuaGao/anaconda3/envs/ktransformers/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 373, in main json_out["return_val"] = hook(**hook_input["kwargs"]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/JinghuaGao/anaconda3/envs/ktransformers/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 280, in build_wheel return _build_backend().build_wheel( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/JinghuaGao/anaconda3/envs/ktransformers/lib/python3.11/site-packages/setuptools/build_meta.py", line 438, in build_wheel return _build(['bdist_wheel', '--dist-info-dir', str(metadata_directory)]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/JinghuaGao/anaconda3/envs/ktransformers/lib/python3.11/site-packages/setuptools/build_meta.py", line 426, in _build return self._build_with_temp_dir( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/JinghuaGao/anaconda3/envs/ktransformers/lib/python3.11/site-packages/setuptools/build_meta.py", line 407, in _build_with_temp_dir self.run_setup() File "/home/JinghuaGao/anaconda3/envs/ktransformers/lib/python3.11/site-packages/setuptools/build_meta.py", line 320, in run_setup exec(code, locals()) File "<string>", line 668, in <module> File "/home/JinghuaGao/anaconda3/envs/ktransformers/lib/python3.11/site-packages/setuptools/__init__.py", line 117, in setup return distutils.core.setup(**attrs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/JinghuaGao/anaconda3/envs/ktransformers/lib/python3.11/site-packages/setuptools/_distutils/core.py", line 186, in setup return run_commands(dist) ^^^^^^^^^^^^^^^^^^ File "/home/JinghuaGao/anaconda3/envs/ktransformers/lib/python3.11/site-packages/setuptools/_distutils/core.py", line 202, in run_commands dist.run_commands() File "/home/JinghuaGao/anaconda3/envs/ktransformers/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 1002, in run_commands self.run_command(cmd) File "/home/JinghuaGao/anaconda3/envs/ktransformers/lib/python3.11/site-packages/setuptools/dist.py", line 1104, in run_command super().run_command(command) File "/home/JinghuaGao/anaconda3/envs/ktransformers/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 1021, in run_command cmd_obj.run() File "<string>", line 263, in run File "/home/JinghuaGao/anaconda3/envs/ktransformers/lib/python3.11/site-packages/setuptools/command/bdist_wheel.py", line 370, in run self.run_command("build") File "/home/JinghuaGao/anaconda3/envs/ktransformers/lib/python3.11/site-packages/setuptools/_distutils/cmd.py", line 357, in run_command self.distribution.run_command(command) File "/home/JinghuaGao/anaconda3/envs/ktransformers/lib/python3.11/site-packages/setuptools/dist.py", line 1104, in run_command super().run_command(command) File "/home/JinghuaGao/anaconda3/envs/ktransformers/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 1021, in run_command cmd_obj.run() File "/home/JinghuaGao/anaconda3/envs/ktransformers/lib/python3.11/site-packages/setuptools/_distutils/command/build.py", line 135, in run self.run_command(cmd_name) File "/home/JinghuaGao/anaconda3/envs/ktransformers/lib/python3.11/site-packages/setuptools/_distutils/cmd.py", line 357, in run_command self.distribution.run_command(command) File "/home/JinghuaGao/anaconda3/envs/ktransformers/lib/python3.11/site-packages/setuptools/dist.py", line 1104, in run_command super().run_command(command) File "/home/JinghuaGao/anaconda3/envs/ktransformers/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 1021, in run_command cmd_obj.run() File "/home/JinghuaGao/anaconda3/envs/ktransformers/lib/python3.11/site-packages/setuptools/command/build_ext.py", line 99, in run _build_ext.run(self) File "/home/JinghuaGao/anaconda3/envs/ktransformers/lib/python3.11/site-packages/setuptools/_distutils/command/build_ext.py", line 368, in run self.build_extensions() File "/home/JinghuaGao/anaconda3/envs/ktransformers/lib/python3.11/site-packages/torch/utils/cpp_extension.py", line 1010, in build_extensions build_ext.build_extensions(self) File "/home/JinghuaGao/anaconda3/envs/ktransformers/lib/python3.11/site-packages/setuptools/_distutils/command/build_ext.py", line 484, in build_extensions self._build_extensions_serial() File "/home/JinghuaGao/anaconda3/envs/ktransformers/lib/python3.11/site-packages/setuptools/_distutils/command/build_ext.py", line 510, in _build_extensions_serial self.build_extension(ext) File "<string>", line 591, in build_extension File "<string>", line 370, in run_command_with_live_tail File "/home/JinghuaGao/anaconda3/envs/ktransformers/lib/python3.11/subprocess.py", line 571, in run raise CalledProcessError(retcode, process.args, subprocess.CalledProcessError: Command '['cmake', '/home/JinghuaGao/ktransformers/csrc/ktransformers_ext', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/home/JinghuaGao/ktransformers/build/lib.linux-x86_64-cpython-311/', '-DPYTHON_EXECUTABLE=/home/JinghuaGao/anaconda3/envs/ktransformers/bin/python3.11', '-DCMAKE_BUILD_TYPE=Release', '-DKTRANSFORMERS_USE_CUDA=ON', '-D_GLIBCXX_USE_CXX11_ABI=1', '-DLLAMA_NATIVE=ON', '-DEXAMPLE_VERSION_INFO=0.3+cu122torch27fancy']' 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. note: This error originates from a subprocess, and is likely not a problem with pip. full command: /home/JinghuaGao/anaconda3/envs/ktransformers/bin/python3.11 /home/JinghuaGao/anaconda3/envs/ktransformers/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py build_wheel /tmp/tmpv88rzseg cwd: /home/JinghuaGao/ktransformers Building wheel for ktransformers (pyproject.toml) ... error ERROR: Failed building wheel for ktransformers Failed to build ktransformers ERROR: Failed to build installable wheels for some pyproject.toml based projects (ktransformers) ### Reproduction 安装脚本 sh install.sh or USE_BALANCE_SERVE=1 bash ./install.sh 同样的bug 已经尝试过安装pybind11, 使用以下命令, 没有效果: sudo apt install python3-pybind11 pip install pybind11[global] ### Environment ubuntu 22.04 conda python=3.11 cuda=12.6 torch=2.7 cmake=3.31.7 gcc=11.4
Author
Owner

@ovowei commented on GitHub (May 20, 2025):

Did you clone the third-party repository to ensure it's complete (especially the pybind11 library)?

<!-- gh-comment-id:2893101897 --> @ovowei commented on GitHub (May 20, 2025): Did you clone the third-party repository to ensure it's complete (especially the pybind11 library)?
Author
Owner

@JinghuaGao commented on GitHub (May 20, 2025):

Did you clone the third-party repository to ensure it's complete (especially the pybind11 library)?

no, how? the dir of "third-party" is all empty in my cloned Ktransformers path

<!-- gh-comment-id:2893213200 --> @JinghuaGao commented on GitHub (May 20, 2025): > Did you clone the third-party repository to ensure it's complete (especially the pybind11 library)? no, how? the dir of "third-party" is all empty in my cloned Ktransformers path
Author
Owner

@ovowei commented on GitHub (May 20, 2025):

try git submodule update --init --recursive

<!-- gh-comment-id:2893229565 --> @ovowei commented on GitHub (May 20, 2025): try `git submodule update --init --recursive`
Author
Owner

@JinghuaGao commented on GitHub (May 20, 2025):

try git submodule update --init --recursive

oh, that works for me, thanks !

<!-- gh-comment-id:2893295530 --> @JinghuaGao commented on GitHub (May 20, 2025): > try `git submodule update --init --recursive` oh, that works for me, thanks !
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#890
No description provided.