-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.py
59 lines (48 loc) · 1.79 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import os
import sys
import subprocess
import multiprocessing
from setuptools import setup, Extension
from setuptools.command.build_ext import build_ext
class CMakeExtension(Extension):
def __init__(self, name, sourcedir=''):
Extension.__init__(self, name, sources=[])
class BuildPackage(build_ext):
def run(self):
for ext in self.extensions:
self.build_extension(ext)
def build_extension(self, ext):
# FIXME: Release mode fails with an error: undefined symbol: fatbinData
cfg = 'Debug' if self.debug else 'RelWithDebInfo'
extdir = os.path.abspath(os.path.dirname(self.get_ext_fullpath(ext.name)))
script_dir = os.path.dirname(os.path.abspath(__file__))
cmake_args = [
f"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY={extdir}",
f"-DPYTHON_EXECUTABLE={sys.executable}",
f"-DCMAKE_BUILD_TYPE={cfg}",
]
build_args = ['--config', cfg]
num_threads = multiprocessing.cpu_count() - 1
if num_threads > 1:
build_args.append(f"-j{num_threads}")
os.makedirs(self.build_temp, exist_ok=True)
subprocess.check_call(["cmake", "-S", ".", "-B", self.build_temp] + cmake_args, cwd=script_dir)
subprocess.check_call(["cmake", "--build", self.build_temp] + build_args, cwd=script_dir)
setup(
name='cuda_float_compress',
version='0.2.3',
python_requires='>=3.7',
author='catid',
description='A PyTorch CUDA extension for floating-point compression',
ext_modules=[CMakeExtension('cuda_float_compress')],
cmdclass={"build_ext": BuildPackage},
package_data={
'cuda_float_compress': ['cuda_float_compress*.so'],
},
include_package_data=True,
zip_safe=False,
install_requires=[
'torch',
'numpy',
],
)