def runtime(self, _from='0'): """Generate the set of instructions to install the runtime specific components from a build in a previous stage. # Examples ```python n = nccl(...) Stage0 += n Stage1 += n.runtime() ``` """ self.rt += comment('NCCL') if self.__build: self.rt += copy(_from=_from, src=self.__prefix, dest=self.__prefix) self.rt += environment(variables=self.environment_step()) else: self.rt += packages(ospackages=self.__ospackages) self.rt += packages( apt=[ 'libnccl2={0}+cuda{1}'.format(self.__version, self.__cuda) ], apt_keys=[ 'https://developer.download.nvidia.com/compute/machine-learning/repos/{0}/{1}/7fa2af80.pub' .format(self.__distro_label, get_cpu_architecture()) ], apt_repositories=[ 'deb https://developer.download.nvidia.com/compute/machine-learning/repos/{0}/{1} /' .format(self.__distro_label, get_cpu_architecture()) ], yum=[ 'libnccl-{0}+cuda{1}'.format(self.__version, self.__cuda) ], yum_keys=[ 'https://developer.download.nvidia.com/compute/machine-learning/repos/{0}/{1}/7fa2af80.pub' .format(self.__distro_label, get_cpu_architecture()) ], yum_repositories=[ 'https://developer.download.nvidia.com/compute/machine-learning/repos/{0}/{1}' .format(self.__distro_label, get_cpu_architecture()) ]) return str(self.rt)
def __init__(self, **kwargs): """Initialize building block""" super(nccl, self).__init__(**kwargs) self.__baseurl = kwargs.pop('baseurl', 'https://github.com/NVIDIA/nccl/archive') self.__build = kwargs.pop('build', False) self.__build_environment = '' # Filled in by __configure self.__default_repository = 'https://github.com/NVIDIA/nccl.git' self.__distro_label = '' # Filled in by __distro self.__cuda = kwargs.pop('cuda', '11.0') self.__make_variables = kwargs.pop('make_variables', {}) self.__ospackages = kwargs.pop('ospackages', []) self.__prefix = kwargs.pop('prefix', '/usr/local/nccl') self.__src_directory = kwargs.pop('src_directory', None) self.__version = kwargs.pop('version', '2.7.8-1') self.__wd = '/var/tmp' # working directory if not self.__build: # Install prebuild package # Set the Linux distribution specific parameters self.__distro() self += comment('NCCL {}'.format(self.__version)) self += packages(ospackages=self.__ospackages) self += packages( apt=[ 'libnccl2={0}+cuda{1}'.format(self.__version, self.__cuda), 'libnccl-dev={0}+cuda{1}'.format(self.__version, self.__cuda) ], apt_keys=[ 'https://developer.download.nvidia.com/compute/machine-learning/repos/{0}/{1}/7fa2af80.pub' .format(self.__distro_label, get_cpu_architecture()) ], apt_repositories=[ 'deb https://developer.download.nvidia.com/compute/machine-learning/repos/{0}/{1} /' .format(self.__distro_label, get_cpu_architecture()) ], yum=[ 'libnccl-{0}+cuda{1}'.format(self.__version, self.__cuda), 'libnccl-devel-{0}+cuda{1}'.format(self.__version, self.__cuda) ], yum_keys=[ 'https://developer.download.nvidia.com/compute/machine-learning/repos/{0}/{1}/7fa2af80.pub' .format(self.__distro_label, get_cpu_architecture()) ], yum_repositories=[ 'https://developer.download.nvidia.com/compute/machine-learning/repos/{0}/{1}' .format(self.__distro_label, get_cpu_architecture()) ]) else: # Build from source # Set the build options self.__configure() self.__download() kwargs['repository'] = self.repository kwargs['url'] = self.url # Setup the environment variables self.environment_variables['CPATH'] = '{}:$CPATH'.format( posixpath.join(self.__prefix, 'include')) self.environment_variables[ 'LIBRARY_PATH'] = '{}:$LIBRARY_PATH'.format( posixpath.join(self.__prefix, 'lib')) self.environment_variables['PATH'] = '{}:$PATH'.format( posixpath.join(self.__prefix, 'bin')) if not self.ldconfig: self.environment_variables[ 'LD_LIBRARY_PATH'] = '{}:$LD_LIBRARY_PATH'.format( posixpath.join(self.__prefix, 'lib')) self.__bb = generic_build( base_annotation=self.__class__.__name__, build=[ '{} make -j$(nproc) install'.format( self.__build_environment) ], comment=False, devel_environment=self.environment_variables, directory='nccl-{}'.format(self.__version) if not self.repository else None, prefix=self.__prefix, runtime_environment=self.environment_variables, **kwargs) self += comment('NCCL') self += packages(ospackages=self.__ospackages) self += self.__bb