diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3c825dd6f1..4615f77857 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -412,6 +412,11 @@ jobs: curl -s https://api.github.com/repos/Qazalin/remu/releases/latest | \ jq -r '.assets[] | select(.name == "libremu.so").browser_download_url' | \ sudo xargs curl -L -o /usr/local/lib/libremu.so + sudo tee --append /etc/ld.so.conf.d/rocm.conf <<'EOF' + /opt/rocm/lib + /opt/rocm/lib64 + EOF + sudo ldconfig - name: Install dependencies run: pip install -e '.[testing${{matrix.backend=='llvm'&&',llvm'||matrix.backend=='ptx'&&',cuda'||matrix.backend=='triton'&&',triton'||''}}]' --extra-index-url https://download.pytorch.org/whl/cpu --extra-index-url https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/Triton-Nightly/pypi/simple/ - name: Check Device.DEFAULT and print some source diff --git a/autogen_stubs.sh b/autogen_stubs.sh index c947dc7ccc..5b8f1e2169 100755 --- a/autogen_stubs.sh +++ b/autogen_stubs.sh @@ -51,8 +51,8 @@ generate_comgr() { clang2py /opt/rocm/include/amd_comgr/amd_comgr.h \ --clang-args="-D__HIP_PLATFORM_AMD__ -I/opt/rocm/include -x c++" -o $BASE/comgr.py -l /opt/rocm/lib/libamd_comgr.so fixup $BASE/comgr.py - sed -i "s\import ctypes\import ctypes, os\g" $BASE/comgr.py - sed -i "s\'/opt/rocm/\os.getenv('ROCM_PATH', '/opt/rocm/')+'/\g" $BASE/comgr.py + sed -i "s\import ctypes\import ctypes, ctypes.util, os\g" $BASE/comgr.py + sed -i "s\ctypes.CDLL('/opt/rocm/lib/libamd_comgr.so')\ctypes.CDLL(os.getenv('ROCM_PATH')+'/lib/libamd_comgr.so' if os.getenv('ROCM_PATH') else ctypes.util.find_library('amd_comgr'))\g" $BASE/comgr.py python3 -c "import tinygrad.runtime.autogen.comgr" } @@ -145,8 +145,8 @@ generate_hsa() { fixup $BASE/hsa.py fixup $BASE/amd_gpu.py - sed -i "s\import ctypes\import ctypes, os\g" $BASE/hsa.py - sed -i "s\'/opt/rocm/\os.getenv('ROCM_PATH', '/opt/rocm/')+'/\g" $BASE/hsa.py + sed -i "s\import ctypes\import ctypes, ctypes.util, os\g" $BASE/hsa.py + sed -i "s\ctypes.CDLL('/opt/rocm/lib/libhsa-runtime64.so')\ctypes.CDLL(os.getenv('ROCM_PATH')+'/lib/libhsa-runtime64.so' if os.getenv('ROCM_PATH') else ctypes.util.find_library('hsa-runtime64'))\g" $BASE/hsa.py python3 -c "import tinygrad.runtime.autogen.hsa" } diff --git a/tinygrad/runtime/autogen/comgr.py b/tinygrad/runtime/autogen/comgr.py index 7aa19293ba..8037f6adbd 100644 --- a/tinygrad/runtime/autogen/comgr.py +++ b/tinygrad/runtime/autogen/comgr.py @@ -6,7 +6,7 @@ # POINTER_SIZE is: 8 # LONGDOUBLE_SIZE is: 16 # -import ctypes, os +import ctypes, ctypes.util, os def string_cast(char_pointer, encoding='utf-8', errors='strict'): @@ -29,7 +29,7 @@ def char_pointer_cast(string, encoding='utf-8'): _libraries = {} -_libraries['libamd_comgr.so'] = ctypes.CDLL(os.getenv('ROCM_PATH', '/opt/rocm/')+'/lib/libamd_comgr.so') +_libraries['libamd_comgr.so'] = ctypes.CDLL(os.getenv('ROCM_PATH')+'/lib/libamd_comgr.so' if os.getenv('ROCM_PATH') else ctypes.util.find_library('amd_comgr')) c_int128 = ctypes.c_ubyte*16 c_uint128 = c_int128 void = None diff --git a/tinygrad/runtime/autogen/hsa.py b/tinygrad/runtime/autogen/hsa.py index 6d27603eab..3436030df6 100644 --- a/tinygrad/runtime/autogen/hsa.py +++ b/tinygrad/runtime/autogen/hsa.py @@ -6,7 +6,7 @@ # POINTER_SIZE is: 8 # LONGDOUBLE_SIZE is: 16 # -import ctypes, os +import ctypes, ctypes.util, os def string_cast(char_pointer, encoding='utf-8', errors='strict'): @@ -29,7 +29,7 @@ def char_pointer_cast(string, encoding='utf-8'): _libraries = {} -_libraries['libhsa-runtime64.so'] = ctypes.CDLL(os.getenv('ROCM_PATH', '/opt/rocm/')+'/lib/libhsa-runtime64.so') +_libraries['libhsa-runtime64.so'] = ctypes.CDLL(os.getenv('ROCM_PATH')+'/lib/libhsa-runtime64.so' if os.getenv('ROCM_PATH') else ctypes.util.find_library('hsa-runtime64')) class AsDictMixin: @classmethod def as_dict(cls, self):