Skip to content

Commit

Permalink
Optional linking with build tags
Browse files Browse the repository at this point in the history
  • Loading branch information
mudler committed May 14, 2023
1 parent 3501b34 commit b3260cf
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
18 changes: 15 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down
9 changes: 9 additions & 0 deletions llama_cublas.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//go:build cublas
// +build cublas

package llama

/*
#cgo LDFLAGS: -lcublas
*/
import "C"
9 changes: 9 additions & 0 deletions llama_openblas.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//go:build openblas
// +build openblas

package llama

/*
#cgo LDFLAGS: -lopenblas
*/
import "C"

0 comments on commit b3260cf

Please sign in to comment.