Skip to content

Commit 6fb6293

Browse files
Revert "Add Intel GPU info collection to the collect env script (pytorch#137846)"
This reverts commit c6b4f98. Reverted pytorch#137846 on behalf of https://github.com/etaf due to This is breaking tests on xpu, detail log: https://hud.pytorch.org/pr/pytorch/pytorch/154962#43700962849 ([comment](pytorch#137846 (comment)))
1 parent be2ad70 commit 6fb6293

File tree

1 file changed

+4
-182
lines changed

1 file changed

+4
-182
lines changed

torch/utils/collect_env.py

Lines changed: 4 additions & 182 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import subprocess
1111
import sys
1212
import os
13-
from typing import cast as _cast
1413
from collections import namedtuple
1514

1615

@@ -38,7 +37,6 @@
3837
'nvidia_driver_version',
3938
'nvidia_gpu_models',
4039
'cudnn_version',
41-
'is_xpu_available',
4240
'pip_version', # 'pip' or 'pip3'
4341
'pip_packages',
4442
'conda_packages',
@@ -75,30 +73,6 @@
7573
"nvtx",
7674
]
7775

78-
ONEAPI_PATTERNS = [
79-
"dpcpp-cpp-rt",
80-
"intel-cmplr-lib-rt",
81-
"intel-cmplr-lib-ur",
82-
"intel-cmplr-lic-rt",
83-
"intel-opencl-rt",
84-
"intel-sycl-rt",
85-
"mkl",
86-
"onemkl-sycl-blas",
87-
"onemkl-sycl-dft",
88-
"onemkl-sycl-lapack",
89-
"onemkl-sycl-rng",
90-
"onemkl-sycl-sparse",
91-
"intel-openmp",
92-
"tbb",
93-
"impi-rt",
94-
"impi-devel",
95-
"oneccl",
96-
"oneccl-devel",
97-
"intel-pti",
98-
"umf",
99-
"tcmlib",
100-
]
101-
10276
CONDA_PATTERNS = [
10377
"cudatoolkit",
10478
"soumith",
@@ -157,7 +131,7 @@ def run_and_return_first_line(run_lambda, command):
157131

158132
def get_conda_packages(run_lambda, patterns=None):
159133
if patterns is None:
160-
patterns = CONDA_PATTERNS + COMMON_PATTERNS + NVIDIA_PATTERNS + ONEAPI_PATTERNS
134+
patterns = CONDA_PATTERNS + COMMON_PATTERNS + NVIDIA_PATTERNS
161135
conda = os.environ.get('CONDA_EXE', 'conda')
162136
out = run_and_read_all(run_lambda, "{} list".format(conda))
163137
if out is None:
@@ -269,149 +243,6 @@ def get_nvidia_smi():
269243
return smi
270244

271245

272-
def _detect_linux_pkg_manager():
273-
if get_platform() != "linux":
274-
return "N/A"
275-
for mgr_name in ["dpkg", "dnf", "yum", "zypper"]:
276-
rc, _, _ = run(f"which {mgr_name}")
277-
if rc == 0:
278-
return mgr_name
279-
return "N/A"
280-
281-
282-
def get_linux_pkg_version(run_lambda, pkg_name):
283-
pkg_mgr = _detect_linux_pkg_manager()
284-
if pkg_mgr == "N/A":
285-
return "N/A"
286-
287-
grep_version = {
288-
"dpkg": {
289-
"field_index": 2,
290-
"command": "dpkg -l | grep {}",
291-
},
292-
"dnf": {
293-
"field_index": 1,
294-
"command": "dnf list | grep {}",
295-
},
296-
"yum": {
297-
"field_index": 1,
298-
"command": "yum list | grep {}",
299-
},
300-
"zypper": {
301-
"field_index": 2,
302-
"command": "zypper info {} | grep Version",
303-
},
304-
}
305-
306-
field_index: int = int(_cast(int, grep_version[pkg_mgr]["field_index"]))
307-
cmd: str = str(grep_version[pkg_mgr]["command"])
308-
cmd = cmd.format(pkg_name)
309-
ret = run_and_read_all(run_lambda, cmd)
310-
if ret == "":
311-
return "N/A"
312-
lst = re.sub(" +", " ", ret).split(" ")
313-
if len(lst) <= field_index:
314-
return "N/A"
315-
return lst[field_index]
316-
317-
318-
def get_intel_gpu_driver_version(run_lambda):
319-
lst = []
320-
platform = get_platform()
321-
if platform == "linux":
322-
pkgs = { # type: ignore[var-annotated]
323-
"dpkg": {
324-
"intel-opencl-icd",
325-
"libze1",
326-
},
327-
"dnf": {
328-
"intel-opencl",
329-
"level-zero",
330-
},
331-
"yum": {
332-
"intel-opencl",
333-
"level-zero",
334-
},
335-
"zypper": {
336-
"intel-opencl",
337-
"level-zero",
338-
},
339-
}.get(_detect_linux_pkg_manager(), {})
340-
for pkg in pkgs:
341-
lst.append(f"* {pkg}:\t{get_linux_pkg_version(run_lambda, pkg)}")
342-
if platform in ["win32", "cygwin"]:
343-
txt = run_and_read_all(
344-
run_lambda,
345-
'powershell.exe "gwmi -Class Win32_PnpSignedDriver | where{$_.DeviceClass -eq \\"DISPLAY\\"\
346-
-and $_.Manufacturer -match \\"Intel\\"} | Select-Object -Property DeviceName,DriverVersion,DriverDate\
347-
| ConvertTo-Json"',
348-
)
349-
try:
350-
obj = json.loads(txt)
351-
if type(obj) is list:
352-
for o in obj:
353-
lst.append(
354-
f'* {o["DeviceName"]}: {o["DriverVersion"]} ({o["DriverDate"]})'
355-
)
356-
else:
357-
lst.append(f'* {obj["DriverVersion"]} ({obj["DriverDate"]})')
358-
except ValueError as e:
359-
lst.append(txt)
360-
lst.append(str(e))
361-
return "\n".join(lst)
362-
363-
364-
def get_intel_gpu_onboard(run_lambda):
365-
lst: list[str] = []
366-
platform = get_platform()
367-
if platform == "linux":
368-
txt = run_and_read_all(run_lambda, "xpu-smi discovery -j")
369-
if txt:
370-
try:
371-
obj = json.loads(txt)
372-
device_list = obj.get("device_list", [])
373-
if isinstance(device_list, list) and device_list:
374-
lst.extend(f'* {device["device_name"]}' for device in device_list)
375-
else:
376-
lst.append("N/A")
377-
except (ValueError, TypeError) as e:
378-
lst.append(txt)
379-
lst.append(str(e))
380-
else:
381-
lst.append("N/A")
382-
if platform in ["win32", "cygwin"]:
383-
txt = run_and_read_all(
384-
run_lambda,
385-
'powershell.exe "gwmi -Class Win32_PnpSignedDriver | where{$_.DeviceClass -eq \\"DISPLAY\\"\
386-
-and $_.Manufacturer -match \\"Intel\\"} | Select-Object -Property DeviceName | ConvertTo-Json"',
387-
)
388-
if txt:
389-
try:
390-
obj = json.loads(txt)
391-
if isinstance(obj, list) and obj:
392-
lst.extend(f'* {device["DeviceName"]}' for device in obj)
393-
else:
394-
lst.append(f'* {obj.get("DeviceName", "N/A")}')
395-
except ValueError as e:
396-
lst.append(txt)
397-
lst.append(str(e))
398-
else:
399-
lst.append("N/A")
400-
return "\n".join(lst)
401-
402-
403-
def get_intel_gpu_detected(run_lambda):
404-
if not TORCH_AVAILABLE or not hasattr(torch, "xpu"):
405-
return "N/A"
406-
407-
device_count = torch.xpu.device_count()
408-
if device_count == 0:
409-
return "N/A"
410-
411-
devices = [f"* [{i}] {torch.xpu.get_device_properties(i)}" for i in range(device_count)]
412-
return "\n".join(devices)
413-
414-
415246
# example outputs of CPU infos
416247
# * linux
417248
# Architecture: x86_64
@@ -565,7 +396,7 @@ def get_os(run_lambda):
565396
from platform import machine
566397
platform = get_platform()
567398

