| 8 | |
| 9 | |
| 10 | class GDSBuilder(AsyncIOBuilder): |
| 11 | BUILD_VAR = "DS_BUILD_GDS" |
| 12 | NAME = "gds" |
| 13 | |
| 14 | def __init__(self): |
| 15 | super().__init__() |
| 16 | |
| 17 | def absolute_name(self): |
| 18 | return f'deepspeed.ops.gds.{self.NAME}_op' |
| 19 | |
| 20 | def lib_sources(self): |
| 21 | src_list = ['csrc/gds/py_lib/deepspeed_py_gds_handle.cpp', 'csrc/gds/py_lib/deepspeed_gds_op.cpp'] |
| 22 | return super().lib_sources() + src_list |
| 23 | |
| 24 | def sources(self): |
| 25 | return self.lib_sources() + ['csrc/gds/py_lib/py_ds_gds.cpp'] |
| 26 | |
| 27 | def cxx_args(self): |
| 28 | return super().cxx_args() + ['-lcufile'] |
| 29 | |
| 30 | def include_paths(self): |
| 31 | import torch |
| 32 | CUDA_INCLUDE = [os.path.join(torch.utils.cpp_extension.CUDA_HOME, "include")] |
| 33 | return ['csrc/aio/py_lib', 'csrc/aio/common'] + CUDA_INCLUDE |
| 34 | |
| 35 | def extra_ldflags(self): |
| 36 | return super().extra_ldflags() + ['-lcufile'] |
| 37 | |
| 38 | def is_compatible(self, verbose=False): |
| 39 | if self.is_rocm_pytorch(): |
| 40 | if verbose: |
| 41 | self.warning(f'{self.NAME} is not compatible with ROCM') |
| 42 | return False |
| 43 | |
| 44 | try: |
| 45 | import torch.utils.cpp_extension |
| 46 | except ImportError: |
| 47 | if verbose: |
| 48 | self.warning("Please install torch if trying to pre-compile GDS") |
| 49 | return False |
| 50 | |
| 51 | CUDA_HOME = torch.utils.cpp_extension.CUDA_HOME |
| 52 | if CUDA_HOME is None: |
| 53 | if verbose: |
| 54 | self.warning("Please install torch CUDA if trying to pre-compile GDS with CUDA") |
| 55 | return False |
| 56 | |
| 57 | CUDA_LIB64 = os.path.join(CUDA_HOME, "lib64") |
| 58 | gds_compatible = self.has_function(funcname="cuFileDriverOpen", |
| 59 | libraries=("cufile", ), |
| 60 | library_dirs=( |
| 61 | CUDA_HOME, |
| 62 | CUDA_LIB64, |
| 63 | ), |
| 64 | verbose=verbose) |
| 65 | |
| 66 | return gds_compatible and super().is_compatible(verbose) |
no outgoing calls
searching dependent graphs…