rwkv.cpp icon indicating copy to clipboard operation
rwkv.cpp copied to clipboard

Apple Silicon : mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')

Open mozzipa opened this issue 2 years ago • 3 comments

Because instruction for Apple silicon in Readme.md has been applied, CMAKE_SYSTEM_PROCESSOR from cmake . appears arm64. But, there is warning as below for cmake .

-- Accelerate framework found
-- CMAKE_SYSTEM_PROCESSOR: arm64
-- ARM detected
-- CMAKE_SYSTEM_PROCESSOR: arm64
CMake Warning at ggml/src/CMakeLists.txt:48 (message):
  Your arch is announced as x86_64, but it seems to actually be ARM64.  Not
  fixing that can lead to bad performance.  For more info see:
  https://github.com/ggerganov/whisper.cpp/issues/66#issuecomment-#1282546789


-- ARM detected
-- Accelerate framework found
-- Configuring done (0.1s)
-- Generating done (0.0s)
-- Build files have been written to: /my/path/rwkv.cpp

Furthermore, below error occurs for python rwkv/generate_completions.py /my/path/rwkv.cpp/models/rwkv-4-raven/ggml-model-q5_1.bin

OSError: dlopen(/my/path/rwkv.cpp/librwkv.dylib, 0x0006): tried: '/my/path/rwkv.cpp/librwkv.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/my/path/rwkv.cpp/librwkv.dylib' (no such file), '/my/path/rwkv.cpp/librwkv.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64'))

For your reference, similar error for llama-cpp-python was solved with arch -arm64 pip install llama-cpp-python --no-cache-dir It might be similar solution mentioned in above github link from warning.

Additionally, arch -arm64 cmake . and arch -arm64 cmake --build . --config Release were not valid.

mozzipa avatar May 13 '23 14:05 mozzipa

same issues

realcarlos avatar Jul 12 '23 07:07 realcarlos

I get similar problem even without that warning.

-- CMAKE_SYSTEM_PROCESSOR: arm64
-- ARM detected
-- Configuring done (0.0s)
-- Generating done (0.2s)
-- Build files have been written to: /Users/joakimeriksson/work/rwkv.cpp
[  9%] Built target ggml
[ 18%] Built target rwkv
[ 27%] Built target test_ggml_basics
[ 36%] Built target test_quantized_matmul_on_gpu
[ 45%] Built target test_tiny_rwkv
[ 54%] Built target test_quantization_format_compatibility
[ 63%] Built target test_logit_calculation_skipping
[ 72%] Built target test_eval_sequence_in_chunks
[ 81%] Built target test_context_cloning
[ 90%] Built target rwkv_cpu_info
[100%] Built target rwkv_quantize

Then:

python python/chat_with_bot.py ~/Downloads/rwkv.cpp-169M-Q5_1.bin
Traceback (most recent call last):
  File "/Users/joakimeriksson/work/rwkv.cpp/python/chat_with_bot.py", line 55, in <module>
    library = rwkv_cpp_shared_library.load_rwkv_shared_library()
  File "/Users/joakimeriksson/work/rwkv.cpp/python/rwkv_cpp/rwkv_cpp_shared_library.py", line 440, in load_rwkv_shared_library
    return RWKVSharedLibrary(str(full_path))
  File "/Users/joakimeriksson/work/rwkv.cpp/python/rwkv_cpp/rwkv_cpp_shared_library.py", line 45, in __init__
    self.library = ctypes.cdll.LoadLibrary(shared_library_path)
  File "/Users/joakimeriksson/anaconda3/envs/detic/lib/python3.9/ctypes/__init__.py", line 460, in LoadLibrary
    return self._dlltype(name)
  File "/Users/joakimeriksson/anaconda3/envs/detic/lib/python3.9/ctypes/__init__.py", line 382, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: dlopen(/Users/joakimeriksson/work/rwkv.cpp/librwkv.dylib, 0x0006): tried: '/opt/homebrew/lib/librwkv.dylib' (no such file), '/Users/joakimeriksson/.wasmedge/lib/librwkv.dylib' (no such file), '/Users/joakimeriksson/work/rwkv.cpp/librwkv.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/joakimeriksson/work/rwkv.cpp/librwkv.dylib' (no such file), '/Users/joakimeriksson/work/rwkv.cpp/librwkv.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64'))

I have Mac with non-intel CPU. Somehow the build-scripts detects ARM64 but when running assumes x86.

joakimeriksson avatar Jan 29 '24 14:01 joakimeriksson

My problem was that my conda environment used an x86 python while the compiler did compile for arm64. Replacing the conda environment with an arm64 worked.

joakimeriksson avatar Jan 29 '24 18:01 joakimeriksson