Build linux using ubuntu 20.04
This changes the container-based linux build to use an older Ubuntu distro to improve our compatibility matrix for older user machines
This commit is contained in:
parent
35934b2e05
commit
89bbaafa64
3 changed files with 47 additions and 17 deletions
|
@ -1,11 +1,18 @@
|
||||||
# Ubuntu 20.04 amd64 dependencies
|
# Ubuntu 20.04 amd64 dependencies
|
||||||
FROM --platform=linux/amd64 nvidia/cuda:11.7.1-devel-ubuntu22.04 AS base-amd64
|
FROM --platform=linux/amd64 ubuntu:20.04 AS base-amd64
|
||||||
|
ARG CUDA_VERSION=11.3.1-1
|
||||||
|
ARG CMAKE_VERSION=3.22.1
|
||||||
# ROCm only supports amd64
|
# ROCm only supports amd64
|
||||||
ARG ROCM_VERSION=5.7
|
ARG ROCM_VERSION=5.7
|
||||||
|
|
||||||
# Note: https://rocm.docs.amd.com/en/latest/release/user_kernel_space_compat_matrix.html
|
# Note: https://rocm.docs.amd.com/en/latest/release/user_kernel_space_compat_matrix.html
|
||||||
RUN apt-get update && \
|
RUN apt-get update && \
|
||||||
apt-get install -y wget && \
|
apt-get install -y wget gnupg && \
|
||||||
wget "https://github.com/Kitware/CMake/releases/download/v3.22.1/cmake-3.22.1-linux-x86_64.sh" -O /tmp/cmake-installer.sh && \
|
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-ubuntu2004.pin && \
|
||||||
|
mv cuda-ubuntu2004.pin /etc/apt/preferences.d/cuda-repository-pin-600 && \
|
||||||
|
apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/3bf863cc.pub && \
|
||||||
|
echo "deb [by-hash=no] https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/ /" > /etc/apt/sources.list.d/cuda.list && \
|
||||||
|
wget "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-linux-x86_64.sh" -O /tmp/cmake-installer.sh && \
|
||||||
chmod +x /tmp/cmake-installer.sh && /tmp/cmake-installer.sh --skip-license --prefix=/usr && \
|
chmod +x /tmp/cmake-installer.sh && /tmp/cmake-installer.sh --skip-license --prefix=/usr && \
|
||||||
mkdir --parents --mode=0755 /etc/apt/keyrings && \
|
mkdir --parents --mode=0755 /etc/apt/keyrings && \
|
||||||
wget https://repo.radeon.com/rocm/rocm.gpg.key -O - | gpg --dearmor > /etc/apt/keyrings/rocm.gpg && \
|
wget https://repo.radeon.com/rocm/rocm.gpg.key -O - | gpg --dearmor > /etc/apt/keyrings/rocm.gpg && \
|
||||||
|
@ -14,35 +21,45 @@ RUN apt-get update && \
|
||||||
echo "Pin: release o=repo.radeon.com" >> /etc/apt/preferences.d/rocm-pin-600 && \
|
echo "Pin: release o=repo.radeon.com" >> /etc/apt/preferences.d/rocm-pin-600 && \
|
||||||
echo "Pin-Priority: 600" >> /etc/apt/preferences.d/rocm-pin-600 && \
|
echo "Pin-Priority: 600" >> /etc/apt/preferences.d/rocm-pin-600 && \
|
||||||
apt-get update && \
|
apt-get update && \
|
||||||
DEBIAN_FRONTEND=noninteractive apt-get install -y rocm-hip-libraries rocm-device-libs rocm-libs rocm-ocl-icd rocm-hip-sdk rocm-hip-libraries rocm-cmake rocm-clang-ocl rocm-dev
|
DEBIAN_FRONTEND=noninteractive apt-get -y install cuda=${CUDA_VERSION} rocm-hip-libraries rocm-device-libs rocm-libs rocm-ocl-icd rocm-hip-sdk rocm-hip-libraries rocm-cmake rocm-clang-ocl rocm-dev
|
||||||
|
|
||||||
ENV ROCM_PATH=/opt/rocm
|
ENV ROCM_PATH=/opt/rocm
|
||||||
|
|
||||||
# Ubuntu 22.04 arm64 dependencies
|
# Ubuntu 22.04 arm64 dependencies
|
||||||
FROM --platform=linux/arm64 nvidia/cuda:11.7.1-devel-ubuntu22.04 AS base-arm64
|
FROM --platform=linux/arm64 ubuntu:20.04 AS base-arm64
|
||||||
|
ARG CUDA_VERSION=11.3.1-1
|
||||||
|
ARG CMAKE_VERSION=3.27.6
|
||||||
RUN apt-get update && \
|
RUN apt-get update && \
|
||||||
apt-get install -y wget && \
|
apt-get install -y wget gnupg && \
|
||||||
wget "https://github.com/Kitware/CMake/releases/download/v3.27.6/cmake-3.27.6-linux-aarch64.sh" -O /tmp/cmake-installer.sh && \
|
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/sbsa/cuda-ubuntu2004.pin && \
|
||||||
chmod +x /tmp/cmake-installer.sh && /tmp/cmake-installer.sh --skip-license --prefix=/usr
|
mv cuda-ubuntu2004.pin /etc/apt/preferences.d/cuda-repository-pin-600 && \
|
||||||
|
apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/sbsa//3bf863cc.pub && \
|
||||||
|
echo "deb [by-hash=no] https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/sbsa/ /" > /etc/apt/sources.list.d/cuda.list && \
|
||||||
|
wget "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-linux-aarch64.sh" -O /tmp/cmake-installer.sh && \
|
||||||
|
chmod +x /tmp/cmake-installer.sh && /tmp/cmake-installer.sh --skip-license --prefix=/usr && \
|
||||||
|
apt-get update && \
|
||||||
|
apt-cache madison cuda && \
|
||||||
|
DEBIAN_FRONTEND=noninteractive apt-get -y install cuda=${CUDA_VERSION}
|
||||||
|
|
||||||
FROM base-${TARGETARCH}
|
FROM base-${TARGETARCH}
|
||||||
ARG TARGETARCH
|
ARG TARGETARCH
|
||||||
ARG GOFLAGS="'-ldflags -w -s'"
|
ARG GOFLAGS="'-ldflags -w -s'"
|
||||||
ARG CGO_CFLAGS
|
ARG CGO_CFLAGS
|
||||||
ARG CLBLAST_VER=1.6.1
|
ARG CLBLAST_VER=1.6.1
|
||||||
|
ARG GOLANG_VERSION=1.21.3
|
||||||
|
|
||||||
# Common toolchain
|
# Common toolchain
|
||||||
RUN apt-get update && \
|
RUN apt-get update && \
|
||||||
DEBIAN_FRONTEND=noninteractive apt-get install -y gcc-11 g++-11 cpp-11 git ocl-icd-opencl-dev && \
|
DEBIAN_FRONTEND=noninteractive apt-get install -y gcc-10 g++-10 cpp-10 git ocl-icd-opencl-dev && \
|
||||||
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 100 --slave /usr/bin/g++ g++ /usr/bin/g++-11 --slave /usr/bin/gcov gcov /usr/bin/gcov-11
|
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100 --slave /usr/bin/g++ g++ /usr/bin/g++-10 --slave /usr/bin/gcov gcov /usr/bin/gcov-10
|
||||||
|
|
||||||
# CLBlast
|
# CLBlast
|
||||||
RUN wget -qO- https://github.com/CNugteren/CLBlast/archive/refs/tags/${CLBLAST_VER}.tar.gz | tar zxv -C /tmp/ && \
|
RUN wget -qO- https://github.com/CNugteren/CLBlast/archive/refs/tags/${CLBLAST_VER}.tar.gz | tar zxv -C /tmp/ && \
|
||||||
cd /tmp/CLBlast-${CLBLAST_VER} && mkdir build && cd build && cmake .. && make && make install
|
cd /tmp/CLBlast-${CLBLAST_VER} && mkdir build && cd build && cmake .. && make && make install
|
||||||
|
|
||||||
# install go
|
# install go
|
||||||
ADD https://dl.google.com/go/go1.21.3.linux-$TARGETARCH.tar.gz /tmp/go1.21.3.tar.gz
|
ADD https://dl.google.com/go/go${GOLANG_VERSION}.linux-$TARGETARCH.tar.gz /tmp/go${GOLANG_VERSION}.tar.gz
|
||||||
RUN mkdir -p /usr/local && tar xz -C /usr/local </tmp/go1.21.3.tar.gz
|
RUN mkdir -p /usr/local && tar xz -C /usr/local </tmp/go${GOLANG_VERSION}.tar.gz
|
||||||
|
|
||||||
# build the final binary
|
# build the final binary
|
||||||
WORKDIR /go/src/github.com/jmorganca/ollama
|
WORKDIR /go/src/github.com/jmorganca/ollama
|
||||||
|
|
|
@ -15,13 +15,20 @@ init_vars() {
|
||||||
}
|
}
|
||||||
|
|
||||||
git_module_setup() {
|
git_module_setup() {
|
||||||
# TODO add flags to skip the init/patch logic to make it easier to mod llama.cpp code in-repo
|
if [ -n "${OLLAMA_SKIP_PATCHING}" ] ; then
|
||||||
|
echo "Skipping submodule initialization"
|
||||||
|
return
|
||||||
|
fi
|
||||||
git submodule init
|
git submodule init
|
||||||
git submodule update --force gguf
|
git submodule update --force gguf
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
apply_patches() {
|
apply_patches() {
|
||||||
|
if [ -n "${OLLAMA_SKIP_PATCHING}" ] ; then
|
||||||
|
echo "Skipping submodule patching"
|
||||||
|
return
|
||||||
|
fi
|
||||||
# Workaround git apply not handling creation well for iteration
|
# Workaround git apply not handling creation well for iteration
|
||||||
rm -f gguf/examples/server/server.h
|
rm -f gguf/examples/server/server.h
|
||||||
for patch in ${PATCHES} ; do
|
for patch in ${PATCHES} ; do
|
||||||
|
|
|
@ -3,13 +3,13 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifdef __linux__
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
#define LOAD_LIBRARY(lib, flags) dlopen(lib, flags)
|
#define LOAD_LIBRARY(lib, flags) dlopen(lib, flags | RTLD_DEEPBIND)
|
||||||
#define LOAD_SYMBOL(handle, sym) dlsym(handle, sym)
|
#define LOAD_SYMBOL(handle, sym) dlsym(handle, sym)
|
||||||
#define LOAD_ERR() dlerror()
|
#define LOAD_ERR() dlerror()
|
||||||
#define UNLOAD_LIBRARY(handle) dlclose(handle)
|
#define UNLOAD_LIBRARY(handle) dlclose(handle)
|
||||||
#else
|
#elif _WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#define LOAD_LIBRARY(lib, flags) LoadLibrary(lib)
|
#define LOAD_LIBRARY(lib, flags) LoadLibrary(lib)
|
||||||
#define LOAD_SYMBOL(handle, sym) GetProcAddress(handle, sym)
|
#define LOAD_SYMBOL(handle, sym) GetProcAddress(handle, sym)
|
||||||
|
@ -20,6 +20,12 @@ inline static char *LOAD_ERR() {
|
||||||
snprintf(errbuf, 8, "0x%lx", GetLastError());
|
snprintf(errbuf, 8, "0x%lx", GetLastError());
|
||||||
return errbuf;
|
return errbuf;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
#include <dlfcn.h>
|
||||||
|
#define LOAD_LIBRARY(lib, flags) dlopen(lib, flags)
|
||||||
|
#define LOAD_SYMBOL(handle, sym) dlsym(handle, sym)
|
||||||
|
#define LOAD_ERR() dlerror()
|
||||||
|
#define UNLOAD_LIBRARY(handle) dlclose(handle)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void rocm_shim_init(const char *libPath, struct rocm_llama_server *s,
|
void rocm_shim_init(const char *libPath, struct rocm_llama_server *s,
|
||||||
|
@ -48,7 +54,7 @@ void rocm_shim_init(const char *libPath, struct rocm_llama_server *s,
|
||||||
};
|
};
|
||||||
|
|
||||||
printf("Lazy loading %s library\n", libPath);
|
printf("Lazy loading %s library\n", libPath);
|
||||||
s->handle = LOAD_LIBRARY(libPath, RTLD_LAZY);
|
s->handle = LOAD_LIBRARY(libPath, RTLD_NOW);
|
||||||
if (!s->handle) {
|
if (!s->handle) {
|
||||||
err->id = -1;
|
err->id = -1;
|
||||||
snprintf(
|
snprintf(
|
||||||
|
|
Loading…
Reference in a new issue