From b3260cf89e5fe2368e120a5fca1a2763e67f50b0 Mon Sep 17 00:00:00 2001 From: mudler Date: Sun, 14 May 2023 11:28:17 +0200 Subject: [PATCH] Optional linking with build tags --- README.md | 18 +++++++++++++++--- llama_cublas.go | 9 +++++++++ llama_openblas.go | 9 +++++++++ 3 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 llama_cublas.go create mode 100644 llama_openblas.go diff --git a/README.md b/README.md index 0eaa3cf..535e6ae 100644 --- a/README.md +++ b/README.md @@ -25,16 +25,28 @@ cd go-llama.cpp make libbinding.a ``` -To build with OpenBLAS, for example: +Now you can run the example with: + +``` +LIBRARY_PATH=$PWD C_INCLUDE_PATH=$PWD go run ./examples -m "/model/path/here" -t 14 +``` + +## OpenBLAS accelleration + +To build and run with OpenBLAS, for example: ``` CMAKE_ARGS="-DLLAMA_OPENBLAS=ON" make libbinding.a +LIBRARY_PATH=$PWD C_INCLUDE_PATH=$PWD go run -tags openblas ./examples -m "/model/path/here" -t 14 ``` -Now you can run the example with: +## GPU + +To build with CuBLAS: ``` -LIBRARY_PATH=$PWD C_INCLUDE_PATH=$PWD go run ./examples -m "/model/path/here" -t 14 +CMAKE_ARGS="-DLLAMA_CUBLAS=ON" make libbinding.a +LIBRARY_PATH=$PWD C_INCLUDE_PATH=$PWD go run -tags cublas ./examples -m "/model/path/here" -t 14 ``` Enjoy! diff --git a/llama_cublas.go b/llama_cublas.go new file mode 100644 index 0000000..32bb072 --- /dev/null +++ b/llama_cublas.go @@ -0,0 +1,9 @@ +//go:build cublas +// +build cublas + +package llama + +/* +#cgo LDFLAGS: -lcublas +*/ +import "C" diff --git a/llama_openblas.go b/llama_openblas.go new file mode 100644 index 0000000..31e09f7 --- /dev/null +++ b/llama_openblas.go @@ -0,0 +1,9 @@ +//go:build openblas +// +build openblas + +package llama + +/* +#cgo LDFLAGS: -lopenblas +*/ +import "C"