Skip to content

Commit 48a6d8d

Browse files
Add more info based on feedback
1 parent ec6df1f commit 48a6d8d

1 file changed

Lines changed: 34 additions & 55 deletions

File tree

rapids_cli/debug/debug.py

Lines changed: 34 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"""This module contains the debug subcommand for the Rapids CLI."""
55
import json
66
import platform
7-
import shutil
87
import subprocess
98
import sys
109
from datetime import datetime
@@ -21,14 +20,6 @@
2120
pynvml.nvmlInit()
2221

2322

24-
def gather_nvidia_smi_output():
25-
"""Gather NVIDIA-SMI output."""
26-
try:
27-
return subprocess.run(["nvidia-smi"], capture_output=True, text=True).stdout
28-
except FileNotFoundError:
29-
return "Nvidia-smi not installed"
30-
31-
3223
def gather_cuda_version():
3324
"""Return CUDA driver version as a string, similar to nvidia-smi output."""
3425
version = pynvml.nvmlSystemGetCudaDriverVersion()
@@ -42,29 +33,6 @@ def gather_cuda_version():
4233
return f"{major}.{minor}.{patch}"
4334

4435

45-
def gather_driver_version():
46-
"""Return CUDA driver version as a string, similar to nvidia-smi output."""
47-
return pynvml.nvmlSystemGetDriverVersion()
48-
49-
50-
def gather_pip_packages():
51-
"""Return pip packages."""
52-
try:
53-
return subprocess.check_output(["pip", "freeze"], text=True)
54-
except FileNotFoundError:
55-
return "Pip not installed"
56-
57-
58-
def gather_python_version_full():
59-
"""Return full Python version."""
60-
return sys.version
61-
62-
63-
def gather_python_version():
64-
"""Return Python version."""
65-
return f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}"
66-
67-
6836
def gather_package_versions():
6937
"""Return package version."""
7038
installed_packages = sorted(
@@ -78,26 +46,26 @@ def gather_package_versions():
7846
return package_versions
7947

8048

81-
def gather_conda_packages():
82-
"""Return conda packages."""
49+
def gather_command_output(
50+
command: list[str], fallback_output: str | None = None
51+
) -> str | None:
52+
"""Return command output."""
8353
try:
84-
return subprocess.check_output(["conda", "list"], text=True)
54+
return subprocess.check_output(command, text=True).strip()
8555
except FileNotFoundError:
86-
return "Conda not installed"
87-
88-
89-
def gather_system_ctk():
90-
"""Return system ctk."""
91-
return sorted([str(p) for p in Path("/usr/local").glob("cuda*") if p.is_dir()])
56+
return fallback_output
9257

9358

94-
def gather_package_managers():
95-
"""Return package managers."""
59+
def gather_tools():
60+
"""Return tools."""
9661
return {
97-
"pip": shutil.which("pip") is not None,
98-
"conda": shutil.which("conda") is not None,
99-
"uv": shutil.which("uv") is not None,
100-
"pixi": shutil.which("pixi") is not None,
62+
"pip": gather_command_output(["pip", "--version"]),
63+
"conda": gather_command_output(["conda", "--version"]),
64+
"uv": gather_command_output(["uv", "--version"]),
65+
"pixi": gather_command_output(["pixi", "--version"]),
66+
"g++": gather_command_output(["g++", "--version"]),
67+
"cmake": gather_command_output(["cmake", "--version"]),
68+
"nvcc": gather_command_output(["nvcc", "--version"]),
10169
}
10270

10371

@@ -106,17 +74,28 @@ def run_debug(output_format="console"):
10674
debug_info = {
10775
"date": datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
10876
"platform": platform.platform(),
109-
"nvidia_smi_output": gather_nvidia_smi_output(),
110-
"driver_version": gather_driver_version(),
77+
"nvidia_smi_output": gather_command_output(
78+
["nvidia-smi"], "Nvidia-smi not installed"
79+
),
80+
"driver_version": pynvml.nvmlSystemGetDriverVersion(),
11181
"cuda_version": gather_cuda_version(),
11282
"cuda_runtime_path": cuda.pathfinder.find_nvidia_header_directory("cudart"),
113-
"system_ctk": gather_system_ctk(),
114-
"python_version_full": gather_python_version_full(),
115-
"python_version": gather_python_version(),
83+
"system_ctk": sorted(
84+
[str(p) for p in Path("/usr/local").glob("cuda*") if p.is_dir()]
85+
),
86+
"python_version_full": sys.version,
87+
"python_version": f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}",
11688
"package_versions": gather_package_versions(),
117-
"pip_packages": gather_pip_packages(),
118-
"conda_packages": gather_conda_packages(),
119-
"package_managers": gather_package_managers(),
89+
"pip_packages": gather_command_output(["pip", "freeze"], "Pip not installed"),
90+
"conda_packages": gather_command_output(
91+
["conda", "list"], "Conda not installed"
92+
),
93+
"conda_info": gather_command_output(["conda", "info"], "Conda not installed"),
94+
"tools": gather_tools(),
95+
"os_info": {
96+
v.split("=")[0]: v.split("=")[1].strip('"')
97+
for v in Path("/etc/os-release").read_text().splitlines()
98+
},
12099
}
121100

122101
if output_format == "json":

0 commit comments

Comments
 (0)