[GH-ISSUE #481] Unable to build ollama on linux with go 1.21.0 and Docker #25982

Closed
opened 2026-04-22 01:51:39 -05:00 by GiteaMirror · 6 comments
Owner

Originally created by @FairyTail2000 on GitHub (Sep 7, 2023).
Original GitHub issue: https://github.com/ollama/ollama/issues/481

When trying to build ollama for linux I encountered the following Problem:

llm/ggml_llama.go:31:12: pattern llama.cpp/ggml/build//bin/: no matching files found

After that I cleaned my enviroment to ensure a clean slate

go clean -r -x -cache -testcache -modcache -fuzzcache

This however did not help.

Testing the docker build also fails with the same error.

Reading the file llm/llama.cpp/generate.go I noticed it used commands and as a human being I'm able to execute them myself. After executing all commands the build works now.

For anyone who doesn't want to read the source code these are commands you have to execute in the folder llm/llama.cpp:

git submodule init
git submodule update --force ggml
git -C ggml apply ../ggml_patch/0001-add-detokenize-endpoint.patch
git -C ggml apply ../ggml_patch/0002-34B-model-support.patch
git -C ggml apply ../ggml_patch/0003-metal-fix-synchronization-in-new-matrix-multiplicati.patch
git -C ggml apply ../ggml_patch/0004-metal-add-missing-barriers-for-mul-mat-2699.patch
cmake --fresh -S ggml -B ggml/build/cpu -DLLAMA_K_QUANTS=on
cmake --build ggml/build/cpu --target server --config Release

The question now is, why isn't this executed at build time?

Originally created by @FairyTail2000 on GitHub (Sep 7, 2023). Original GitHub issue: https://github.com/ollama/ollama/issues/481 When trying to build ollama for linux I encountered the following Problem: > llm/ggml_llama.go:31:12: pattern llama.cpp/ggml/build/*/bin/*: no matching files found After that I cleaned my enviroment to ensure a clean slate ```bash go clean -r -x -cache -testcache -modcache -fuzzcache ``` This however did not help. Testing the docker build also fails with the same error. Reading the file llm/llama.cpp/generate.go I noticed it used commands and as a human being I'm able to execute them myself. After executing all commands the build works now. For anyone who doesn't want to read the source code these are commands you have to execute in the folder llm/llama.cpp: ```bash git submodule init git submodule update --force ggml git -C ggml apply ../ggml_patch/0001-add-detokenize-endpoint.patch git -C ggml apply ../ggml_patch/0002-34B-model-support.patch git -C ggml apply ../ggml_patch/0003-metal-fix-synchronization-in-new-matrix-multiplicati.patch git -C ggml apply ../ggml_patch/0004-metal-add-missing-barriers-for-mul-mat-2699.patch cmake --fresh -S ggml -B ggml/build/cpu -DLLAMA_K_QUANTS=on cmake --build ggml/build/cpu --target server --config Release ``` The question now is, why isn't this executed at build time?
Author
Owner

@FairyTail2000 commented on GitHub (Sep 7, 2023):

#480 looks like I'm not the only one confused by this. It might be useful to write such a breaking change into the release notes. If you can, can you update the release notes? You can close this issue without comment after you saw it, since this isn't actually an issue

<!-- gh-comment-id:1709641751 --> @FairyTail2000 commented on GitHub (Sep 7, 2023): #480 looks like I'm not the only one confused by this. It might be useful to write such a breaking change into the release notes. If you can, can you update the release notes? You can close this issue without comment after you saw it, since this isn't actually an issue
Author
Owner

@jmorganca commented on GitHub (Sep 7, 2023):

Hi there, sorry you hit this issue. The build instructions did change, and we could have done a better job of putting that in the release notes. I added some instructions to https://github.com/jmorganca/ollama/releases/tag/v0.0.18 – let me know if that works for you!

You'll need to run go generate ./... before go build to build some dependencies that ollama itself needs when running go build. While I wish there was a way to do this directly go build, it doesn't quite seem like it today. Let me know if you have thoughts on how we can possibly make this easier.

<!-- gh-comment-id:1709950975 --> @jmorganca commented on GitHub (Sep 7, 2023): Hi there, sorry you hit this issue. The build instructions did [change](https://github.com/jmorganca/ollama#building), and we could have done a better job of putting that in the release notes. I added some instructions to https://github.com/jmorganca/ollama/releases/tag/v0.0.18 – let me know if that works for you! You'll need to run `go generate ./...` before `go build` to build some dependencies that `ollama` itself needs when running `go build`. While I wish there was a way to do this directly `go build`, it doesn't quite seem like it today. Let me know if you have thoughts on how we can possibly make this easier.
Author
Owner

@FairyTail2000 commented on GitHub (Sep 7, 2023):

Sure there is a pretty low hanging fruit:
A build script

For now it can only contain two lines:

go generate ./...
go build

Then you can write into the readme:

To build project execute the script build.sh and for windows build.bat/ps1

That way you can also add build steps and don't have to change the readme

<!-- gh-comment-id:1709968778 --> @FairyTail2000 commented on GitHub (Sep 7, 2023): Sure there is a pretty low hanging fruit: A build script For now it can only contain two lines: ``` go generate ./... go build ``` Then you can write into the readme: To build project execute the script build.sh and for windows build.bat/ps1 That way you can also add build steps and don't have to change the readme
Author
Owner

@FairyTail2000 commented on GitHub (Sep 7, 2023):

The new compile instructions work perfectly and thank you for updating the release notes!

<!-- gh-comment-id:1709973100 --> @FairyTail2000 commented on GitHub (Sep 7, 2023): The new compile instructions work perfectly and thank you for updating the release notes!
Author
Owner

@FairyTail2000 commented on GitHub (Sep 7, 2023):

Sure there is a pretty low hanging fruit: A build script

For now it can only contain two lines:

go generate ./...
go build

Then you can write into the readme:

To build project execute the script build.sh and for windows build.bat/ps1

That way you can also add build steps and don't have to change the readme

Another idea for the script is to check the availability of a compiler, go and git. So new users don't see obscure errors but rather a nice error message

<!-- gh-comment-id:1709974176 --> @FairyTail2000 commented on GitHub (Sep 7, 2023): > Sure there is a pretty low hanging fruit: A build script > > For now it can only contain two lines: > > ``` > go generate ./... > go build > ``` > > Then you can write into the readme: > > To build project execute the script build.sh and for windows build.bat/ps1 > > That way you can also add build steps and don't have to change the readme Another idea for the script is to check the availability of a compiler, go and git. So new users don't see obscure errors but rather a nice error message
Author
Owner

@jmorganca commented on GitHub (Sep 7, 2023):

Awesome! Thanks! Will close this issue for now, but feel free to continue the discussion / or re-open if you hit more issues. BTW just noticed this: https://github.com/FairyTail2000/ollama-frontend – so cool!

<!-- gh-comment-id:1710167218 --> @jmorganca commented on GitHub (Sep 7, 2023): Awesome! Thanks! Will close this issue for now, but feel free to continue the discussion / or re-open if you hit more issues. BTW just noticed this: https://github.com/FairyTail2000/ollama-frontend – so cool!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#25982