From c5a27980df7ca8be7ba9d133c55d4c4de81e1284 Mon Sep 17 00:00:00 2001 From: Maciej Wójcik Date: Thu, 1 Jul 2021 21:04:04 +0200 Subject: 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 --- var/spack/repos/builtin/packages/cuda/package.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/var/spack/repos/builtin/packages/cuda/package.py b/var/spack/repos/builtin/packages/cuda/package.py index 72afffaa9a..8e378ad5f7 100644 --- a/var/spack/repos/builtin/packages/cuda/package.py +++ b/var/spack/repos/builtin/packages/cuda/package.py @@ -133,6 +133,11 @@ class Cuda(Package): return match.group(1) if match else None 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:'): libxml2_home = self.spec['libxml2'].prefix env.set('LIBXML2HOME', libxml2_home) @@ -171,6 +176,18 @@ class Cuda(Package): os.makedirs(os.path.join(prefix, "src")) 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 arguments = [ runfile, # the install script @@ -178,13 +195,15 @@ class Cuda(Package): '--override', # override compiler version checks '--toolkit', # install CUDA Toolkit ] + if spec.satisfies('@10.1:'): arguments.append('--installpath=%s' % prefix) # Where to install else: arguments.append('--verbose') # Verbose log file arguments.append('--toolkitpath=%s' % prefix) # Where to install - install_shell = which('sh') + install_shell(*arguments) + try: os.remove('/tmp/cuda-installer.log') except OSError: -- cgit v1.2.3-60-g2f50