Skip to content

Commit b1a46d3

Browse files
authored
Merge pull request #3161 from boegel/cuda_compute_capabilities
add --cuda-compute-capabilities configuration option
2 parents e4e02fb + 3b838fb commit b1a46d3

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

easybuild/tools/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ def mk_full_default_path(name, prefix=DEFAULT_PREFIX):
159159
'container_image_name',
160160
'container_template_recipe',
161161
'container_tmpdir',
162+
'cuda_compute_capabilities',
162163
'download_timeout',
163164
'dump_test_report',
164165
'easyblock',

easybuild/tools/options.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,8 @@ def override_options(self):
343343
'consider-archived-easyconfigs': ("Also consider archived easyconfigs", None, 'store_true', False),
344344
'containerize': ("Generate container recipe/image", None, 'store_true', False, 'C'),
345345
'copy-ec': ("Copy specified easyconfig(s) to specified location", None, 'store_true', False),
346+
'cuda-compute-capabilities': ("List of CUDA compute capabilities to use when building GPU software",
347+
'strlist', 'extend', None),
346348
'debug-lmod': ("Run Lmod modules tool commands in debug module", None, 'store_true', False),
347349
'default-opt-level': ("Specify default optimisation level", 'choice', 'store', DEFAULT_OPT_LEVEL,
348350
Compiler.COMPILER_OPT_FLAGS),
@@ -760,6 +762,15 @@ def validate(self):
760762
msg = "Selected module naming scheme '%s' is unknown: %s" % (self.options.module_naming_scheme, avail_mnss)
761763
error_msgs.append(msg)
762764

765+
# values passed to --cuda-compute-capabilities must be of form X.Y (with both X and Y integers),
766+
# see https://developer.nvidia.com/cuda-gpus
767+
if self.options.cuda_compute_capabilities:
768+
cuda_cc_regex = re.compile(r'^[0-9]+\.[0-9]+$')
769+
faulty_cuda_ccs = [x for x in self.options.cuda_compute_capabilities if not cuda_cc_regex.match(x)]
770+
if faulty_cuda_ccs:
771+
error_msg = "Incorrect values in --cuda-compute-capabilities (expected pattern: '%s'): %s"
772+
error_msgs.append(error_msg % (cuda_cc_regex.pattern, ', '.join(faulty_cuda_ccs)))
773+
763774
if error_msgs:
764775
raise EasyBuildError("Found problems validating the options: %s", '\n'.join(error_msgs))
765776

test/framework/options.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4668,6 +4668,14 @@ def test_sort_looseversions(self):
46684668
(ver5, suff3), (ver4, suff1), (ver4, suff3), (ver6, suff2)]
46694669
self.assertEqual(sort_looseversions(input), expected)
46704670

4671+
def test_cuda_compute_capabilities(self):
4672+
"""Test --cuda-compute-capabilities configuration option."""
4673+
args = ['--cuda-compute-capabilities=3.5,6.2,7.0', '--show-config']
4674+
txt, _ = self._run_mock_eb(args, do_build=True, raise_error=True, testing=False, strip=True)
4675+
4676+
regex = re.compile(r"^cuda-compute-capabilities\s*\(C\)\s*=\s*3\.5, 6\.2, 7\.0$", re.M)
4677+
self.assertTrue(regex.search(txt), "Pattern '%s' not found in: %s" % (regex.pattern, txt))
4678+
46714679

46724680
def suite():
46734681
""" returns all the testcases in this module """

0 commit comments

Comments
 (0)