![65a](/assets/img/avatar_default.png)
The build tags rocm or cuda must be specified to both go generate and go build. ROCm builds should have both ROCM_PATH set (and the ROCM SDK present) as well as CLBlast installed (for GGML) and CLBlast_DIR set in the environment to the CLBlast cmake directory (likely /usr/lib/cmake/CLBlast). Build tags are also used to switch VRAM detection between cuda and rocm implementations, using added "accelerator_foo.go" files which contain architecture specific functions and variables. accelerator_none is used when no tags are set, and a helper function addRunner will ignore it if it is the chosen accelerator. Fix go generate commands, thanks @deadmeu for testing.
32 lines
1 KiB
Docker
32 lines
1 KiB
Docker
FROM nvidia/cuda:11.8.0-devel-ubuntu22.04
|
|
|
|
ARG TARGETARCH
|
|
ARG GOFLAGS="'-ldflags=-w -s'"
|
|
|
|
WORKDIR /go/src/github.com/jmorganca/ollama
|
|
RUN apt-get update && apt-get install -y git build-essential cmake
|
|
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
|
|
|
|
COPY . .
|
|
ENV GOARCH=$TARGETARCH
|
|
ENV GOFLAGS=$GOFLAGS
|
|
RUN /usr/local/go/bin/go generate -tags cuda ./... \
|
|
&& /usr/local/go/bin/go build -tags cuda .
|
|
|
|
FROM ubuntu:22.04
|
|
RUN apt-get update && apt-get install -y ca-certificates
|
|
COPY --from=0 /go/src/github.com/jmorganca/ollama/ollama /bin/ollama
|
|
EXPOSE 11434
|
|
ENV OLLAMA_HOST 0.0.0.0
|
|
|
|
# set some environment variable for better NVIDIA compatibility
|
|
ENV PATH=/usr/local/nvidia/bin:/usr/local/cuda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
|
ENV LD_LIBRARY_PATH=/usr/local/nvidia/lib:/usr/local/nvidia/lib64
|
|
ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility
|
|
|
|
ENTRYPOINT ["/bin/ollama"]
|
|
CMD ["serve"]
|
|
|
|
|