File size: 2,457 Bytes
a1c3f58
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
FROM nvidia/cuda:11.3.1-cudnn8-devel-ubuntu18.04

ARG LLAMA_CPP_VERSION="v0.1.53"
ARG CMAKE_VERSION=3.26
ARG CMAKE_VERSION_PATCH=3.26.3
ARG CMAKE_OS=linux
ARG DEBIAN_FRONTEND=noninteractive
ENV TZ=UTC

RUN apt-get update && \
    apt-get install --no-install-recommends -y \
      curl git vim build-essential software-properties-common python3 python3-pip python3-dev python3-venv \
      libffi-dev libncurses5-dev zlib1g zlib1g-dev libreadline-dev libbz2-dev libsqlite3-dev libssl-dev \
      libblas-dev liblapack-dev cmake && \
    add-apt-repository ppa:ubuntu-toolchain-r/test && \
    apt-get update && \
    apt install --no-install-recommends -y gcc-10 g++-10 && \
    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 && \
    rm -rf /var/lib/apt/lists/* && \
    pip3 install scikit-build
RUN curl -L https://cmake.org/files/v$CMAKE_VERSION/cmake-$CMAKE_VERSION_PATCH-$CMAKE_OS-x86_64.sh -o /tmp/cmake-$CMAKE_VERSION_PATCH-$CMAKE_OS-x86_64.sh && \
    mkdir /opt/cmake && \
    sh /tmp/cmake-$CMAKE_VERSION_PATCH-$CMAKE_OS-x86_64.sh --skip-license --prefix=/opt/cmake && \
    ln -s /opt/cmake/bin/cmake /usr/local/bin/cmake

RUN useradd -m -u 1000 appuser

WORKDIR /build
RUN chown appuser:appuser /build
USER appuser

ENV HOME /home/appuser
ENV PYENV_ROOT $HOME/.pyenv
ENV PATH $PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH

RUN git clone --depth 1 --branch $LLAMA_CPP_VERSION https://github.com/abetlen/llama-cpp-python.git /build
RUN git clone https://github.com/ggerganov/llama.cpp.git /build/vendor/llama.cpp
RUN curl https://pyenv.run | bash

RUN pyenv install 3.8.9 && \
    pyenv global 3.8.9 && \
    pyenv rehash && \
    pip install --no-cache-dir --upgrade pip==22.3.1 setuptools wheel && \
    pip install --no-cache-dir datasets "huggingface-hub>=0.12.1" "protobuf<4" "click<8.1" "scikit-build" && \
    CMAKE_ARGS="-DLLAMA_CUBLAS=on" FORCE_CMAKE=1 python3 setup.py bdist_wheel && \
    mkdir /build/dists/ && \
    cp dist/llama_cpp_python-${LLAMA_CPP_VERSION}-cp38-cp38-linux_x86_64.whl dists/llama_cpp_python-gpu-${LLAMA_CPP_VERSION}-cp38-cp38-linux_x86_64.whl && \
    CMAKE_ARGS="-DLLAMA_CUBLAS=off" FORCE_CMAKE=1 python3 setup.py bdist_wheel && \
    cp dist/llama_cpp_python-${LLAMA_CPP_VERSION}-cp38-cp38-linux_x86_64.whl dists/llama_cpp_python-cpu-${LLAMA_CPP_VERSION}-cp38-cp38-linux_x86_64.whl && \
    ls -l /build/dists/