MCPcopy Create free account
hub / github.com/InternLM/InternBootcamp / _get_gpu_info

Function _get_gpu_info

verl/scripts/diagnose.py:216–241  ·  view source on GitHub ↗

Get GPU type, GPU memory, and GPU count using nvidia-smi command.

()

Source from the content-addressed store, hash-verified

214
215
216def _get_gpu_info():
217 """
218 Get GPU type, GPU memory, and GPU count using nvidia-smi command.
219 """
220 try:
221 result = subprocess.run(
222 ["nvidia-smi", "--query-gpu=gpu_name,memory.total", "--format=csv,noheader,nounits"],
223 capture_output=True,
224 text=True,
225 check=True,
226 )
227 gpu_lines = result.stdout.strip().split("\n")
228 gpu_count = len(gpu_lines)
229 gpu_info = []
230 for line in gpu_lines:
231 gpu_name, gpu_memory = line.split(", ")
232 gpu_info.append(
233 {
234 "type": gpu_name,
235 "memory": float(gpu_memory) / 1024, # Convert to GB
236 }
237 )
238 return gpu_count, gpu_info
239 except (subprocess.CalledProcessError, FileNotFoundError):
240 print("Failed to execute nvidia-smi command.")
241 return 0, []
242
243
244def _get_system_info():

Callers 1

_get_system_infoFunction · 0.85

Calls 3

appendMethod · 0.80
runMethod · 0.45
splitMethod · 0.45

Tested by

no test coverage detected