(abort=False)
return True
Return True if check pass; if check fails and abort is True,
    raise an Exception, othereise return False.
Return True if check pass; if check fails and abort is True,
    raise an Exception, othereise return False.
Return True if check pass ; if check fails and abort is True raise an Exception othereise return False .
def check_sru_requirement(abort=False):
    """
    Return True if check pass; if check fails and abort is True,
    raise an Exception, othereise return False.
    """

    # Check 1.
    try:
        if platform.system() == 'Windows':
            subprocess.check_output('pip freeze | findstr cupy', shell=True)
            subprocess.check_output('pip freeze | findstr pynvrtc',
                                    shell=True)
        else:  # Unix-like systems
            subprocess.check_output('pip freeze | grep -w cupy', shell=True)
            subprocess.check_output('pip freeze | grep -w pynvrtc',
                                    shell=True)
    except subprocess.CalledProcessError:
        if not abort:
            return False
        raise AssertionError("Using SRU requires 'cupy' and 'pynvrtc' "
                             "python packages installed.")

    # Check 2.
    if torch.cuda.is_available() is False:
        if not abort:
            return False
        raise AssertionError("Using SRU requires pytorch built with cuda.")

    # Check 3.
    pattern = re.compile(".*cuda/lib.*")
    ld_path = os.getenv('LD_LIBRARY_PATH', "")
    if re.match(pattern, ld_path) is None:
        if not abort:
            return False
        raise AssertionError("Using SRU requires setting cuda lib path, e.g. "
                             "export LD_LIBRARY_PATH=/usr/local/cuda/lib64.")

    return True
def check_sru_requirement ( abort = False ) : # Check 1. try : if platform . system ( ) == 'Windows' : subprocess . check_output ( 'pip freeze | findstr cupy' , shell = True ) subprocess . check_output ( 'pip freeze | findstr pynvrtc' , shell = True ) else : # Unix-like systems subprocess . check_output ( 'pip freeze | grep -w cupy' , shell = True ) subprocess . check_output ( 'pip freeze | grep -w pynvrtc' , shell = True ) except subprocess . CalledProcessError : if not abort : return False raise AssertionError ( "Using SRU requires 'cupy' and 'pynvrtc' " "python packages installed." ) # Check 2. if torch . cuda . is_available ( ) is False : if not abort : return False raise AssertionError ( "Using SRU requires pytorch built with cuda." ) # Check 3. pattern = re . compile ( ".*cuda/lib.*" ) ld_path = os . getenv ( 'LD_LIBRARY_PATH' , "" ) if re . match ( pattern , ld_path ) is None : if not abort : return False raise AssertionError ( "Using SRU requires setting cuda lib path, e.g. " "export LD_LIBRARY_PATH=/usr/local/cuda/lib64." ) return True