setup.py 1.51 KB
Newer Older
1
import torch
2
from setuptools import setup, find_packages
3

jjsjann123's avatar
jjsjann123 committed
4
5
import sys

6
7
8
9
if not torch.cuda.is_available():
    print("Warning: Torch did not find available GPUs on this system.\n",
          "If your intention is to cross-compile, this is not an error.")

10
11
12
13
14
15
16
17
print("torch.__version__  = ", torch.__version__)
TORCH_MAJOR = int(torch.__version__.split('.')[0])
TORCH_MINOR = int(torch.__version__.split('.')[1])

if TORCH_MAJOR == 0 and TORCH_MINOR < 4:
      raise RuntimeError("APEx requires Pytorch 0.4 or newer.\n" +
                         "The latest stable release can be obtained from https://pytorch.org/")

jjsjann123's avatar
jjsjann123 committed
18
19
20
21
22
23
24
25
26
27
28
29
30
cmdclass = {}
ext_modules = []

if "--cuda_ext" in sys.argv:
    from torch.utils.cpp_extension import CUDAExtension, BuildExtension
    sys.argv.remove("--cuda_ext")
    cmdclass['build_ext'] = BuildExtension
    ext_modules.append(CUDAExtension('syncbn',[
                   'csrc/syncbn.cpp',
                   'csrc/welford.cu'
                  ]))


Christian Sarofeen's avatar
Christian Sarofeen committed
31
setup(
32
33
34
35
36
37
38
39
40
41
42
    name='apex',
    version='0.1',
    packages=find_packages(exclude=('build', 
                                    'csrc', 
                                    'include', 
                                    'tests', 
                                    'dist',
                                    'docs',
                                    'tests',
                                    'examples',
                                    'apex.egg-info',)),
Christian Sarofeen's avatar
Christian Sarofeen committed
43
    description='PyTorch Extensions written by NVIDIA',
jjsjann123's avatar
jjsjann123 committed
44
45
    ext_modules=ext_modules,
    cmdclass=cmdclass,
Christian Sarofeen's avatar
Christian Sarofeen committed
46
)