未验证 提交 31922692 编写于 作者: G gouzil 提交者: GitHub

[tools] Update summary env (#48627)

* [tools] remove deprecated api , fix macOS get version error

* [tools] Rename the value that returns null

* [tools] add gcc, clang, cmak, libc version

* [tools] fix cudnn read error

* [tools] add gpu devices list, drive based

* [issue] update 3_build-installation-issue.yml

* [tools] fix get gpu list AttributeError
上级 015db48e
...@@ -49,11 +49,16 @@ body: ...@@ -49,11 +49,16 @@ body:
Paddle With CUDA: Paddle With CUDA:
OS: OS:
GCC version:
Clang version:
CMake version:
Libc version:
Python version: Python version:
CUDA version: CUDA version:
cuDNN version: cuDNN version:
Nvidia driver version: Nvidia driver version:
Nvidia driver List:
**************************************** ****************************************
validations: validations:
required: true required: true
......
...@@ -22,11 +22,16 @@ Paddle version: {paddle_version} ...@@ -22,11 +22,16 @@ Paddle version: {paddle_version}
Paddle With CUDA: {paddle_with_cuda} Paddle With CUDA: {paddle_with_cuda}
OS: {os_info} OS: {os_info}
GCC version: {gcc_version}
Clang version: {clang_version}
CMake version: {cmake_version}
Libc version: {libc_version}
Python version: {python_version} Python version: {python_version}
CUDA version: {cuda_version} CUDA version: {cuda_version}
cuDNN version: {cudnn_version} cuDNN version: {cudnn_version}
Nvidia driver version: {nvidia_driver_version} Nvidia driver version: {nvidia_driver_version}
Nvidia driver List: {nvidia_gpu_driver}
""" """
envs = {} envs = {}
...@@ -39,27 +44,64 @@ def get_paddle_info(): ...@@ -39,27 +44,64 @@ def get_paddle_info():
envs['paddle_version'] = paddle.__version__ envs['paddle_version'] = paddle.__version__
envs['paddle_with_cuda'] = paddle.fluid.core.is_compiled_with_cuda() envs['paddle_with_cuda'] = paddle.fluid.core.is_compiled_with_cuda()
except: except:
envs['paddle_version'] = None envs['paddle_version'] = 'N/A'
envs['paddle_with_cuda'] = None envs['paddle_with_cuda'] = 'N/A'
def get_os_info(): def get_os_info():
plat = platform.system()
if platform.system() == "Darwin": if platform.system() == "Darwin":
plat = "macOs" plat = "macOS"
ver = platform.mac_ver()[0] ver = run_shell_command('sw_vers -productVersion').strip('\n')
elif platform.system() == "Linux": elif platform.system() == "Linux":
plat = distro.linux_distribution()[0] plat = distro.id()
ver = distro.linux_distribution()[1] ver = distro.version()
elif platform.system() == "Windows": elif platform.system() == "Windows":
plat = "Windows" plat = "Windows"
ver = platform.win32_ver()[0] ver = platform.win32_ver()[0]
else: else:
plat = None plat = 'N/A'
ver = None ver = 'N/A'
envs['os_info'] = "{0} {1}".format(plat, ver) envs['os_info'] = "{0} {1}".format(plat, ver)
def get_gcc_version():
try:
envs['gcc_version'] = (
run_shell_command("gcc --version").split('\n')[0].split("gcc ")[1]
)
except:
envs['gcc_version'] = 'N/A'
def get_clang_version():
try:
envs['clang_version'] = (
run_shell_command("clang --version")
.split('\n')[0]
.split("clang version ")[1]
)
except:
envs['clang_version'] = 'N/A'
def get_cmake_version():
try:
envs['cmake_version'] = (
run_shell_command("cmake --version")
.split('\n')[0]
.split("cmake ")[1]
)
except:
envs['cmake_version'] = 'N/A'
def get_libc_version():
if platform.system() == "Linux":
envs['libc_version'] = ' '.join(platform.libc_ver())
else:
envs['libc_version'] = 'N/A'
def get_python_info(): def get_python_info():
envs['python_version'] = sys.version.split(' ')[0] envs['python_version'] = sys.version.split(' ')[0]
...@@ -79,7 +121,7 @@ def get_cuda_info(): ...@@ -79,7 +121,7 @@ def get_cuda_info():
if out: if out:
envs['cuda_version'] = out.split('V')[-1].strip() envs['cuda_version'] = out.split('V')[-1].strip()
else: else:
envs['cuda_version'] = None envs['cuda_version'] = 'N/A'
def get_cudnn_info(): def get_cudnn_info():
...@@ -88,7 +130,7 @@ def get_cudnn_info(): ...@@ -88,7 +130,7 @@ def get_cudnn_info():
if out: if out:
return out.split(' ')[-1].strip() return out.split(' ')[-1].strip()
else: else:
return None return 'N/A'
if platform.system() == "Windows": if platform.system() == "Windows":
cudnn_dll_path = run_shell_command('where cudnn*') cudnn_dll_path = run_shell_command('where cudnn*')
...@@ -98,17 +140,21 @@ def get_cudnn_info(): ...@@ -98,17 +140,21 @@ def get_cudnn_info():
) )
cmd = 'type "{0}" | findstr "{1}" | findstr /v "CUDNN_VERSION"' cmd = 'type "{0}" | findstr "{1}" | findstr /v "CUDNN_VERSION"'
else: else:
envs['cudnn_version'] = None envs['cudnn_version'] = 'N/A'
return return
else: else:
cudnn_header_path = run_shell_command( cudnn_header_path = run_shell_command(
'whereis "cudnn.h" | awk \'{print $2}\'' 'whereis "cudnn.h" | awk \'{print $2}\''
) ).strip('\n')
if cudnn_header_path: if cudnn_header_path:
cudnn_header_path = cudnn_header_path.strip()
cmd = 'cat "{0}" | grep "{1}" | grep -v "CUDNN_VERSION"' cmd = 'cat "{0}" | grep "{1}" | grep -v "CUDNN_VERSION"'
if _get_cudnn_ver(cmd.format(cudnn_header_path, 'CUDNN_MAJOR')):
cudnn_header_path = run_shell_command(
'whereis "cudnn_version.h" | awk \'{print $2}\''
).strip('\n')
else: else:
envs['cudnn_version'] = None envs['cudnn_version'] = 'N/A'
return return
major = _get_cudnn_ver(cmd.format(cudnn_header_path, 'CUDNN_MAJOR')) major = _get_cudnn_ver(cmd.format(cudnn_header_path, 'CUDNN_MAJOR'))
...@@ -117,7 +163,10 @@ def get_cudnn_info(): ...@@ -117,7 +163,10 @@ def get_cudnn_info():
cmd.format(cudnn_header_path, 'CUDNN_PATCHLEVEL') cmd.format(cudnn_header_path, 'CUDNN_PATCHLEVEL')
) )
if major != 'N/A':
envs['cudnn_version'] = "{0}.{1}.{2}".format(major, minor, patch_level) envs['cudnn_version'] = "{0}.{1}.{2}".format(major, minor, patch_level)
else:
envs['cudnn_version'] = 'N/A'
def get_driver_info(): def get_driver_info():
...@@ -127,17 +176,37 @@ def get_driver_info(): ...@@ -127,17 +176,37 @@ def get_driver_info():
driver_ver.split('Driver Version:')[1].strip().split(' ')[0] driver_ver.split('Driver Version:')[1].strip().split(' ')[0]
) )
else: else:
driver_ver = None driver_ver = 'N/A'
envs['nvidia_driver_version'] = driver_ver envs['nvidia_driver_version'] = driver_ver
def get_nvidia_gpu_driver():
if platform.system() != "Windows" and platform.system() != "Linux":
envs['nvidia_gpu_driver'] = 'N/A'
return
try:
nvidia_smi = 'nvidia-smi'
gpu_list = run_shell_command(nvidia_smi + " -L")
result = "\n"
for gpu_info in gpu_list.split("\n"):
result += gpu_info.split(" (UUID:")[0] + "\n"
envs['nvidia_gpu_driver'] = result
except:
envs['nvidia_gpu_driver'] = 'N/A'
def main(): def main():
get_paddle_info() get_paddle_info()
get_os_info() get_os_info()
get_gcc_version()
get_clang_version()
get_cmake_version()
get_libc_version()
get_python_info() get_python_info()
get_cuda_info() get_cuda_info()
get_cudnn_info() get_cudnn_info()
get_driver_info() get_driver_info()
get_nvidia_gpu_driver()
print('*' * 40 + envs_template.format(**envs) + '*' * 40) print('*' * 40 + envs_template.format(**envs) + '*' * 40)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册