Skip to content

Commit c6cd398

Browse files
authored
display verbose message when build failed. (#5600)
Issue: When triton build failed, it missed verbose error message display. Fixing: It referenced to `PyTorch` cpp_builder code, to show verbose error message: https://github.com/pytorch/pytorch/blob/2bec68e73b64715354af076ad309335f943e36cd/torch/_inductor/cpp_builder.py#L613-L631 Local validation: After this fixing, it should shows the verbose build fail message: <img width="1105" height="1238" alt="image" src="https://github.com/user-attachments/assets/2af74011-9a95-4f06-a6b4-a0ac0adfd82f" />
1 parent 0e5643b commit c6cd398

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

python/triton/runtime/build.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
import functools
44
import hashlib
55
import importlib.util
6+
import locale
67
import logging
78
import os
89
import shutil
910
import subprocess
11+
import sys
1012
import sysconfig
1113
import tempfile
1214
import re
@@ -16,6 +18,9 @@
1618
from .cache import get_cache_manager
1719
from .. import knobs
1820

21+
_IS_WINDOWS = sys.platform == "win32"
22+
SUBPROCESS_DECODE_ARGS = (locale.getpreferredencoding(), ) if _IS_WINDOWS else ()
23+
1924

2025
def is_xpu():
2126
import torch
@@ -106,7 +111,11 @@ def _build(name: str, src: str, srcdir: str, library_dirs: list[str], include_di
106111
if os.getenv("VERBOSE"):
107112
print(" ".join(cc_cmd))
108113

109-
subprocess.check_call(cc_cmd, stdout=subprocess.DEVNULL)
114+
try:
115+
subprocess.run(cc_cmd, check=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
116+
except subprocess.CalledProcessError as e:
117+
output = e.stdout.decode(*SUBPROCESS_DECODE_ARGS)
118+
raise RuntimeError(output)
110119
return so
111120

112121

0 commit comments

Comments
 (0)