python3Packages.triton-bin: revisit cuda & rocm patching

This commit is contained in:
Gaetan Lepage
2026-06-07 01:22:45 +02:00
parent f6cb12e27a
commit f012a712b4
+21 -1
View File
@@ -1,12 +1,17 @@
{
lib,
stdenv,
config,
cudaPackages,
buildPythonPackage,
fetchurl,
python,
autoPatchelfHook,
zlib,
rocmPackages,
rocmSupport ? config.rocmSupport,
addDriverRunpath,
}:
buildPythonPackage (finalAttrs: {
@@ -38,10 +43,25 @@ buildPythonPackage (finalAttrs: {
dontStrip = true;
# If this breaks, consider replacing with "${cuda_nvcc}/bin/ptxas"
postFixup = ''
mkdir -p $out/${python.sitePackages}/triton/third_party/cuda/bin/
ln -s ${cudaPackages.cuda_nvcc}/bin/ptxas $out/${python.sitePackages}/triton/third_party/cuda/bin/
''
# Ugly patch to circumvent the heuristic-based search logic of libcuda.so
+ ''
substituteInPlace "${placeholder "out"}/${python.sitePackages}/triton/backends/nvidia/driver.py" \
--replace-fail \
"if env_libcuda_path := knobs.nvidia.libcuda_path:" \
"return '${addDriverRunpath.driverLink}/lib/libcuda.so'" \
--replace-fail \
"return [env_libcuda_path]" \
""
''
+ lib.optionalString rocmSupport ''
substituteInPlace "${placeholder "out"}/${python.sitePackages}/triton/backends/amd/driver.py" \
--replace-fail \
"lib_name = "libamdhip64.so" \
"return '${rocmPackages.clr}/lib/libamdhip64.so'"
'';
meta = {