Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0ede672

Browse filesBrowse files
committed
On Apple Platforms (including M1/2), llama_cpp is built dynamically. Therefore we build a different extension (.dylib)
1 parent 422beeb commit 0ede672
Copy full SHA for 0ede672

File tree

Expand file treeCollapse file tree

2 files changed

+28
-10
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+28
-10
lines changed

‎CMakeLists.txt

Copy file name to clipboard
+27-9Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,31 @@
1-
set(CMAKE_SYSTEM_PROCESSOR "arm64")
2-
31
cmake_minimum_required(VERSION 3.4...3.22)
42

53
project(llama_cpp)
64

7-
set(BUILD_SHARED_LIBS "On")
8-
add_subdirectory(vendor/llama.cpp)
9-
install(
10-
TARGETS llama
11-
LIBRARY DESTINATION llama_cpp
12-
RUNTIME DESTINATION llama_cpp
13-
)
5+
option(FORCE_CMAKE "Force CMake build of Python bindings" OFF)
6+
7+
set(FORCE_CMAKE $ENV{FORCE_CMAKE})
8+
9+
if (UNIX AND NOT FORCE_CMAKE AND NOT APPLE)
10+
add_custom_command(
11+
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/vendor/llama.cpp/libllama.so
12+
COMMAND make libllama.so
13+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/vendor/llama.cpp
14+
)
15+
add_custom_target(
16+
run ALL
17+
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/vendor/llama.cpp/libllama.so
18+
)
19+
install(
20+
FILES ${CMAKE_CURRENT_SOURCE_DIR}/vendor/llama.cpp/libllama.so
21+
DESTINATION llama_cpp
22+
)
23+
else()
24+
set(BUILD_SHARED_LIBS "On")
25+
add_subdirectory(vendor/llama.cpp)
26+
install(
27+
TARGETS llama
28+
LIBRARY DESTINATION llama_cpp
29+
RUNTIME DESTINATION llama_cpp
30+
)
31+
endif(UNIX AND NOT FORCE_CMAKE AND NOT APPLE)

‎llama_cpp/llama_cpp.py

Copy file name to clipboardExpand all lines: llama_cpp/llama_cpp.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def _load_shared_library(lib_base_name):
2222
if sys.platform.startswith("linux"):
2323
lib_ext = ".so"
2424
elif sys.platform == "darwin":
25-
lib_ext = ".so"
25+
lib_ext = ".dylib"
2626
elif sys.platform == "win32":
2727
lib_ext = ".dll"
2828
else:

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.