mirror of
https://github.com/kvcache-ai/ktransformers.git
synced 2025-09-10 23:34:35 +00:00
fix compile, add abi check to setup.py
This commit is contained in:
parent
f4ae7c85ed
commit
9dd24ecd72
6 changed files with 17 additions and 28 deletions
12
setup.py
12
setup.py
|
@ -25,6 +25,7 @@ import urllib.request
|
|||
import urllib.error
|
||||
from pathlib import Path
|
||||
from packaging.version import parse
|
||||
import torch
|
||||
import torch.version
|
||||
from wheel.bdist_wheel import bdist_wheel as _bdist_wheel
|
||||
from setuptools import setup, Extension
|
||||
|
@ -281,6 +282,13 @@ class CMakeExtension(Extension):
|
|||
print(name, sourcedir)
|
||||
self.sourcedir = sourcedir
|
||||
|
||||
def get_cmake_abi_args(cmake_args):
|
||||
if torch.compiled_with_cxx11_abi():
|
||||
cmake_args.append("-D_GLIBCXX_USE_CXX11_ABI=1")
|
||||
else:
|
||||
cmake_args.append("-D_GLIBCXX_USE_CXX11_ABI=0")
|
||||
return cmake_args
|
||||
|
||||
class CMakeBuild(BuildExtension):
|
||||
|
||||
def build_extension(self, ext) -> None:
|
||||
|
@ -318,6 +326,8 @@ class CMakeBuild(BuildExtension):
|
|||
cmake_args += ["-DKTRANSFORMERS_USE_ROCM=ON"]
|
||||
else:
|
||||
raise ValueError("Unsupported backend: CUDA_HOME, MUSA_HOME, and ROCM_HOME are not set.")
|
||||
|
||||
cmake_args = get_cmake_abi_args(cmake_args)
|
||||
# log cmake_args
|
||||
print("CMake args:", cmake_args)
|
||||
|
||||
|
@ -470,4 +480,4 @@ setup(
|
|||
version=VersionInfo().get_package_version(),
|
||||
cmdclass={"bdist_wheel":BuildWheelsCommand ,"build_ext": CMakeBuild},
|
||||
ext_modules=ext_modules
|
||||
)
|
||||
)
|
Loading…
Add table
Add a link
Reference in a new issue