Skip to content

Commit

Permalink
Merge pull request #3332 from Flamefire/fix-pytorch-build-type
Browse files Browse the repository at this point in the history
Set build type for PyTorch explicitely
  • Loading branch information
ocaisa authored Jul 17, 2024
2 parents 064e3e2 + 7cd6096 commit 0e6e2bb
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions easybuild/easyblocks/p/pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ class EB_PyTorch(PythonPackage):
def extra_options():
extra_vars = PythonPackage.extra_options()
extra_vars.update({
'build_type': [None, "Build type for CMake, e.g. Release."
"Defaults to 'Release' or 'Debug' depending on toolchainopts[debug]", CUSTOM],
'custom_opts': [[], "List of options for the build/install command. Can be used to change the defaults " +
"set by the PyTorch EasyBlock, for example ['USE_MKLDNN=0'].", CUSTOM],
'excluded_tests': [{}, "Mapping of architecture strings to list of tests to be excluded", CUSTOM],
Expand Down Expand Up @@ -407,6 +409,23 @@ def add_enable_option(name, enabled):
# Metal only supported on IOS which likely doesn't work with EB, so disabled
options.append('USE_METAL=0')

build_type = self.cfg.get('build_type')
if build_type is None:
build_type = 'Debug' if self.toolchain.options.get('debug', None) else 'Release'
else:
for name in ('prebuildopts', 'preinstallopts', 'custom_opts'):
if '-DCMAKE_BUILD_TYPE=' in self.cfg[name]:
self.log.warning('CMAKE_BUILD_TYPE is set in %s. Ignoring build_type', name)
build_type = None
if build_type:
if pytorch_version >= '1.2.0':
options.append('CMAKE_BUILD_TYPE=' + build_type)
else:
# Older versions use 2 env variables defaulting to "Release" if none are set
build_type = build_type.lower()
add_enable_option('DEBUG', build_type == 'debug')
add_enable_option('REL_WITH_DEB_INFO', build_type == 'relwithdebinfo')

unique_options = self.cfg['custom_opts']
for option in options:
name = option.split('=')[0] + '=' # Include the equals sign to avoid partial matches
Expand Down

0 comments on commit 0e6e2bb

Please sign in to comment.