hotfix: amd works on arch linux w/o rocm

This commit is contained in:
George Hotz
2025-05-24 16:47:13 -07:00
parent d90ddcc365
commit 941cbd3471
2 changed files with 8 additions and 6 deletions

View File

@@ -1,3 +1,3 @@
#!/bin/bash
PYTHON_PATH=$(readlink -f $(which python3))
sudo setcap 'cap_dac_override,cap_sys_rawio,cap_sys_admin=ep' $PYTHON_PATH
sudo setcap 'cap_dac_override,cap_sys_rawio,cap_sys_admin,cap_ipc_lock=ep' $PYTHON_PATH

View File

@@ -1,11 +1,13 @@
import ctypes, subprocess
import tinygrad.runtime.autogen.comgr as comgr
comgr.amd_comgr_get_version(ctypes.byref(major:=ctypes.c_uint64()), ctypes.byref(minor:=ctypes.c_uint64()))
assert comgr.AMD_COMGR_LANGUAGE_HIP == 4
if major.value >= 3:
# in comgr 3 the values of enums in headers were changed: https://github.com/ROCm/llvm-project/issues/272
import tinygrad.runtime.autogen.comgr_3 as comgr # type: ignore[no-redef]
assert comgr.AMD_COMGR_LANGUAGE_HIP == 3
try:
comgr.amd_comgr_get_version(ctypes.byref(major:=ctypes.c_uint64()), ctypes.byref(minor:=ctypes.c_uint64()))
if major.value >= 3:
# in comgr 3 the values of enums in headers were changed: https://github.com/ROCm/llvm-project/issues/272
import tinygrad.runtime.autogen.comgr_3 as comgr # type: ignore[no-redef]
assert comgr.AMD_COMGR_LANGUAGE_HIP == 3
except AttributeError: pass # ignore if ROCm isn't installed
from tinygrad.device import Compiler, CompileError
from tinygrad.runtime.ops_llvm import LLVMCompiler
from tinygrad.helpers import OSX, to_char_p_p