568-
if platform in ["win32", "cygwin"]:
399+
if platform == 'win32' or platform == 'cygwin':
569400
return get_windows_version(run_lambda)
570401

571402
if platform == 'darwin':
@@ -606,7 +437,7 @@ def get_libc_version():
606437
def get_pip_packages(run_lambda, patterns=None):
607438
"""Return `pip list` output. Note: will also find conda-installed pytorch and numpy packages."""
608439
if patterns is None:
609-
patterns = PIP_PATTERNS + COMMON_PATTERNS + NVIDIA_PATTERNS + ONEAPI_PATTERNS
440+
patterns = PIP_PATTERNS + COMMON_PATTERNS + NVIDIA_PATTERNS
610441

611442
pip_version = 'pip3' if sys.version_info.major == 3 else 'pip'
612443

@@ -673,13 +504,6 @@ def get_env_info():
673504
debug_mode_str = str(torch.version.debug)
674505
cuda_available_str = str(torch.cuda.is_available())
675506
cuda_version_str = torch.version.cuda
676-
xpu_available_str = str(torch.xpu.is_available())
677-
if torch.xpu.is_available():
678-
xpu_available_str = f'{xpu_available_str}\n' + \
679-
f'XPU used to build PyTorch: {torch.version.xpu}\n' + \
680-
f'Intel GPU driver version:\n{get_intel_gpu_driver_version(run_lambda)}\n' + \
681-
f'Intel GPU models onboard:\n{get_intel_gpu_onboard(run_lambda)}\n' + \
682-
f'Intel GPU models detected:\n{get_intel_gpu_detected(run_lambda)}'
683507
if not hasattr(torch.version, 'hip') or torch.version.hip is None: # cuda version
684508
hip_compiled_version = hip_runtime_version = miopen_runtime_version = 'N/A'
685509
else: # HIP version
@@ -693,7 +517,7 @@ def get_version_or_na(cfg, prefix):
693517
cuda_version_str = 'N/A'
694518
hip_compiled_version = torch.version.hip
695519
else:
696-
version_str = debug_mode_str = cuda_available_str = cuda_version_str = xpu_available_str = 'N/A'
520+
version_str = debug_mode_str = cuda_available_str = cuda_version_str = 'N/A'
697521
hip_compiled_version = hip_runtime_version = miopen_runtime_version = 'N/A'
698522

699523
sys_version = sys.version.replace("\n", " ")
@@ -712,7 +536,6 @@ def get_version_or_na(cfg, prefix):
712536
nvidia_gpu_models=get_gpu_info(run_lambda),
713537
nvidia_driver_version=get_nvidia_driver_version(run_lambda),
714538
cudnn_version=get_cudnn_version(run_lambda),
715-
is_xpu_available=xpu_available_str,
716539
hip_compiled_version=hip_compiled_version,
717540
hip_runtime_version=hip_runtime_version,
718541
miopen_runtime_version=miopen_runtime_version,
@@ -749,7 +572,6 @@ def get_version_or_na(cfg, prefix):
749572
GPU models and configuration: {nvidia_gpu_models}
750573
Nvidia driver version: {nvidia_driver_version}
751574
cuDNN version: {cudnn_version}
752-
Is XPU available: {is_xpu_available}
753575
HIP runtime version: {hip_runtime_version}
754576
MIOpen runtime version: {miopen_runtime_version}
755577
Is XNNPACK available: {is_xnnpack_available}

0 commit comments

Comments
 (0)