"docs/vscode:/vscode.git/clone" did not exist on "365313edd2658e5d048d97fad04c7729deb9815b"
Dockerfile.build 3.57 KB
Newer Older
1
ARG GOLANG_VERSION=1.21.3
Michael Yang's avatar
Michael Yang committed
2
3
4
ARG CMAKE_VERSION=3.22.1
ARG CUDA_VERSION=11.3.1

Daniel Hiltgen's avatar
Daniel Hiltgen committed
5
6
# Copy the minimal context we need to run the generate scripts
FROM scratch AS llm-code
7
8
9
COPY .git .git
COPY .gitmodules .gitmodules
COPY llm llm
10

Daniel Hiltgen's avatar
Daniel Hiltgen committed
11
12
13
14
15
16
FROM --platform=linux/amd64 nvidia/cuda:$CUDA_VERSION-devel-centos7 AS cuda-build-amd64
ARG CMAKE_VERSION
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/
17
WORKDIR /go/src/github.com/jmorganca/ollama/llm/generate
Daniel Hiltgen's avatar
Daniel Hiltgen committed
18
RUN OLLAMA_SKIP_CPU_GENERATE=1 sh gen_linux.sh
Michael Yang's avatar
Michael Yang committed
19
20
21

FROM --platform=linux/arm64 nvidia/cuda:$CUDA_VERSION-devel-rockylinux8 AS cuda-build-arm64
ARG CMAKE_VERSION
Daniel Hiltgen's avatar
Daniel Hiltgen committed
22
23
24
25
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/
26
WORKDIR /go/src/github.com/jmorganca/ollama/llm/generate
Daniel Hiltgen's avatar
Daniel Hiltgen committed
27
RUN OLLAMA_SKIP_CPU_GENERATE=1 sh gen_linux.sh
Michael Yang's avatar
Michael Yang committed
28

29
FROM --platform=linux/amd64 rocm/dev-centos-7:5.7.1-complete AS rocm-5-build-amd64
Michael Yang's avatar
Michael Yang committed
30
ARG CMAKE_VERSION
Daniel Hiltgen's avatar
Daniel Hiltgen committed
31
32
COPY ./scripts/rh_linux_deps.sh /
RUN CMAKE_VERSION=${CMAKE_VERSION} sh /rh_linux_deps.sh
Michael Yang's avatar
Michael Yang committed
33
34
ENV PATH /opt/rh/devtoolset-10/root/usr/bin:$PATH
ENV LIBRARY_PATH /opt/amdgpu/lib64
Daniel Hiltgen's avatar
Daniel Hiltgen committed
35
COPY --from=llm-code / /go/src/github.com/jmorganca/ollama/
36
37
WORKDIR /go/src/github.com/jmorganca/ollama/llm/generate
RUN OLLAMA_SKIP_CPU_GENERATE=1 sh gen_linux.sh
Michael Yang's avatar
Michael Yang committed
38

39
40
FROM --platform=linux/amd64 rocm/dev-centos-7:6.0-complete AS rocm-6-build-amd64
ARG CMAKE_VERSION
Daniel Hiltgen's avatar
Daniel Hiltgen committed
41
42
COPY ./scripts/rh_linux_deps.sh /
RUN CMAKE_VERSION=${CMAKE_VERSION} sh /rh_linux_deps.sh
43
44
ENV PATH /opt/rh/devtoolset-10/root/usr/bin:$PATH
ENV LIBRARY_PATH /opt/amdgpu/lib64
Daniel Hiltgen's avatar
Daniel Hiltgen committed
45
COPY --from=llm-code / /go/src/github.com/jmorganca/ollama/
46
47
WORKDIR /go/src/github.com/jmorganca/ollama/llm/generate
RUN OLLAMA_SKIP_CPU_GENERATE=1 sh gen_linux.sh
Michael Yang's avatar
Michael Yang committed
48

Daniel Hiltgen's avatar
Daniel Hiltgen committed
49
50
FROM --platform=linux/amd64 centos:7 AS cpu-build-amd64
ARG CMAKE_VERSION
Michael Yang's avatar
Michael Yang committed
51
ARG GOLANG_VERSION
52
ARG OLLAMA_CUSTOM_CPU_DEFS
Daniel Hiltgen's avatar
Daniel Hiltgen committed
53
54
55
56
57
58
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
Michael Yang's avatar
Michael Yang committed
59

Daniel Hiltgen's avatar
Daniel Hiltgen committed
60
61
62
FROM --platform=linux/arm64 centos:7 AS cpu-build-arm64
ARG CMAKE_VERSION
ARG GOLANG_VERSION
63
ARG OLLAMA_CUSTOM_CPU_DEFS
Daniel Hiltgen's avatar
Daniel Hiltgen committed
64
65
COPY ./scripts/rh_linux_deps.sh /
RUN CMAKE_VERSION=${CMAKE_VERSION} GOLANG_VERSION=${GOLANG_VERSION} sh /rh_linux_deps.sh
Michael Yang's avatar
Michael Yang committed
66
ENV PATH /opt/rh/devtoolset-10/root/usr/bin:$PATH
Daniel Hiltgen's avatar
Daniel Hiltgen committed
67
68
69
COPY --from=llm-code / /go/src/github.com/jmorganca/ollama/
WORKDIR /go/src/github.com/jmorganca/ollama/llm/generate
RUN sh gen_linux.sh
Michael Yang's avatar
Michael Yang committed
70
71


Daniel Hiltgen's avatar
Daniel Hiltgen committed
72
73
74
75
FROM --platform=linux/amd64 cpu-build-amd64 AS build-amd64
ENV CGO_ENABLED 1
ARG GOFLAGS
ARG CGO_FLAGS
Michael Yang's avatar
Michael Yang committed
76
77
WORKDIR /go/src/github.com/jmorganca/ollama
COPY . .
78
79
80
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/
Michael Yang's avatar
Michael Yang committed
81
82
RUN go build .

Daniel Hiltgen's avatar
Daniel Hiltgen committed
83
FROM --platform=linux/arm64 cpu-build-arm64 AS build-arm64
Michael Yang's avatar
Michael Yang committed
84
85
86
87
88
89
ENV CGO_ENABLED 1
ARG GOLANG_VERSION
ARG GOFLAGS
ARG CGO_FLAGS
WORKDIR /go/src/github.com/jmorganca/ollama
COPY . .
90
COPY --from=cuda-build-arm64 /go/src/github.com/jmorganca/ollama/llm/llama.cpp/build/linux/ llm/llama.cpp/build/linux/
Michael Yang's avatar
Michael Yang committed
91
RUN go build .
Michael Yang's avatar
Michael Yang committed
92

Michael Yang's avatar
Michael Yang committed
93
FROM build-$TARGETARCH