From 2877041a45ba9fb4470c5ae62b182ad33f12dc04 Mon Sep 17 00:00:00 2001 From: deftdawg Date: Sun, 22 Dec 2024 19:08:42 -0500 Subject: [PATCH 1/2] Update RoCM substitutions for tinygrad AMD replaced their hardcoded `/opt/rocm/lib` paths with `ROCM_PATH, '/opt/rocm/'` variables, the old `substituteInPlace` no longer matched the strings and did the substitutions resulting in the libraries not being found at runtime. --- pkgs/development/python-modules/tinygrad/default.nix | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pkgs/development/python-modules/tinygrad/default.nix b/pkgs/development/python-modules/tinygrad/default.nix index d181f339b5b79..7ae30a43b8aab 100644 --- a/pkgs/development/python-modules/tinygrad/default.nix +++ b/pkgs/development/python-modules/tinygrad/default.nix @@ -86,11 +86,10 @@ buildPythonPackage rec { '' + lib.optionalString rocmSupport '' substituteInPlace tinygrad/runtime/autogen/hip.py \ - --replace-fail "/opt/rocm/lib/libamdhip64.so" "${rocmPackages.clr}/lib/libamdhip64.so" \ - --replace-fail "/opt/rocm/lib/libhiprtc.so" "${rocmPackages.clr}/lib/libhiprtc.so" \ + --replace-fail "/opt/rocm/" "${rocmPackages.clr}/" substituteInPlace tinygrad/runtime/autogen/comgr.py \ - --replace-fail "/opt/rocm/lib/libamd_comgr.so" "${rocmPackages.rocm-comgr}/lib/libamd_comgr.so" + --replace-fail "/opt/rocm/" "${rocmPackages.rocm-comgr}/" ''; build-system = [ setuptools ]; From d1d640e33141e8a1693c338a0f73a466b6c124ee Mon Sep 17 00:00:00 2001 From: deftdawg Date: Mon, 23 Dec 2024 11:49:38 -0500 Subject: [PATCH 2/2] Add compiler_hip fixes @wozeparrot's fixes for compiler_hip.py --- pkgs/development/python-modules/tinygrad/default.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkgs/development/python-modules/tinygrad/default.nix b/pkgs/development/python-modules/tinygrad/default.nix index 7ae30a43b8aab..c9bc6325b48d2 100644 --- a/pkgs/development/python-modules/tinygrad/default.nix +++ b/pkgs/development/python-modules/tinygrad/default.nix @@ -88,6 +88,12 @@ buildPythonPackage rec { substituteInPlace tinygrad/runtime/autogen/hip.py \ --replace-fail "/opt/rocm/" "${rocmPackages.clr}/" + substituteInPlace tinygrad/runtime/support/compiler_hip.py \ + --replace-fail "/opt/rocm/include" "${rocmPackages.clr}/include" + + substituteInPlace tinygrad/runtime/support/compiler_hip.py \ + --replace-fail "/opt/rocm/llvm" "${rocmPackages.llvm.llvm}" + substituteInPlace tinygrad/runtime/autogen/comgr.py \ --replace-fail "/opt/rocm/" "${rocmPackages.rocm-comgr}/" '';