Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
#
# Copyright (c) 2022 Opentensor Foundation

# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
# documentation files (the “Software”), to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
# documentation files (the “Software”), to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
# and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

# The above copyright notice and this permission notice shall be included in all copies or substantial portions of
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of
# the Software.

# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
# THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.

__version__ = "1.1.2"
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# pyproject.toml

[build-system]
requires = ["setuptools>=59.0.0", "wheel==0.37.1", "Cython>=0.29.33", "numpy==1.21.6" ]
requires = ["setuptools>=70.0.0", "wheel", "Cython>=0.29.33", "numpy>=1.21.6" ]
build-backend = "setuptools.build_meta"

[project]
name = "cubit"
version = "1.2.0"
version = "1.2.1"
description = "A python package for CUDA registration on bittensor. "
readme = "README.md"
authors = [{ name = "Opentensor Foundation", email = "cameron@opentensor.ai" }]
Expand All @@ -18,12 +18,12 @@ classifiers = [
]
keywords = ["bittensor", "cuda", "register", "cubit"]
dependencies = [
"setuptools>=59.0.0", "wheel==0.37.1", "Cython>=0.29.33", "numpy==1.21.6"
"setuptools>=70.0.0", "wheel", "Cython>=0.29.33", "numpy>=1.21.6", "torch>=1.13.1,<3.0"
]
requires-python = ">=3.8"

[project.optional-dependencies]
test = ["black", "pip-tools", "bittensor>=3.0.0", "pycryptodome==3.4.3" ]
test = ["ruff", "pip-tools", "bittensor>=9.0.0", "pycryptodome==3.4.3" ]

[project.urls]
Homepage = "https://github.com/opentensor/cubit"
117 changes: 64 additions & 53 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
#
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
Expand All @@ -28,6 +28,7 @@
from Cython.Build import cythonize
import numpy


def find_in_path(name, path):
"""Find a file in a search path"""

Expand All @@ -50,25 +51,31 @@ def locate_cuda():
"""

# First check if the CUDAHOME env variable is in use
if 'CUDA_HOME' in os.environ:
home = os.environ['CUDA_HOME']
nvcc = pjoin(home, 'bin', 'nvcc')
if "CUDA_HOME" in os.environ:
home = os.environ["CUDA_HOME"]
nvcc = pjoin(home, "bin", "nvcc")
else:
# Otherwise, search the PATH for NVCC
nvcc = find_in_path('nvcc', os.environ['PATH'])
nvcc = find_in_path("nvcc", os.environ["PATH"])
if nvcc is None:
raise EnvironmentError('The nvcc binary could not be '
'located in your $PATH. Either add it to your path, '
'or set $CUDA_HOME')
raise EnvironmentError(
"The nvcc binary could not be "
"located in your $PATH. Either add it to your path, "
"or set $CUDA_HOME"
)
home = os.path.dirname(os.path.dirname(nvcc))

cudaconfig = {'home': home, 'nvcc': nvcc,
'include': pjoin(home, 'include'),
'lib64': pjoin(home, 'lib64')}
cudaconfig = {
"home": home,
"nvcc": nvcc,
"include": pjoin(home, "include"),
"lib64": pjoin(home, "lib64"),
}
for k, v in iter(cudaconfig.items()):
if not os.path.exists(v):
raise EnvironmentError('The CUDA %s path could not be '
'located in %s' % (k, v))
raise EnvironmentError(
"The CUDA %s path could not be located in %s" % (k, v)
)

return cudaconfig

Expand All @@ -85,7 +92,7 @@ def customize_compiler_for_nvcc(self):
"""

# Tell the compiler it can processes .cu and files
self.src_extensions.append('.cu')
self.src_extensions.append(".cu")

# Save references to the default compiler_so and _comple methods
default_compiler_so = self.compiler_so
Expand All @@ -95,14 +102,14 @@ def customize_compiler_for_nvcc(self):
# object but distutils doesn't have the ability to change compilers
# based on source extension: we add it.
def _compile(obj, src, ext, cc_args, extra_postargs, pp_opts):
if os.path.splitext(src)[1] == '.cu':
if os.path.splitext(src)[1] == ".cu":
# use the cuda for .cu files
self.set_executable('compiler_so', CUDA['nvcc'])
self.set_executable("compiler_so", CUDA["nvcc"])
# use only a subset of the extra_postargs, which are 1-1
# translated from the extra_compile_args in the Extension class
postargs = extra_postargs['nvcc']
postargs = extra_postargs["nvcc"]
else:
postargs = extra_postargs['gcc']
postargs = extra_postargs["gcc"]

super(obj, src, ext, cc_args, postargs, pp_opts)
# Reset the default compiler_so, which we might have changed for cuda
Expand All @@ -112,15 +119,13 @@ def _compile(obj, src, ext, cc_args, extra_postargs, pp_opts):
self._compile = _compile



# Run the customize_compiler
class custom_build_ext(build_ext):
def build_extensions(self):
customize_compiler_for_nvcc(self.compiler)
build_ext.build_extensions(self)



CUDA = locate_cuda()

# Obtain the numpy include directory. This logic works across numpy versions.
Expand All @@ -129,44 +134,50 @@ def build_extensions(self):
except AttributeError:
numpy_include = numpy.get_numpy_include()

ext = Extension('cubit',
sources = ['kernels/main.cu', 'cubit.pyx'],
library_dirs=[CUDA['lib64']],
libraries=['cudart'],
language='c++',
runtime_library_dirs=[CUDA['lib64']],
extra_compile_args={
'gcc': [],
'nvcc': ['-Xptxas', '-v', '-O3',

'-gencode', 'arch=compute_86,code=sm_86',
'-gencode', 'arch=compute_80,code=sm_80',
'-gencode', 'arch=compute_75,code=sm_75',
'-gencode', 'arch=compute_70,code=sm_70',
'-gencode', 'arch=compute_61,code=sm_61',

'--ptxas-options=-v', '-c',
'--compiler-options', "'-fPIC'"
]
},
include_dirs = [numpy_include, CUDA['include']])

ext = Extension(
"cubit",
sources=["kernels/main.cu", "cubit.pyx"],
library_dirs=[CUDA["lib64"]],
libraries=["cudart"],
language="c++",
runtime_library_dirs=[CUDA["lib64"]],
extra_compile_args={
"gcc": [],
"nvcc": [
"-Xptxas",
"-v",
"-O3",
"-gencode",
"arch=compute_86,code=sm_86",
"-gencode",
"arch=compute_80,code=sm_80",
"-gencode",
"arch=compute_75,code=sm_75",
"-gencode",
"arch=compute_70,code=sm_70",
"-gencode",
"arch=compute_61,code=sm_61",
"--ptxas-options=-v",
"-c",
"--compiler-options",
"'-fPIC'",
],
},
include_dirs=[numpy_include, CUDA["include"]],
)


setup(
name = 'cubit',
name="cubit",
# Random metadata. there's more you can supply
author = 'Opentensor Foundation',
author_email = 'cameron@opentensor.ai',
url = 'https://github.com/opentensor/cubit',
version = '1.2.1',

ext_modules = cythonize(ext),

author="Opentensor Foundation",
author_email="cameron@opentensor.ai",
url="https://github.com/opentensor/cubit",
version="1.2.1",
ext_modules=cythonize(ext),
# Inject our custom trigger
cmdclass = {'build_ext': custom_build_ext},

cmdclass={"build_ext": custom_build_ext},
# Since the package has c code, the egg cannot be zipped
zip_safe = False,
zip_safe=False,
packages=find_packages(),
)
Loading