Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set build type for PyTorch explicitely #3332

Merged
merged 3 commits into from
Jul 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading