3636from hpccm .primitives .copy import copy
3737from hpccm .primitives .environment import environment
3838
39- class nccl (bb_base , hpccm .templates .downloader , hpccm .templates .envvars ,
40- hpccm .templates .ldconfig ):
39+
40+ class nccl (
41+ bb_base ,
42+ hpccm .templates .downloader ,
43+ hpccm .templates .envvars ,
44+ hpccm .templates .ldconfig ,
45+ ):
4146 """The `nccl` building block installs the
4247 [NCCL](https://developer.nvidia.com/nccl) component.
4348
@@ -77,7 +82,7 @@ class nccl(bb_base, hpccm.templates.downloader, hpccm.templates.envvars,
7782 specified by `version`.
7883
7984 version: The version of NCCL to install. The default value is
80- `2.29.7 -1`.
85+ `2.30.4 -1`.
8186
8287 # Examples
8388
@@ -96,20 +101,20 @@ def __init__(self, **kwargs):
96101
97102 super (nccl , self ).__init__ (** kwargs )
98103
99- self .__arch_label = '' # Filled in by __cpu_arch
100- self .__baseurl = kwargs .pop (' baseurl' , ' https://github.com/NVIDIA/nccl/archive' )
101- self .__build = kwargs .pop (' build' , False )
102- self .__build_environment = '' # Filled in by __configure
103- self .__default_repository = ' https://github.com/NVIDIA/nccl.git'
104- self .__distro_label = '' # Filled in by __distro
105- self .__cuda = kwargs .pop (' cuda' , ' 13.2' )
106- self .__make_variables = kwargs .pop (' make_variables' , {})
107- self .__ospackages = kwargs .pop (' ospackages' , [])
108- self .__prefix = kwargs .pop (' prefix' , ' /usr/local/nccl' )
109- self .__repo_key = '' # Filled in by __repo_key
110- self .__src_directory = kwargs .pop (' src_directory' , None )
111- self .__version = kwargs .pop (' version' , '2.29.7-1' )
112- self .__wd = kwargs .get ('wd' , hpccm .config .g_wd ) # working directory
104+ self .__arch_label = "" # Filled in by __cpu_arch
105+ self .__baseurl = kwargs .pop (" baseurl" , " https://github.com/NVIDIA/nccl/archive" )
106+ self .__build = kwargs .pop (" build" , False )
107+ self .__build_environment = "" # Filled in by __configure
108+ self .__default_repository = " https://github.com/NVIDIA/nccl.git"
109+ self .__distro_label = "" # Filled in by __distro
110+ self .__cuda = kwargs .pop (" cuda" , " 13.2" )
111+ self .__make_variables = kwargs .pop (" make_variables" , {})
112+ self .__ospackages = kwargs .pop (" ospackages" , [])
113+ self .__prefix = kwargs .pop (" prefix" , " /usr/local/nccl" )
114+ self .__repo_key = "" # Filled in by __repo_key
115+ self .__src_directory = kwargs .pop (" src_directory" , None )
116+ self .__version = kwargs .pop (" version" , "2.30.4-1" )
117+ self .__wd = kwargs .get ("wd" , hpccm .config .g_wd ) # working directory
113118
114119 if not self .__build :
115120 # Install prebuild package
@@ -123,20 +128,40 @@ def __init__(self, **kwargs):
123128 # Set the repo key
124129 self .__repo ()
125130
126- self += comment (' NCCL {}' .format (self .__version ))
131+ self += comment (" NCCL {}" .format (self .__version ))
127132 self += packages (ospackages = self .__ospackages )
128133 self += packages (
129- apt = ['libnccl2={0}+cuda{1}' .format (self .__version ,
130- self .__cuda ),
131- 'libnccl-dev={0}+cuda{1}' .format (self .__version ,
132- self .__cuda )],
133- apt_keys = ['https://developer.download.nvidia.com/compute/cuda/repos/{0}/{1}/{2}' .format (self .__distro_label , self .__arch_label , self .__repo_key )],
134- apt_repositories = ['deb [signed-by=/usr/share/keyrings/{2}] https://developer.download.nvidia.com/compute/cuda/repos/{0}/{1} /' .format (self .__distro_label , self .__arch_label , self .__repo_key .replace ('.pub' , '.gpg' ))],
135- yum = ['libnccl-{0}+cuda{1}' .format (self .__version , self .__cuda ),
136- 'libnccl-devel-{0}+cuda{1}' .format (self .__version ,
137- self .__cuda )],
138- yum_keys = ['https://developer.download.nvidia.com/compute/cuda/repos/{0}/{1}/{2}' .format (self .__distro_label , self .__arch_label , self .__repo_key )],
139- yum_repositories = ['https://developer.download.nvidia.com/compute/cuda/repos/{0}/{1}' .format (self .__distro_label , self .__arch_label )])
134+ apt = [
135+ "libnccl2={0}+cuda{1}" .format (self .__version , self .__cuda ),
136+ "libnccl-dev={0}+cuda{1}" .format (self .__version , self .__cuda ),
137+ ],
138+ apt_keys = [
139+ "https://developer.download.nvidia.com/compute/cuda/repos/{0}/{1}/{2}" .format (
140+ self .__distro_label , self .__arch_label , self .__repo_key
141+ )
142+ ],
143+ apt_repositories = [
144+ "deb [signed-by=/usr/share/keyrings/{2}] https://developer.download.nvidia.com/compute/cuda/repos/{0}/{1} /" .format (
145+ self .__distro_label ,
146+ self .__arch_label ,
147+ self .__repo_key .replace (".pub" , ".gpg" ),
148+ )
149+ ],
150+ yum = [
151+ "libnccl-{0}+cuda{1}" .format (self .__version , self .__cuda ),
152+ "libnccl-devel-{0}+cuda{1}" .format (self .__version , self .__cuda ),
153+ ],
154+ yum_keys = [
155+ "https://developer.download.nvidia.com/compute/cuda/repos/{0}/{1}/{2}" .format (
156+ self .__distro_label , self .__arch_label , self .__repo_key
157+ )
158+ ],
159+ yum_repositories = [
160+ "https://developer.download.nvidia.com/compute/cuda/repos/{0}/{1}" .format (
161+ self .__distro_label , self .__arch_label
162+ )
163+ ],
164+ )
140165
141166 else :
142167 # Build from source
@@ -145,31 +170,38 @@ def __init__(self, **kwargs):
145170 self .__configure ()
146171
147172 self .__download ()
148- kwargs [' repository' ] = self .repository
149- kwargs [' url' ] = self .url
173+ kwargs [" repository" ] = self .repository
174+ kwargs [" url" ] = self .url
150175
151176 # Setup the environment variables
152- self .environment_variables ['CPATH' ] = '{}:$CPATH' .format (
153- posixpath .join (self .__prefix , 'include' ))
154- self .environment_variables ['LIBRARY_PATH' ] = '{}:$LIBRARY_PATH' .format (
155- posixpath .join (self .__prefix , 'lib' ))
156- self .environment_variables ['PATH' ] = '{}:$PATH' .format (
157- posixpath .join (self .__prefix , 'bin' ))
177+ self .environment_variables ["CPATH" ] = "{}:$CPATH" .format (
178+ posixpath .join (self .__prefix , "include" )
179+ )
180+ self .environment_variables ["LIBRARY_PATH" ] = "{}:$LIBRARY_PATH" .format (
181+ posixpath .join (self .__prefix , "lib" )
182+ )
183+ self .environment_variables ["PATH" ] = "{}:$PATH" .format (
184+ posixpath .join (self .__prefix , "bin" )
185+ )
158186 if not self .ldconfig :
159- self .environment_variables ['LD_LIBRARY_PATH' ] = '{}:$LD_LIBRARY_PATH' .format (posixpath .join (self .__prefix , 'lib' ))
187+ self .environment_variables ["LD_LIBRARY_PATH" ] = (
188+ "{}:$LD_LIBRARY_PATH" .format (posixpath .join (self .__prefix , "lib" ))
189+ )
160190
161191 self .__bb = generic_build (
162192 base_annotation = self .__class__ .__name__ ,
163- build = ['{} make -j$(nproc) install' .format (
164- self .__build_environment )],
193+ build = ["{} make -j$(nproc) install" .format (self .__build_environment )],
165194 comment = False ,
166195 devel_environment = self .environment_variables ,
167- directory = 'nccl-{}' .format (self .__version ) if not self .repository else None ,
196+ directory = (
197+ "nccl-{}" .format (self .__version ) if not self .repository else None
198+ ),
168199 prefix = self .__prefix ,
169200 runtime_environment = self .environment_variables ,
170- ** kwargs )
201+ ** kwargs
202+ )
171203
172- self += comment (' NCCL' )
204+ self += comment (" NCCL" )
173205 self += packages (ospackages = self .__ospackages )
174206 self += self .__bb
175207
@@ -178,91 +210,97 @@ def __cpu_arch(self):
178210 specified value overrides any defaults."""
179211
180212 if hpccm .config .g_cpu_arch == cpu_arch .AARCH64 :
181- self .__arch_label = ' sbsa'
213+ self .__arch_label = " sbsa"
182214 elif hpccm .config .g_cpu_arch == cpu_arch .X86_64 :
183- self .__arch_label = ' x86_64'
184- else : # pragma: no cover
185- raise RuntimeError (' Unknown CPU architecture' )
215+ self .__arch_label = " x86_64"
216+ else : # pragma: no cover
217+ raise RuntimeError (" Unknown CPU architecture" )
186218
187219 def __configure (self ):
188220 """Setup build options based on user parameters"""
189221
190222 e = {}
191223
192- e [' PREFIX' ] = self .__prefix
224+ e [" PREFIX" ] = self .__prefix
193225
194226 if self .__make_variables :
195- e .update (self .__make_variables )
227+ e .update (self .__make_variables )
196228
197229 l = []
198230 if e :
199231 for key , val in sorted (e .items ()):
200- l .append (' {0}={1}' .format (key , val ))
232+ l .append (" {0}={1}" .format (key , val ))
201233
202- self .__build_environment = ' ' .join (l )
234+ self .__build_environment = " " .join (l )
203235
204236 def __distro (self ):
205237 """Based on the Linux distribution, set values accordingly. A user
206238 specified value overrides any defaults."""
207239
208240 if hpccm .config .g_linux_distro == linux_distro .UBUNTU :
209241 if not self .__ospackages :
210- self .__ospackages = ['apt-transport-https' , 'ca-certificates' ,
211- 'gnupg' , 'wget' ]
212-
213- if hpccm .config .g_linux_version >= Version ('24.0' ):
214- self .__distro_label = 'ubuntu2404'
215- elif hpccm .config .g_linux_version >= Version ('22.0' ):
216- self .__distro_label = 'ubuntu2204'
242+ self .__ospackages = [
243+ "apt-transport-https" ,
244+ "ca-certificates" ,
245+ "gnupg" ,
246+ "wget" ,
247+ ]
248+
249+ if hpccm .config .g_linux_version >= Version ("26.0" ):
250+ self .__distro_label = "ubuntu2604"
251+ elif hpccm .config .g_linux_version >= Version ("24.0" ):
252+ self .__distro_label = "ubuntu2404"
253+ elif hpccm .config .g_linux_version >= Version ("22.0" ):
254+ self .__distro_label = "ubuntu2204"
217255 else :
218- self .__distro_label = ' ubuntu2004'
256+ self .__distro_label = " ubuntu2004"
219257
220258 elif hpccm .config .g_linux_distro == linux_distro .CENTOS :
221- if hpccm .config .g_linux_version >= Version (' 10.0' ):
222- self .__distro_label = ' rhel10'
223- elif hpccm .config .g_linux_version >= Version (' 9.0' ):
224- self .__distro_label = ' rhel9'
259+ if hpccm .config .g_linux_version >= Version (" 10.0" ):
260+ self .__distro_label = " rhel10"
261+ elif hpccm .config .g_linux_version >= Version (" 9.0" ):
262+ self .__distro_label = " rhel9"
225263 else :
226- self .__distro_label = ' rhel8'
264+ self .__distro_label = " rhel8"
227265
228- else : # pragma: no cover
229- raise RuntimeError (' Unknown Linux distribution' )
266+ else : # pragma: no cover
267+ raise RuntimeError (" Unknown Linux distribution" )
230268
231269 def __download (self ):
232270 """Set download source based on user parameters"""
233271
234272 if not self .__ospackages :
235- self .__ospackages = [' make' , ' wget' ]
273+ self .__ospackages = [" make" , " wget" ]
236274
237275 if hpccm .config .g_linux_distro == linux_distro .CENTOS :
238- self .__ospackages .append (' which' )
276+ self .__ospackages .append (" which" )
239277
240278 if self .repository :
241- self .__ospackages .append (' git' )
279+ self .__ospackages .append (" git" )
242280
243281 # Use the default repository if set to True
244282 if self .repository is True :
245283 self .repository = self .__default_repository
246284
247285 if not self .repository and not self .url :
248- self .url = ' {0}/v{1}.tar.gz' .format (self .__baseurl , self .__version )
286+ self .url = " {0}/v{1}.tar.gz" .format (self .__baseurl , self .__version )
249287
250288 def __repo (self ):
251289 """Based on the Linux distribution and CPU architecture, set values
252290 accordingly. A user specified value overrides any defaults.
253291 """
254292
255- if self .__distro_label .startswith (' ubuntu' ):
256- self .__repo_key = ' 3bf863cc.pub'
257- elif self .__distro_label .startswith (' rhel' ):
258- if hpccm .config .g_linux_version >= Version (' 10.0' ):
259- self .__repo_key = ' CDF6BA43.pub'
293+ if self .__distro_label .startswith (" ubuntu" ):
294+ self .__repo_key = " 3bf863cc.pub"
295+ elif self .__distro_label .startswith (" rhel" ):
296+ if hpccm .config .g_linux_version >= Version (" 10.0" ):
297+ self .__repo_key = " CDF6BA43.pub"
260298 else :
261- self .__repo_key = ' D42D0685.pub'
262- else : # pragma: no cover
263- raise RuntimeError (' Unknown repository' )
299+ self .__repo_key = " D42D0685.pub"
300+ else : # pragma: no cover
301+ raise RuntimeError (" Unknown repository" )
264302
265- def runtime (self , _from = '0' ):
303+ def runtime (self , _from = "0" ):
266304 """Generate the set of instructions to install the runtime specific
267305 components from a build in a previous stage.
268306
@@ -274,19 +312,37 @@ def runtime(self, _from='0'):
274312 Stage1 += n.runtime()
275313 ```
276314 """
277- self .rt += comment (' NCCL' )
315+ self .rt += comment (" NCCL" )
278316 if self .__build :
279317 self .rt += copy (_from = _from , src = self .__prefix , dest = self .__prefix )
280318 self .rt += environment (variables = self .environment_step ())
281319 else :
282320 self .rt += packages (ospackages = self .__ospackages )
283321 self .rt += packages (
284- apt = ['libnccl2={0}+cuda{1}' .format (self .__version ,
285- self .__cuda )],
286- apt_keys = ['https://developer.download.nvidia.com/compute/cuda/repos/{0}/{1}/{2}' .format (self .__distro_label , self .__arch_label , self .__repo_key )],
287- apt_repositories = ['deb [signed-by=/usr/share/keyrings/{2}] https://developer.download.nvidia.com/compute/cuda/repos/{0}/{1} /' .format (self .__distro_label , self .__arch_label , self .__repo_key .replace ('.pub' , '.gpg' ))],
288- yum = ['libnccl-{0}+cuda{1}' .format (self .__version , self .__cuda )],
289- yum_keys = ['https://developer.download.nvidia.com/compute/cuda/repos/{0}/{1}/{2}' .format (self .__distro_label , self .__arch_label , self .__repo_key )],
290- yum_repositories = ['https://developer.download.nvidia.com/compute/cuda/repos/{0}/{1}' .format (self .__distro_label , self .__arch_label )])
322+ apt = ["libnccl2={0}+cuda{1}" .format (self .__version , self .__cuda )],
323+ apt_keys = [
324+ "https://developer.download.nvidia.com/compute/cuda/repos/{0}/{1}/{2}" .format (
325+ self .__distro_label , self .__arch_label , self .__repo_key
326+ )
327+ ],
328+ apt_repositories = [
329+ "deb [signed-by=/usr/share/keyrings/{2}] https://developer.download.nvidia.com/compute/cuda/repos/{0}/{1} /" .format (
330+ self .__distro_label ,
331+ self .__arch_label ,
332+ self .__repo_key .replace (".pub" , ".gpg" ),
333+ )
334+ ],
335+ yum = ["libnccl-{0}+cuda{1}" .format (self .__version , self .__cuda )],
336+ yum_keys = [
337+ "https://developer.download.nvidia.com/compute/cuda/repos/{0}/{1}/{2}" .format (
338+ self .__distro_label , self .__arch_label , self .__repo_key
339+ )
340+ ],
341+ yum_repositories = [
342+ "https://developer.download.nvidia.com/compute/cuda/repos/{0}/{1}" .format (
343+ self .__distro_label , self .__arch_label
344+ )
345+ ],
346+ )
291347
292348 return str (self .rt )
0 commit comments