2023-11-29 14:00:37 -05:00
|
|
|
# Ubuntu 20.04 amd64 dependencies
|
|
|
|
FROM --platform=linux/amd64 nvidia/cuda:11.7.1-devel-ubuntu22.04 AS base-amd64
|
|
|
|
# ROCm only supports amd64
|
|
|
|
ARG ROCM_VERSION=5.7
|
|
|
|
# Note: https://rocm.docs.amd.com/en/latest/release/user_kernel_space_compat_matrix.html
|
|
|
|
RUN apt-get update && \
|
|
|
|
apt-get install -y wget && \
|
|
|
|
wget "https://github.com/Kitware/CMake/releases/download/v3.22.1/cmake-3.22.1-linux-x86_64.sh" -O /tmp/cmake-installer.sh && \
|
|
|
|
chmod +x /tmp/cmake-installer.sh && /tmp/cmake-installer.sh --skip-license --prefix=/usr && \
|
|
|
|
mkdir --parents --mode=0755 /etc/apt/keyrings && \
|
|
|
|
wget https://repo.radeon.com/rocm/rocm.gpg.key -O - | gpg --dearmor > /etc/apt/keyrings/rocm.gpg && \
|
|
|
|
echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/rocm.gpg] https://repo.radeon.com/rocm/apt/${ROCM_VERSION} focal main" > /etc/apt/sources.list.d/rocm.list && \
|
|
|
|
echo "Package: *" > /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 && \
|
|
|
|
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
|
|
|
|
|
|
|
|
ENV ROCM_PATH=/opt/rocm
|
|
|
|
|
|
|
|
# Ubuntu 22.04 arm64 dependencies
|
|
|
|
FROM --platform=linux/arm64 nvidia/cuda:11.7.1-devel-ubuntu22.04 AS base-arm64
|
|
|
|
RUN apt-get update && \
|
|
|
|
apt-get install -y wget && \
|
|
|
|
wget "https://github.com/Kitware/CMake/releases/download/v3.27.6/cmake-3.27.6-linux-aarch64.sh" -O /tmp/cmake-installer.sh && \
|
|
|
|
chmod +x /tmp/cmake-installer.sh && /tmp/cmake-installer.sh --skip-license --prefix=/usr
|
2023-09-22 15:20:12 -04:00
|
|
|
|
|
|
|
FROM base-${TARGETARCH}
|
|
|
|
ARG TARGETARCH
|
2023-10-03 10:05:09 -04:00
|
|
|
ARG GOFLAGS="'-ldflags -w -s'"
|
2023-11-29 14:00:37 -05:00
|
|
|
ARG CGO_CFLAGS
|
|
|
|
ARG CLBLAST_VER=1.6.1
|
|
|
|
|
|
|
|
# Common toolchain
|
|
|
|
RUN apt-get update && \
|
|
|
|
DEBIAN_FRONTEND=noninteractive apt-get install -y gcc-11 g++-11 cpp-11 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
|
|
|
|
|
|
|
|
# CLBlast
|
|
|
|
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
|
2023-09-22 15:20:12 -04:00
|
|
|
|
|
|
|
# install go
|
2023-10-12 22:14:20 -04:00
|
|
|
ADD https://dl.google.com/go/go1.21.3.linux-$TARGETARCH.tar.gz /tmp/go1.21.3.tar.gz
|
|
|
|
RUN mkdir -p /usr/local && tar xz -C /usr/local </tmp/go1.21.3.tar.gz
|
2023-09-22 15:20:12 -04:00
|
|
|
|
|
|
|
# build the final binary
|
|
|
|
WORKDIR /go/src/github.com/jmorganca/ollama
|
|
|
|
COPY . .
|
2023-10-03 10:05:09 -04:00
|
|
|
|
2023-09-26 13:38:32 -04:00
|
|
|
ENV GOOS=linux
|
2023-09-22 15:20:12 -04:00
|
|
|
ENV GOARCH=$TARGETARCH
|
2023-10-03 10:05:09 -04:00
|
|
|
ENV GOFLAGS=$GOFLAGS
|
2023-11-29 14:00:37 -05:00
|
|
|
ENV CGO_CFLAGS=${CGO_CFLAGS}
|
2023-09-26 13:38:32 -04:00
|
|
|
|
2023-11-29 14:00:37 -05:00
|
|
|
RUN /usr/local/go/bin/go generate ./... && \
|
|
|
|
/usr/local/go/bin/go build .
|