Spaces:
Build error
Build error
" rather than '
Browse files12 unmodified lines131415161718196 unmodified lines2627282930313213 unmodified lines464748495051525 unmodified lines5859606162636419 unmodified lines848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591604 unmodified lines16516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120212 unmodified linesdef is_rocm_pytorch() -> bool:"""Check whether the PyTorch is compiled on ROCm."""is_rocm = Falseif TORCH_VERSION != 'parrots':try:from torch.utils.cpp_extension import ROCM_HOMEis_rocm = True if ((torch.version.hip is not None) and6 unmodified linesdef get_build_config():"""Obtain the build information of PyTorch or Parrots."""if TORCH_VERSION == 'parrots':from parrots.config import get_build_inforeturn get_build_info()else:13 unmodified linesreturn torch.cuda.is_available()def _get_cuda_home():if TORCH_VERSION == 'parrots':from parrots.utils.build_extension import CUDA_HOMEelse:if is_rocm_pytorch():5 unmodified linesdef _get_musa_home():return os.environ.get('MUSA_HOME')def collect_env():19 unmodified linesfrom distutils import errorsenv_info = OrderedDict()env_info['sys.platform'] = sys.platformenv_info['Python'] = sys.version.replace('\n', '')cuda_available = is_cuda_available()musa_available = is_musa_available()env_info['CUDA available'] = cuda_availableenv_info['MUSA available'] = musa_availableenv_info['numpy_random_seed'] = np.random.get_state()[1][0]if cuda_available:devices = defaultdict(list)for k in range(torch.cuda.device_count()):devices[torch.cuda.get_device_name(k)].append(str(k))for name, device_ids in devices.items():env_info['GPU ' + ','.join(device_ids)] = nameCUDA_HOME = _get_cuda_home()env_info['CUDA_HOME'] = CUDA_HOMEif CUDA_HOME is not None and osp.isdir(CUDA_HOME):if CUDA_HOME == '/opt/rocm':try:nvcc = osp.join(CUDA_HOME, 'hip/bin/hipcc')nvcc = subprocess.check_output(f'"{nvcc}" --version', shell=True)nvcc = nvcc.decode('utf-8').strip()release = nvcc.rfind('HIP version:')build = nvcc.rfind('')nvcc = nvcc[release:build].strip()except subprocess.SubprocessError:nvcc = 'Not Available'else:try:nvcc = osp.join(CUDA_HOME, 'bin/nvcc')nvcc = subprocess.check_output(f'"{nvcc}" -V', shell=True)nvcc = nvcc.decode('utf-8').strip()release = nvcc.rfind('Cuda compilation tools')build = nvcc.rfind('Build ')nvcc = nvcc[release:build].strip()except subprocess.SubprocessError:nvcc = 'Not Available'env_info['NVCC'] = nvccelif musa_available:devices = defaultdict(list)for k in range(torch.musa.device_count()):devices[torch.musa.get_device_name(k)].append(str(k))for name, device_ids in devices.items():env_info['GPU ' + ','.join(device_ids)] = nameMUSA_HOME = _get_musa_home()env_info['MUSA_HOME'] = MUSA_HOMEif MUSA_HOME is not None and osp.isdir(MUSA_HOME):try:mcc = osp.join(MUSA_HOME, 'bin/mcc')subprocess.check_output(f'"{mcc}" -v', shell=True)except subprocess.SubprocessError:mcc = 'Not Available'env_info['mcc'] = mcctry:# Check C++ Compiler.# For Unix-like, sysconfig has 'CC' variable like 'gcc -pthread ...',# indicating the compiler used, we use this to get the compiler nameimport ioimport sysconfigcc = sysconfig.get_config_var('CC')if cc:cc = osp.basename(cc.split()[0])cc_info = subprocess.check_output(f'{cc} --version', shell=True)env_info['GCC'] = cc_info.decode('utf-8').partition('\n')[0].strip()else:# on Windows, cl.exe is not in PATH. We need to find the path.# distutils.ccompiler.new_compiler() returns a msvccompiler4 unmodified linesccompiler = new_compiler()ccompiler.initialize()cc = subprocess.check_output(f'{ccompiler.cc}', stderr=subprocess.STDOUT, shell=True)encoding = os.device_encoding(sys.stdout.fileno()) or locale.getpreferredencoding()env_info['MSVC'] = cc.decode(encoding).partition('\n')[0].strip()env_info['GCC'] = 'n/a'except (subprocess.CalledProcessError, errors.DistutilsPlatformError):env_info['GCC'] = 'n/a'except io.UnsupportedOperation as e:# JupyterLab on Windows changes sys.stdout, which has no `fileno` attr# Refer to: https://github.com/open-mmlab/mmengine/issues/931# TODO: find a solution to get compiler info in Windows JupyterLab,# while preserving backward-compatibility in other systems.env_info['MSVC'] = f'n/a, reason: {str(e)}'env_info['PyTorch'] = torch.__version__env_info['PyTorch compiling details'] = get_build_config()try:import torchvisionenv_info['TorchVision'] = torchvision.__version__except ModuleNotFoundError:passtry:import cv2env_info['OpenCV'] = cv2.__version__except ImportError:passreturn env_infoif __name__ == '__main__':for name, val in collect_env().items():print(f'{name}: {val}')12 unmodified lines131415161718196 unmodified lines2627282930313213 unmodified lines464748495051525 unmodified lines5859606162636419 unmodified lines848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591604 unmodified lines16516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120212 unmodified linesdef is_rocm_pytorch() -> bool:"""Check whether the PyTorch is compiled on ROCm."""is_rocm = Falseif TORCH_VERSION != "parrots":try:from torch.utils.cpp_extension import ROCM_HOMEis_rocm = True if ((torch.version.hip is not None) and6 unmodified linesdef get_build_config():"""Obtain the build information of PyTorch or Parrots."""if TORCH_VERSION == "parrots":from parrots.config import get_build_inforeturn get_build_info()else:13 unmodified linesreturn torch.cuda.is_available()def _get_cuda_home():if TORCH_VERSION == "parrots":from parrots.utils.build_extension import CUDA_HOMEelse:if is_rocm_pytorch():5 unmodified linesdef _get_musa_home():return os.environ.get("MUSA_HOME")def collect_env():19 unmodified linesfrom distutils import errorsenv_info = OrderedDict()env_info["sys.platform"] = sys.platformenv_info["Python"] = sys.version.replace("\n", "")cuda_available = is_cuda_available()musa_available = is_musa_available()env_info["CUDA available"] = cuda_availableenv_info["MUSA available"] = musa_availableenv_info["numpy_random_seed"] = np.random.get_state()[1][0]if cuda_available:devices = defaultdict(list)for k in range(torch.cuda.device_count()):devices[torch.cuda.get_device_name(k)].append(str(k))for name, device_ids in devices.items():env_info["GPU " + ",".join(device_ids)] = nameCUDA_HOME = _get_cuda_home()env_info["CUDA_HOME"] = CUDA_HOMEif CUDA_HOME is not None and osp.isdir(CUDA_HOME):if CUDA_HOME == "/opt/rocm":try:nvcc = osp.join(CUDA_HOME, "hip/bin/hipcc")nvcc = subprocess.check_output(f"\"{nvcc}\" --version", shell=True)nvcc = nvcc.decode("utf-8").strip()release = nvcc.rfind("HIP version:")build = nvcc.rfind("")nvcc = nvcc[release:build].strip()except subprocess.SubprocessError:nvcc = "Not Available"else:try:nvcc = osp.join(CUDA_HOME, "bin/nvcc")nvcc = subprocess.check_output(f"\"{nvcc}\" -V", shell=True)nvcc = nvcc.decode("utf-8").strip()release = nvcc.rfind("Cuda compilation tools")build = nvcc.rfind("Build ")nvcc = nvcc[release:build].strip()except subprocess.SubprocessError:nvcc = "Not Available"env_info["NVCC"] = nvccelif musa_available:devices = defaultdict(list)for k in range(torch.musa.device_count()):devices[torch.musa.get_device_name(k)].append(str(k))for name, device_ids in devices.items():env_info["GPU " + ",".join(device_ids)] = nameMUSA_HOME = _get_musa_home()env_info["MUSA_HOME"] = MUSA_HOMEif MUSA_HOME is not None and osp.isdir(MUSA_HOME):try:mcc = osp.join(MUSA_HOME, "bin/mcc")subprocess.check_output(f"\"{mcc}\" -v", shell=True)except subprocess.SubprocessError:mcc = "Not Available"env_info["mcc"] = mcctry:# Check C++ Compiler.# For Unix-like, sysconfig has 'CC' variable like 'gcc -pthread ...',# indicating the compiler used, we use this to get the compiler nameimport ioimport sysconfigcc = sysconfig.get_config_var("CC")if cc:cc = osp.basename(cc.split()[0])cc_info = subprocess.check_output(f"{cc} --version", shell=True)env_info["GCC"] = cc_info.decode("utf-8").partition("\n")[0].strip()else:# on Windows, cl.exe is not in PATH. We need to find the path.# distutils.ccompiler.new_compiler() returns a msvccompiler4 unmodified linesccompiler = new_compiler()ccompiler.initialize()cc = subprocess.check_output(f"{ccompiler.cc}", stderr=subprocess.STDOUT, shell=True)encoding = os.device_encoding(sys.stdout.fileno()) or locale.getpreferredencoding()env_info["MSVC"] = cc.decode(encoding).partition("\n")[0].strip()env_info["GCC"] = "n/a"except (subprocess.CalledProcessError, errors.DistutilsPlatformError):env_info["GCC"] = "n/a"except io.UnsupportedOperation as e:# JupyterLab on Windows changes sys.stdout, which has no `fileno` attr# Refer to: https://github.com/open-mmlab/mmengine/issues/931# TODO: find a solution to get compiler info in Windows JupyterLab,# while preserving backward-compatibility in other systems.env_info["MSVC"] = f"n/a, reason: {str(e)}"env_info["PyTorch"] = torch.__version__env_info["PyTorch compiling details"] = get_build_config()try:import torchvisionenv_info["TorchVision"] = torchvision.__version__except ModuleNotFoundError:passtry:import cv2env_info["OpenCV"] = cv2.__version__except ImportError:passreturn env_infoif __name__ == "__main__":for name, val in collect_env().items():print(f"{name}: {val}")
utils/collect_env.py+46-46