Skip to content

Commit eb60d6a

Browse files
authored
Fix permission for triton/backends (#704)
Summary: Some binaries were not executable and as a result, we got some related errors (e.g. below) ``` "/packages/pytorch_latest_sixlib_conda_gb200/conda/lib/python3.12/subprocess.py", line 1955, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) PermissionError: [Errno 13] Permission denied: '/packages/pytorch_latest_sixlib_conda_gb200/conda/lib/python3.12/site-packages/triton/backends/nvidia/bin/ptxas' ``` This PR fixes the permission issues by setting the executable bits for those binaries. Test Plan: We built the conda env with the changes and it was built successfully. D87816077
1 parent c66a976 commit eb60d6a

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

setup.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ def get_thirdparty_packages(packages: list, should_fix_permissions: bool = False
344344
return thirdparty_cmake_args
345345

346346

347-
def download_and_copy(name, src_func, dst_path, variable, version, url_func):
347+
def download_and_copy(name, src_func, dst_path, variable, version, url_func, should_fix_permissions=False):
348348
if is_offline_build():
349349
return
350350
triton_cache_path = get_triton_cache_path()
@@ -359,7 +359,8 @@ def download_and_copy(name, src_func, dst_path, variable, version, url_func):
359359
url = url_func(supported[system], arch, version)
360360
src_path = src_func(supported[system], arch, version)
361361
tmp_path = os.path.join(triton_cache_path, "nvidia", name) # path to cache the download
362-
dst_path = os.path.join(base_dir, "third_party", "nvidia", "backend", dst_path) # final binary path
362+
backend_path = os.path.join(base_dir, "third_party", "nvidia", "backend")
363+
dst_path = os.path.join(backend_path, dst_path) # final binary path
363364
src_path = os.path.join(tmp_path, src_path)
364365
download = not os.path.exists(src_path)
365366
if os.path.exists(dst_path) and system == "Linux" and shutil.which(dst_path) is not None:
@@ -378,6 +379,9 @@ def download_and_copy(name, src_func, dst_path, variable, version, url_func):
378379
else:
379380
shutil.copy(src_path, dst_path)
380381

382+
if should_fix_permissions:
383+
fix_package_permissions(backend_path)
384+
381385

382386
# ---- cmake extension ----
383387

@@ -553,6 +557,7 @@ def download_and_copy_dependencies():
553557
NVIDIA_TOOLCHAIN_VERSION = json.load(nvidia_version_file)
554558

555559
exe_extension = sysconfig.get_config_var("EXE")
560+
triton_override_package_permissions = check_env_flag("TRITON_OVERRIDE_PACKAGE_PERMISSIONS")
556561
download_and_copy(
557562
name="nvcc",
558563
src_func=lambda system, arch, version: f"cuda_nvcc-{system}-{arch}-{version}-archive/bin/ptxas{exe_extension}",
@@ -561,6 +566,7 @@ def download_and_copy_dependencies():
561566
version=NVIDIA_TOOLCHAIN_VERSION["ptxas"],
562567
url_func=lambda system, arch, version:
563568
f"https://developer.download.nvidia.com/compute/cuda/redist/cuda_nvcc/{system}-{arch}/cuda_nvcc-{system}-{arch}-{version}-archive.tar.xz",
569+
should_fix_permissions=triton_override_package_permissions,
564570
)
565571
download_and_copy(
566572
name="cuobjdump",
@@ -571,6 +577,7 @@ def download_and_copy_dependencies():
571577
version=NVIDIA_TOOLCHAIN_VERSION["cuobjdump"],
572578
url_func=lambda system, arch, version:
573579
f"https://developer.download.nvidia.com/compute/cuda/redist/cuda_cuobjdump/{system}-{arch}/cuda_cuobjdump-{system}-{arch}-{version}-archive.tar.xz",
580+
should_fix_permissions=triton_override_package_permissions,
574581
)
575582
download_and_copy(
576583
name="nvdisasm",
@@ -581,6 +588,7 @@ def download_and_copy_dependencies():
581588
version=NVIDIA_TOOLCHAIN_VERSION["nvdisasm"],
582589
url_func=lambda system, arch, version:
583590
f"https://developer.download.nvidia.com/compute/cuda/redist/cuda_nvdisasm/{system}-{arch}/cuda_nvdisasm-{system}-{arch}-{version}-archive.tar.xz",
591+
should_fix_permissions=triton_override_package_permissions,
584592
)
585593
download_and_copy(
586594
name="nvcc",

0 commit comments

Comments
 (0)