How To compile ollama from source to use unsupported AMD GPU with rocm in Ubuntu Debian

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

 


Tags:

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,

Latest Articles

  • How To Convert HTML to Text Based PDF
  • How To Emulate Android in Linux
  • How to use KVM and GUI inside Docker
  • python spacey ERROR: No matching distribution found for thinc<8.4.0,>=8.3.12
  • Debian 11 security repo fixes due to EOL
  • MySQL vs MariaDB how to create a socket user tutorial
  • Ubuntu Linux Mint Desktop Dark Black Cannot See Solution
  • How to combine .txt ACLs without breaking things
  • How to ping all of Googlebot's IPs script
  • 'virtio0' uses a qcow2 feature which is not supported by this qemu version: QCOW version 3
  • Linux bash script to get the IP of a list of hostnames
  • How To Use Camera Webcam in Docker for OBS Studio etc...
  • Computer Server Won't Post Boot Or Enter BIOS Setup After Installing RAID SAS or GPU Card etc..
  • How To Test PHP Scripts from CLI with GET variables/query string
  • apt-cache how to see all available versions of a package in Debian Ubuntu Mint
  • Virtualbox VBox Guest-utils drag and drop files stops working with Windows VMs
  • How To Remove Ubuntu Netplan and Go Back to /etc/network/interfaces
  • How To Force Flash an AMD Instinct GPU To Another Model Using Debian Ubuntu Mint Linux
  • How To compile ollama from source to use unsupported AMD GPU with rocm in Ubuntu Debian
  • QEMU KVM Virtio GPU Windows Cannot Select 1080P