Added Perl workaround for CUDA <= 8 (#24291)

* Added Perl workaround for CUDA <= 8
* Re-wrapped comment
* Proofreading corrections
* Added a reference
* Do not override Perl include path
* Retrieve shell once

Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
This commit is contained in:
Maciej Wójcik 2021-07-01 21:04:04 +02:00 committed by GitHub
parent 406117148d
commit c5a27980df
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -133,6 +133,11 @@ def determine_version(cls, exe):
return match.group(1) if match else None return match.group(1) if match else None
def setup_build_environment(self, env): def setup_build_environment(self, env):
if self.spec.satisfies('@:8.0.61'):
# Perl 5.26 removed current directory from module search path,
# CUDA 9 has a fix for this, but CUDA 8 and lower don't.
env.append_path('PERL5LIB', self.stage.source_path)
if self.spec.satisfies('@10.1.243:'): if self.spec.satisfies('@10.1.243:'):
libxml2_home = self.spec['libxml2'].prefix libxml2_home = self.spec['libxml2'].prefix
env.set('LIBXML2HOME', libxml2_home) env.set('LIBXML2HOME', libxml2_home)
@ -171,6 +176,18 @@ def install(self, spec, prefix):
os.makedirs(os.path.join(prefix, "src")) os.makedirs(os.path.join(prefix, "src"))
os.symlink(includedir, os.path.join(prefix, "include")) os.symlink(includedir, os.path.join(prefix, "include"))
install_shell = which('sh')
if self.spec.satisfies('@:8.0.61'):
# Perl 5.26 removed current directory from module search path.
# We are addressing this by exporting `PERL5LIB` earlier, but for some
# reason, it is not enough. One more file needs to be extracted before
# running the actual installer. This solution is one of the commonly
# found on the Internet, when people try to install CUDA <= 8 manually.
# For example: https://askubuntu.com/a/1087842
arguments = [runfile, '--tar', 'mxvf', './InstallUtils.pm']
install_shell(*arguments)
# CUDA 10.1+ has different cmdline options for the installer # CUDA 10.1+ has different cmdline options for the installer
arguments = [ arguments = [
runfile, # the install script runfile, # the install script
@ -178,13 +195,15 @@ def install(self, spec, prefix):
'--override', # override compiler version checks '--override', # override compiler version checks
'--toolkit', # install CUDA Toolkit '--toolkit', # install CUDA Toolkit
] ]
if spec.satisfies('@10.1:'): if spec.satisfies('@10.1:'):
arguments.append('--installpath=%s' % prefix) # Where to install arguments.append('--installpath=%s' % prefix) # Where to install
else: else:
arguments.append('--verbose') # Verbose log file arguments.append('--verbose') # Verbose log file
arguments.append('--toolkitpath=%s' % prefix) # Where to install arguments.append('--toolkitpath=%s' % prefix) # Where to install
install_shell = which('sh')
install_shell(*arguments) install_shell(*arguments)
try: try:
os.remove('/tmp/cuda-installer.log') os.remove('/tmp/cuda-installer.log')
except OSError: except OSError: