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

Add support for including PTX code in PyTorch #2328

Closed
wants to merge 8 commits into from
20 changes: 18 additions & 2 deletions easybuild/easyblocks/p/pytorch.py
Expand Up @@ -51,7 +51,9 @@ def extra_options():
extra_vars.update({
'excluded_tests': [{}, 'Mapping of architecture strings to list of tests to be excluded', 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]
'set by the PyTorch EasyBlock, for example ["USE_MKLDNN=0"].', CUSTOM],
'ptx': ['last', 'For which compute architectures PTX code should be generated. Can be '
'"first", "last", None or any PyTorch supported arch, e.g. "3.7"', CUSTOM],
})
extra_vars['download_dep_fail'][0] = True
extra_vars['sanity_pip_check'][0] = True
Expand Down Expand Up @@ -193,8 +195,22 @@ def configure_step(self):
raise EasyBuildError('List of CUDA compute capabilities must be specified, either via '
'cuda_compute_capabilities easyconfig parameter or via '
'--cuda-compute-capabilities')
ptx = self.cfg['ptx']
cuda_cc = cuda_cc[:] # Don't modify original list
if ptx == 'last':
cuda_cc[-1] += '+PTX'
elif ptx == 'first':
cuda_cc[0] += '+PTX'
elif ptx is not None:
if ptx in cuda_cc:
cuda_cc.remove(ptx)
cuda_cc.append(ptx + '+PTX')

self.log.info('Compiling with specified list of CUDA compute capabilities: %s', ', '.join(cuda_cc))
options.append('TORCH_CUDA_ARCH_LIST="%s"' % ';'.join(cuda_cc))
# This variable is also used at runtime (e.g. for tests) and if it is not set PyTorch will automatically
# determine the compute capability of a GPU in the system and use that which may fail tests if
# it is to new for the used nvcc
env.setvar('TORCH_CUDA_ARCH_LIST', ';'.join(cuda_cc))
else:
# Disable CUDA
options.append('USE_CUDA=0')
Expand Down