jmorganca 593d6836ab fix cuda build 11 months ago
..
ggml-cuda 01ccbc07fe replace static build in `llm` 8 months ago
patches beb847b40f add license headers 8 months ago
.gitignore b1696e308e Add missing hipcc flags 8 months ago
README.md 4a5633e4bc fix sync script 8 months ago
build_cuda.sh 593d6836ab fix cuda build 8 months ago
build_hipblas.sh 4a5633e4bc fix sync script 8 months ago
ggml-alloc.c beb847b40f add license headers 8 months ago
ggml-alloc.h beb847b40f add license headers 8 months ago
ggml-backend-impl.h beb847b40f add license headers 8 months ago
ggml-backend.c beb847b40f add license headers 8 months ago
ggml-backend.h beb847b40f add license headers 8 months ago
ggml-common.h beb847b40f add license headers 8 months ago
ggml-cuda.cu beb847b40f add license headers 8 months ago
ggml-cuda.h beb847b40f add license headers 8 months ago
ggml-impl.h beb847b40f add license headers 8 months ago
ggml-metal-darwin_arm64.m 533a7e7d50 fix build on windows 8 months ago
ggml-metal.h beb847b40f add license headers 8 months ago
ggml-metal.metal beb847b40f add license headers 8 months ago
ggml-metal.o 01ccbc07fe replace static build in `llm` 8 months ago
ggml-quants.c beb847b40f add license headers 8 months ago
ggml-quants.h beb847b40f add license headers 8 months ago
ggml.c beb847b40f add license headers 8 months ago
ggml.h beb847b40f add license headers 8 months ago
llama.cpp beb847b40f add license headers 8 months ago
llama.go e86db9381a `avx2` should only add `avx2` 8 months ago
llama.h beb847b40f add license headers 8 months ago
sgemm.cpp 0110994d06 Initial `llama` Go module 8 months ago
sgemm.h 0110994d06 Initial `llama` Go module 8 months ago
unicode-data.cpp beb847b40f add license headers 8 months ago
unicode-data.h beb847b40f add license headers 8 months ago
unicode.cpp beb847b40f add license headers 8 months ago
unicode.h beb847b40f add license headers 8 months ago

README.md

llama

This package integrates llama.cpp as a Go package that's easy to build with tags for different CPU and GPU processors.

  • CPU
  • avx, avx2
  • avx512
  • macOS Metal
  • Windows CUDA
  • Windows ROCm
  • Linux CUDA
  • Linux ROCm

Extra build steps are required for CUDA and ROCm on Windows since nvcc and hipcc both require using msvc as the host compiler. For these small dlls are created:

  • ggml-cuda.dll
  • ggml-hipblas.dll

Note: it's important that memory is allocated and freed by the same compiler (e.g. entirely by code compiled with msvc or mingw). Issues from this should be rare, but there are some places where pointers are returned by the CUDA or HIP runtimes and freed elsewhere, causing a a crash. In a future change the same runtime should be used in both cases to avoid crashes.

Building

go build .

AVX

go build -tags avx .

AVX2

# go doesn't recognize `-mfma` as a valid compiler flag
# see https://github.com/golang/go/issues/17895
go env -w "CGO_CFLAGS_ALLOW=-mfma"
go env -w "CGO_CXXFLAGS_ALLOW=-mfma"
go build -tags=avx2 .

CUDA

Install the CUDA toolkit v11.3.1 then build ggml-cuda:

Build ggml-cuda.dll:

./build_cuda.sh

Then build the package with the cuda tag:

go build -tags=cuda .

ROCm

Install ROCm 5.7.1 and Strawberry Perl.

Then, build ggml-hipblas.dll:

./build_hipblas.sh

Then build the package with the rocm tag:

go build -tags=rocm .

Syncing with llama.cpp

To update this package to the latest llama.cpp code, use the sync.sh script.

./sync.sh ../../llama.cpp