-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDockerfile.llm
112 lines (102 loc) · 5.45 KB
/
Dockerfile.llm
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# Copyright (c) 2023 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ============================================================================
#
# THIS IS A GENERATED DOCKERFILE.
#
# This file was assembled from multiple pieces, whose use is documented
# throughout. Please refer to the TensorFlow dockerfiles documentation
# for more information.
#
# ============================================================================
# How to build:
# docker build ./ -f DockerFile.llm -t llm_centos8:latest
# If you need to use proxy, please use the following command
# docker build ./ --build-arg http_proxy=${http_proxy} --build-arg https_proxy=${http_proxy} -f DockerFile.llm -t llm_centos8:latest
FROM centos:centos8
WORKDIR /opt/installs/
RUN dnf --disablerepo '*' --enablerepo=extras swap centos-linux-repos centos-stream-repos -y && \
yum update -y && yum install -y unzip which zip vim wget && \
yum -y install epel-release && \
yum -y install git openssl-devel make gcc-c++ automake autoconf libtool python3 python3-pip \
graphviz numactl* mesa-libGL && \
yum -y groupinstall "Development Tools" && \
yum -y install gcc-toolset-11* cmake expect libfabric && \
yum -y install libsndfile
# Build LLVM for IPEX Semi-compiler
RUN cd /opt/installs && git clone --depth 1 --branch llvmorg-13.0.0 https://github.com/llvm/llvm-project && \
cd llvm-project && mkdir build && cd build && \
cmake ../llvm -DCMAKE_INSTALL_PREFIX=/opt/llvm -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD=X86 -DLLVM_INCLUDE_TESTS=OFF -DLLVM_INCLUDE_EXAMPLES=OFF -DLLVM_ENABLE_TERMINFO=OFF -DCMAKE_CXX_FLAGS="-D_GLIBCXX_USE_CXX11_ABI=0" && \
make install -j && \
ln -s /opt/llvm/bin/llvm-config /usr/local/bin/llvm-config-13
# Prepare the Conda environment
RUN cd /opt/installs && wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O anaconda3.sh && \
chmod +x anaconda3.sh && \
./anaconda3.sh -b -p ~/anaconda3 && \
rm ./anaconda3.sh
ENV PATH=~/anaconda3/bin/:${PATH}
RUN export PATH=~/anaconda3/bin/:${PATH} && \
conda config --add channels intel && \
conda install -c intel -y intel-openmp && \
conda create -yn llm python=3.9 && \
source activate llm && \
pip install pip && \
pip install lark-parser hypothesis tornado tqdm Pillow yacs opencv-python pycocotools cityscapesscripts unidecode inflect \
librosa==0.8.1 toml soundfile==0.10.3.post1 ipdb sox tensorboard==2.0.0 jinja2 psutil pytest scikit-learn onnx && \
conda config --add channels intel && \
conda install -y openblas && \
conda install gperftools -c conda-forge -y && \
pip install intel-openmp matplotlib typing_extensions future six requests dataclasses \
ninja pyyaml setuptools cmake cffi typing intel-openmp mkl mkl-include numpy cpuid datasets pip install sympy && \
pip3 install https://download.pytorch.org/whl/nightly/cpu/torch-2.1.0.dev20230518%2Bcpu-cp39-cp39-linux_x86_64.whl --no-deps
# Build IPEX
RUN source /root/anaconda3/bin/activate llm && \
pip install mkl intel-openmp && \
cd /opt/installs && git clone -b master https://github.com/intel/intel-extension-for-pytorch.git ipex-cpu && \
cd /opt/installs/ipex-cpu && git checkout de88d93 && git submodule sync && git submodule update --init --recursive && \
export DNNL_GRAPH_BUILD_COMPILER_BACKEND=1 && \
source /opt/rh/gcc-toolset-11/enable && \
rm -rf /root/anaconda3/lib/libstdc++.so* && \
rm -rf /root/anaconda3/envs/llm/lib/libstdc++.so* && \
python setup.py install
# Build TPP extension for Pytorch
RUN source /root/anaconda3/bin/activate llm && \
pip install accelerate protobuf==3.20.3 numpy==1.23.5 && \
cd /opt/installs && git clone -b gpt_infer --depth 1 https://github.com/libxsmm/tpp-pytorch-extension.git && \
cd /opt/installs/tpp-pytorch-extension && git submodule update --init && \
source /opt/rh/gcc-toolset-11/enable && \
python setup.py install
# Build neural-compressor only for int8
RUN source /root/anaconda3/bin/activate llm && \
cd /opt/installs && git clone -b master --depth 1 https://github.com/intel/neural-compressor.git && \
cd /opt/installs/neural-compressor && \
pip install -r requirements.txt && \
python setup.py install
# Build Transformer
COPY transformers.patch /opt/installs
RUN source /root/anaconda3/bin/activate llm && \
cd /opt/installs && git clone -b v4.26.1 --depth 1 https://github.com/huggingface/transformers.git && \
cd /opt/installs/transformers && git submodule update --init --recursive && \
git apply /opt/installs/transformers.patch && \
python setup.py install
RUN /root/anaconda3/bin/conda clean -y -all && \
yum clean all && \
rm -rf /opt/installs/
ENV BASH_ENV=/opt/.bash_profile
# Env config
ENV KMP_BLOCKTIME=1
ENV KMP_AFFINITY="granularity=fine,compact,1,0"
# IOMP & TcMalloc
ENV LD_PRELOAD=/root/anaconda3/envs/llm/lib/libiomp5.so:/root/anaconda3/envs/llm/lib/libtcmalloc.so:${LD_PRELOAD}
WORKDIR /root/workspace/