diff --git a/install.py b/install.py index 0f210a7fce..b6f497a057 100755 --- a/install.py +++ b/install.py @@ -22,10 +22,32 @@ import shutil import subprocess import sys +from typing import Callable, Optional, Tuple # Flush output on newlines sys.stdout.reconfigure(line_buffering=True) + +class bcolors: + OKGREEN = "\033[92m" + WARNING = "\033[93m" + FAIL = "\033[91m" + ENDC = "\033[0m" + + +CUDA_PATH_ERROR_RE = ( + r"The\s+following\s+variables\s+are\s+used\s+in\s+this\s+project,\s+but" + r"\s+they\s+are\s+set\s+to\s+NOTFOUND.\s+Please\s+set\s+them\s+or\s+make" + r"\s+sure\s+they\s+are\s+set\s+and\s+tested\s+correctly\s+in\s+the\s+CMake" + r"\s+files:\s+CUDA_CUDA_LIBRARY\s+\(ADVANCED" +) + +CUDA_PATH_ERROR_MESSAGE = """ +The most likely error is Legion's FindCUDA failing to find the CUDA libraries. +This can usually be fixed by setting CUDA_PATH in the environment. +For most systems, this will be CUDA_PATH=/usr/local/cuda/lib64/stubs. +""" + os_name = platform.system() if os_name == "Linux": @@ -76,10 +98,21 @@ def __call__(self, parser, namespace, values, option_string): setattr(namespace, self.dest, not option_string.startswith("--no")) -def execute_command(args, verbose, **kwargs): +def execute_command( + args, verbose, suggested_fixes: Optional[Tuple[Callable]] = None, **kwargs +): if verbose: print('Executing: "', " ".join(args), '" with ', kwargs) - subprocess.check_call(args, **kwargs) + try: + output = subprocess.check_output( + args, stderr=subprocess.STDOUT, **kwargs + ).decode("utf-8") + for fix in suggested_fixes: + fix(output) + except subprocess.CalledProcessError as e: + for fix in suggested_fixes: + fix(e.output.decode("utf-8")) + raise def scikit_build_cmake_build_dir(skbuild_dir): @@ -120,6 +153,14 @@ def was_previously_built_with_different_build_isolation( return False +def check_cuda_paths_error(output): + import re + + match = re.compile(CUDA_PATH_ERROR_RE).search(output) + if match: + print(bcolors.FAIL + CUDA_PATH_ERROR_MESSAGE + bcolors.ENDC) + + def install_cunumeric( arch, build_isolation, @@ -359,7 +400,13 @@ def validate_path(path): } ) - execute_command(pip_install_cmd, verbose, cwd=cunumeric_dir, env=cmd_env) + execute_command( + pip_install_cmd, + verbose, + cwd=cunumeric_dir, + env=cmd_env, + suggested_fixes=(check_cuda_paths_error,), + ) def driver():