mirror of https://gitee.com/namelin2022/ollama
Browse Source
This renames Dockerfile.build to Dockerfile, and adds some new stages to support 2 modes of building - the build_linux.sh script uses intermediate stages to extract the artifacts for ./dist, and the default build generates a container image usable by both cuda and rocm cards. This required transitioniing the x86 base to the rocm image to avoid layer bloat.upgrade-all
3 changed files with 111 additions and 116 deletions
@ -1,99 +0,0 @@ |
|||
ARG GOLANG_VERSION=1.21.3 |
|||
ARG CMAKE_VERSION=3.22.1 |
|||
ARG CUDA_VERSION=11.3.1 |
|||
|
|||
# Copy the minimal context we need to run the generate scripts |
|||
FROM scratch AS llm-code |
|||
COPY .git .git |
|||
COPY .gitmodules .gitmodules |
|||
COPY llm llm |
|||
|
|||
FROM --platform=linux/amd64 nvidia/cuda:$CUDA_VERSION-devel-centos7 AS cuda-build-amd64 |
|||
ARG CMAKE_VERSION |
|||
ARG CGO_CFLAGS |
|||
COPY ./scripts/rh_linux_deps.sh / |
|||
RUN CMAKE_VERSION=${CMAKE_VERSION} sh /rh_linux_deps.sh |
|||
ENV PATH /opt/rh/devtoolset-10/root/usr/bin:$PATH |
|||
COPY --from=llm-code / /go/src/github.com/jmorganca/ollama/ |
|||
WORKDIR /go/src/github.com/jmorganca/ollama/llm/generate |
|||
RUN OLLAMA_SKIP_CPU_GENERATE=1 sh gen_linux.sh |
|||
|
|||
FROM --platform=linux/arm64 nvidia/cuda:$CUDA_VERSION-devel-rockylinux8 AS cuda-build-arm64 |
|||
ARG CMAKE_VERSION |
|||
ARG CGO_CFLAGS |
|||
COPY ./scripts/rh_linux_deps.sh / |
|||
RUN CMAKE_VERSION=${CMAKE_VERSION} sh /rh_linux_deps.sh |
|||
ENV PATH /opt/rh/gcc-toolset-10/root/usr/bin:$PATH |
|||
COPY --from=llm-code / /go/src/github.com/jmorganca/ollama/ |
|||
WORKDIR /go/src/github.com/jmorganca/ollama/llm/generate |
|||
RUN OLLAMA_SKIP_CPU_GENERATE=1 sh gen_linux.sh |
|||
|
|||
FROM --platform=linux/amd64 rocm/dev-centos-7:5.7.1-complete AS rocm-5-build-amd64 |
|||
ARG CMAKE_VERSION |
|||
ARG CGO_CFLAGS |
|||
COPY ./scripts/rh_linux_deps.sh / |
|||
RUN CMAKE_VERSION=${CMAKE_VERSION} sh /rh_linux_deps.sh |
|||
ENV PATH /opt/rh/devtoolset-10/root/usr/bin:$PATH |
|||
ENV LIBRARY_PATH /opt/amdgpu/lib64 |
|||
COPY --from=llm-code / /go/src/github.com/jmorganca/ollama/ |
|||
WORKDIR /go/src/github.com/jmorganca/ollama/llm/generate |
|||
RUN OLLAMA_SKIP_CPU_GENERATE=1 sh gen_linux.sh |
|||
|
|||
FROM --platform=linux/amd64 rocm/dev-centos-7:6.0-complete AS rocm-6-build-amd64 |
|||
ARG CMAKE_VERSION |
|||
ARG CGO_CFLAGS |
|||
COPY ./scripts/rh_linux_deps.sh / |
|||
RUN CMAKE_VERSION=${CMAKE_VERSION} sh /rh_linux_deps.sh |
|||
ENV PATH /opt/rh/devtoolset-10/root/usr/bin:$PATH |
|||
ENV LIBRARY_PATH /opt/amdgpu/lib64 |
|||
COPY --from=llm-code / /go/src/github.com/jmorganca/ollama/ |
|||
WORKDIR /go/src/github.com/jmorganca/ollama/llm/generate |
|||
RUN OLLAMA_SKIP_CPU_GENERATE=1 sh gen_linux.sh |
|||
|
|||
FROM --platform=linux/amd64 centos:7 AS cpu-build-amd64 |
|||
ARG CMAKE_VERSION |
|||
ARG GOLANG_VERSION |
|||
ARG OLLAMA_CUSTOM_CPU_DEFS |
|||
ARG CGO_CFLAGS |
|||
COPY ./scripts/rh_linux_deps.sh / |
|||
RUN CMAKE_VERSION=${CMAKE_VERSION} GOLANG_VERSION=${GOLANG_VERSION} sh /rh_linux_deps.sh |
|||
ENV PATH /opt/rh/devtoolset-10/root/usr/bin:$PATH |
|||
COPY --from=llm-code / /go/src/github.com/jmorganca/ollama/ |
|||
WORKDIR /go/src/github.com/jmorganca/ollama/llm/generate |
|||
RUN sh gen_linux.sh |
|||
|
|||
FROM --platform=linux/arm64 centos:7 AS cpu-build-arm64 |
|||
ARG CMAKE_VERSION |
|||
ARG GOLANG_VERSION |
|||
ARG OLLAMA_CUSTOM_CPU_DEFS |
|||
ARG CGO_CFLAGS |
|||
COPY ./scripts/rh_linux_deps.sh / |
|||
RUN CMAKE_VERSION=${CMAKE_VERSION} GOLANG_VERSION=${GOLANG_VERSION} sh /rh_linux_deps.sh |
|||
ENV PATH /opt/rh/devtoolset-10/root/usr/bin:$PATH |
|||
COPY --from=llm-code / /go/src/github.com/jmorganca/ollama/ |
|||
WORKDIR /go/src/github.com/jmorganca/ollama/llm/generate |
|||
RUN sh gen_linux.sh |
|||
|
|||
|
|||
FROM --platform=linux/amd64 cpu-build-amd64 AS build-amd64 |
|||
ENV CGO_ENABLED 1 |
|||
ARG GOFLAGS |
|||
ARG CGO_CFLAGS |
|||
WORKDIR /go/src/github.com/jmorganca/ollama |
|||
COPY . . |
|||
COPY --from=cuda-build-amd64 /go/src/github.com/jmorganca/ollama/llm/llama.cpp/build/linux/ llm/llama.cpp/build/linux/ |
|||
COPY --from=rocm-5-build-amd64 /go/src/github.com/jmorganca/ollama/llm/llama.cpp/build/linux/ llm/llama.cpp/build/linux/ |
|||
COPY --from=rocm-6-build-amd64 /go/src/github.com/jmorganca/ollama/llm/llama.cpp/build/linux/ llm/llama.cpp/build/linux/ |
|||
RUN go build . |
|||
|
|||
FROM --platform=linux/arm64 cpu-build-arm64 AS build-arm64 |
|||
ENV CGO_ENABLED 1 |
|||
ARG GOLANG_VERSION |
|||
ARG GOFLAGS |
|||
ARG CGO_CFLAGS |
|||
WORKDIR /go/src/github.com/jmorganca/ollama |
|||
COPY . . |
|||
COPY --from=cuda-build-arm64 /go/src/github.com/jmorganca/ollama/llm/llama.cpp/build/linux/ llm/llama.cpp/build/linux/ |
|||
RUN go build . |
|||
|
|||
FROM build-$TARGETARCH |
|||
Loading…
Reference in new issue