-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
91 lines (82 loc) · 2.63 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import os
from setuptools import setup, find_packages
from torch.utils.cpp_extension import CUDAExtension, BuildExtension
from setuptools.command.install import install
import shutil
cpu_count = os.cpu_count()
if cpu_count:
os.environ["MAX_JOBS"] = str(cpu_count)
else:
os.environ["MAX_JOBS"] = "1"
with open("README.md", "r", encoding="utf-8") as f:
long_description = f.read()
class CustomBuildExtCommand(BuildExtension.with_options(parallel=True)):
def run(self):
super().run()
build_lib = os.path.abspath(self.build_lib)
target_dir = os.path.join(build_lib, "evogp")
os.makedirs(target_dir, exist_ok=True)
for ext in self.extensions:
if ext.name == "evogp_cuda":
ext_path = self.get_ext_fullpath(ext.name)
target_path = os.path.join(
build_lib, "evogp", os.path.basename(ext_path)
)
print(f"Copying {ext_path} to {target_path}")
shutil.copy2(ext_path, target_path)
class CustomInstallCommand(install):
def run(self):
super().run()
setup(
name="evogp",
version="0.1.0",
author="Zhihong Wu, Lishuang Wang, Kebin Sun",
author_email="[email protected]",
description="Evolutionary Genetic Programming with CUDA-based GPU acceleration.",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/EMI-Group/evogp",
packages=find_packages(where="src"),
package_dir={"": "src"},
ext_modules=[
CUDAExtension(
name="evogp_cuda",
sources=[
"./src/evogp/cuda/torch_wrapper.cu",
"./src/evogp/cuda/generate.cu",
"./src/evogp/cuda/mutation.cu",
"./src/evogp/cuda/forward.cu",
],
extra_compile_args={
"cxx": ["-O3"],
"nvcc": [
"-O3",
"--expt-relaxed-constexpr",
"--ptxas-options=-v",
"-Xptxas=-O3",
"-lineinfo",
"-lcudart",
"-use_fast_math",
"-maxrregcount=32",
],
},
)
],
cmdclass={
"build_ext": CustomBuildExtCommand,
"install": CustomInstallCommand,
},
install_requires=[
"torch",
"numpy",
"scikit_learn",
"networkx",
"sympy",
],
extras_require={
"visualize": ["pygraphviz"],
"brax": ["jax", "brax"],
},
include_package_data=True,
python_requires=">=3.9",
)