compiling ollama from source by using a docker container with a prebuilt rocm 6.1 dev environment:
rocm/dev-ubuntu-22.04:6.1-complete
Install these packages first
apt install cmake git
apt install software-properties-common
add-apt-repository ppa:longsleep/golang-backports
apt install golang-go
Clone the repo
git clone https://github.com/ollama/ollama /rtt/ollamabuild
cd /rtt/ollamabuild
#set version we want eg v0.23.0
git checkout v0.23.0
Export these ENVs to make sure the compiler uses rocm and the right clang
export CC=/opt/rocm/bin/hipcc
export CXX=/opt/rocm/bin/hipcc
export ROCM_PATH=/opt/rocm
export HIP_PATH=/opt/rocm
export PATH=$PATH:/opt/rocm/bin:/opt/rocm/llvm/bin
Generate
go generate ./...
Build
go build .
If you get an error like below you didn't follow the packages install section at the beginning.
#go build .
go: errors parsing go.mod:
/src/ollama/go.mod:3: invalid go version '1.22.0': must match format 1.23
compile, ollama, unsupported, amd, gpu, rocm, ubuntu, debiancompiling, docker, container, prebuilt, dev, install, packages, apt, cmake, software, properties, repository, ppa, longsleep, golang, backports, clone, repo, git, https, github, rtt, ollamabuild, export, envs, compiler, clang, cc, opt, bin, hipcc, cxx, rocm_path, hip_path, llvm, generate, didn, errors, parsing, mod, src, invalid, format,