def test_show_config(self): with mock.patch('sys.stdout.write') as write_func: cupy.show_config() write_func.assert_called_once_with(str(cupyx.get_runtime_info()))
print('testing CuPy...') import cupy as cp print('CuPy version: ' + str(cp.__version__)) print(cp.show_config()) print('running CuPy GPU array test...') x_gpu = cp.array([1, 2, 3]) print(x_gpu) l2_gpu = cp.linalg.norm(x_gpu) print(l2_gpu) print('done CuPy GPU array test') print('CuPy OK\n')
#!/usr/bin/env python if __name__ != '__main__': raise Exception("Do not import me!") import chainer print(f"Chainer version: {chainer.__version__}") try: import cupy cupy.show_config() except Exception as e: print("cupy could not be imported! Do you work in NVIDIA environment?!") pass
def main(): ### Environment header('Environment') report('Current Directory', os.getcwd()) for (k, v) in os.environ.items(): if k.startswith('LD_') or k.startswith('DYLD_'): report('${}'.format(k), v) ### CuPy header('CuPy') cupy = None (cupy_status, cudnn_status, nccl_status) = ('N/A', 'N/A', 'N/A') cudart_version = None try: import cupy cupy_status = 'OK' cudart_version = cupy.cuda.runtime.runtimeGetVersion() try: import cupy.cuda.cudnn cudnn_status = 'OK' except Exception as e: cudnn_status = 'failed (optional) ({})'.format(repr(e)) try: import cupy.cuda.nccl nccl_status = 'OK' except Exception as e: nccl_status = 'failed (optional) ({})'.format(repr(e)) except Exception as e: cupy_status = 'failed ({})'.format(repr(e)) report('Available', cupy_status) if cupy is not None: report('Available (cuDNN)', cudnn_status) report('Available (NCCL)', nccl_status) if hasattr(cupy, 'show_config'): report('show_config API', 'Available') print('') cupy.show_config() print('') else: report('show_config API', 'Not Available (optional) (requires v4.0.0+)') builtins = get_cdll('nvrtc-builtins') if builtins is None: report('NVRTC Builtins', 'Not Found') else: builtins_path = get_cdll_path(builtins.getArchBuiltins) report('NVRTC Builtins', 'Found ({})'.format(builtins_path)) try: cupy.cuda.compiler.compile_using_nvrtc('') cupy_compile = 'OK' except Exception as e: cupy_compile = 'failed ({})'.format(repr(e)) report('NVRTC Test', cupy_compile) ### Python Modules header('Python Modules') def _report_pypkg(name, modname, pkg): import_msg = None try: mod = __import__(modname) version = '(unknown version)' if hasattr(mod, '__version__'): version = mod.__version__ import_msg = 'importing {} from {}'.format(version, mod.__path__) except Exception as e: import_msg = 'import failed with {}: {}'.format( type(e).__name__, str(e)) install_msg = 'not installed' if pkg is not None: install_msg = 'OK ({} version {} from {})'.format( pkg.project_name, pkg.version, pkg.location) status = '{} ({})'.format(install_msg, import_msg) report(name, status) # Chainer _report_pypkg('Chainer', 'chainer', get_package('chainer')) # CuPy cupy_pkgs = [ ('cupy', lambda v: 7000 <= v < 10000), ('cupy-cuda80', lambda v: 8000 <= v < 9000), ('cupy-cuda90', lambda v: 9000 <= v < 9010), ('cupy-cuda91', lambda v: 9010 <= v < 9020), ('cupy-cuda92', lambda v: 9020 <= v < 9030), ] cupy_found = None for (pkgname, is_cuda_version_supported) in cupy_pkgs: pkg = get_package(pkgname) if pkg is not None: _report_pypkg('CuPy', 'cupy', pkg) if (cudart_version is not None and not is_cuda_version_supported(cudart_version)): print('*** ERROR: This CuPy package ({}) does not support ' 'CUDA version {}!'.format(pkgname, cudart_version)) if cupy_found is not None: print('*** ERROR: multiple CuPy packages are installed! ' 'You can only install one of {}.'''.format( [x[0] for x in cupy_pkgs])) cupy_found = pkg if cupy_found is None: _report_pypkg('CuPy', 'cupy', None) # NumPy _report_pypkg('NumPy', 'numpy', get_package('numpy')) # iDeep _report_pypkg('iDeep', 'ideep4py', get_package('ideep4py'))