cfg_vars[key] = value.replace("-Wstrict-prototypes", "") ################################################################################ # Custom build commands ################################################################################ dep_libs = [ 'nccl', 'ATen', 'libshm', 'libshm_windows', 'gloo', 'THD', 'nanopb', ] # global ninja file for building generated code stuff ninja_global = None if WITH_NINJA: ninja_global = NinjaBuilder('global') def build_libs(libs): for lib in libs: assert lib in dep_libs, 'invalid lib: {}'.format(lib) if IS_WINDOWS: build_libs_cmd = ['torch\\lib\\build_libs.bat'] else: build_libs_cmd = ['bash', 'torch/lib/build_libs.sh'] my_env = os.environ.copy() my_env["PYTORCH_PYTHON"] = sys.executable if not IS_WINDOWS: if WITH_NINJA: my_env["CMAKE_GENERATOR"] = '-GNinja' my_env["CMAKE_INSTALL"] = 'ninja install'
def run(self): # Print build options if USE_NUMPY: print('-- Building with NumPy bindings') else: print('-- NumPy not found') if USE_CUDNN: print('-- Detected cuDNN at ' + CUDNN_LIBRARY + ', ' + CUDNN_INCLUDE_DIR) else: print('-- Not using cuDNN') if USE_MIOPEN: print('-- Detected MIOpen at ' + MIOPEN_LIBRARY + ', ' + MIOPEN_INCLUDE_DIR) else: print('-- Not using MIOpen') if USE_CUDA: print('-- Detected CUDA at ' + CUDA_HOME) else: print('-- Not using CUDA') if USE_MKLDNN: print('-- Using MKLDNN') else: print('-- Not using MKLDNN') if USE_NCCL and USE_SYSTEM_NCCL: print('-- Using system provided NCCL library at ' + NCCL_SYSTEM_LIB + ', ' + NCCL_INCLUDE_DIR) elif USE_NCCL: print('-- Building NCCL library') else: print('-- Not using NCCL') if USE_DISTRIBUTED: print('-- Building with THD distributed package ') if IS_LINUX: print('-- Building with c10d distributed package ') else: print('-- Building without c10d distributed package') else: print('-- Building without distributed package') if USE_NINJA: ninja_builder = NinjaBuilder('global') generate_code(ninja_builder) # before we start the normal build make sure all generated code # gets built ninja_builder.run() else: generate_code(None) # It's an old-style class in Python 2.7... setuptools.command.build_ext.build_ext.run(self) # Copy the essential export library to compile C++ extensions. if IS_WINDOWS: build_temp = self.build_temp ext_filename = self.get_ext_filename('_C') lib_filename = '.'.join(ext_filename.split('.')[:-1]) + '.lib' export_lib = os.path.join(build_temp, 'torch', 'csrc', lib_filename).replace('\\', '/') build_lib = self.build_lib target_lib = os.path.join(build_lib, 'torch', 'lib', '_C.lib').replace('\\', '/') self.copy_file(export_lib, target_lib)