Caffe2 - Python API
A deep learning, cross platform ML framework
setup.py
1 import sys
2 import torch.cuda
3 from setuptools import setup
4 from torch.utils.cpp_extension import BuildExtension, CppExtension, CUDAExtension
5 from torch.utils.cpp_extension import CUDA_HOME
6 
7 CXX_FLAGS = [] if sys.platform == 'win32' else ['-g', '-Werror']
8 
9 ext_modules = [
10  CppExtension(
11  'torch_test_cpp_extension.cpp', ['extension.cpp'],
12  extra_compile_args=CXX_FLAGS),
13  CppExtension(
14  'torch_test_cpp_extension.msnpu', ['msnpu_extension.cpp'],
15  extra_compile_args=CXX_FLAGS),
16 ]
17 
18 if torch.cuda.is_available() and CUDA_HOME is not None:
19  extension = CUDAExtension(
20  'torch_test_cpp_extension.cuda', [
21  'cuda_extension.cpp',
22  'cuda_extension_kernel.cu',
23  'cuda_extension_kernel2.cu',
24  ],
25  extra_compile_args={'cxx': CXX_FLAGS,
26  'nvcc': ['-O2']})
27  ext_modules.append(extension)
28 
29 setup(
30  name='torch_test_cpp_extension',
31  packages=['torch_test_cpp_extension'],
32  ext_modules=ext_modules,
33  cmdclass={'build_ext': BuildExtension})
Definition: setup.py:1
def is_available()
Definition: __init__.py:45