Skip to content

Commit c016f71

Browse files
authored
[BUILD] Check cache version instead of destination (#802)
Check the cached binary version in ~/.triton rather than the already-installed binary in third_party/nvidia/backend/. This avoids unnecessary re-downloads when the cache is valid but the destination differs.
1 parent d438598 commit c016f71

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

python/setup.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -349,11 +349,14 @@ def download_and_copy(name, src_func, dst_path, variable, version, url_func):
349349
dst_path = os.path.join(base_dir, os.pardir, "third_party", "nvidia", "backend", dst_path) # final binary path
350350
src_path = os.path.join(tmp_path, src_path)
351351
download = not os.path.exists(src_path)
352-
if os.path.exists(dst_path) and system == "Linux" and shutil.which(dst_path) is not None:
353-
curr_version = subprocess.check_output([dst_path, "--version"]).decode("utf-8").strip()
354-
curr_version = re.search(r"V([.|\d]+)", curr_version)
355-
assert curr_version is not None, f"No version information for {dst_path}"
356-
download = download or curr_version.group(1) != version
352+
# flagtree: check the cached binary version in ~/.triton, skip download if it matches
353+
if os.path.exists(src_path) and system == "Linux" and shutil.which(src_path) is not None:
354+
try:
355+
cache_version = subprocess.check_output([src_path, "--version"]).decode("utf-8").strip()
356+
cache_version = re.search(r"V([.|\d]+)", cache_version).group(1)
357+
download = download or cache_version != version
358+
except Exception:
359+
download = True
357360
if download and not is_offline_build():
358361
print(f'{YELLOW}downloading and extracting {url} ... {NC}', file=sys.stderr, flush=True)
359362
file = tarfile.open(fileobj=open_url(url), mode="r|*")

0 commit comments

Comments
 (0)