forked from singnet/nlp-services
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
141 lines (121 loc) · 4.66 KB
/
Dockerfile
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
FROM nvidia/cuda:8.0-devel-ubuntu16.04 as torch_builder
RUN apt update && \
apt install -y \
autoconf \
automake \
build-essential \
cmake \
curl \
g++ \
gcc \
git \
libprotobuf-dev \
libprotobuf9v5 \
libreadline-dev \
libtool \
libzmq-dev \
pkg-config \
protobuf-compiler \
unzip \
nano \
wget
# Fetch Intel MKL.
RUN mkdir /root/mkl && \
wget https://anaconda.org/intel/mkl/2020.0/download/linux-64/mkl-2020.0-intel_166.tar.bz2 && \
tar -xf mkl-2020.0-intel_166.tar.bz2 -C /root/mkl && \
rm mkl-2020.0-intel_166.tar.bz2
ENV MKL_ROOT=/root/mkl
RUN rm -f $MKL_ROOT/lib/*vml* \
$MKL_ROOT/lib/*ilp64* \
$MKL_ROOT/lib/*blacs* \
$MKL_ROOT/lib/*scalapack* \
$MKL_ROOT/lib/*cdft* \
$MKL_ROOT/lib/libmkl_tbb_thread.so \
$MKL_ROOT/lib/libmkl_ao_worker.so
# Compile Torch and OpenNMT dependencies.
ARG CUDA_ARCH
ENV CUDA_ARCH=${CUDA_ARCH:-Common}
RUN git clone https://github.com/torch/distro.git /root/torch-distro --recursive && \
cd /root/torch-distro && \
mkdir /root/torch && \
CMAKE_LIBRARY_PATH=$CMAKE_LIBRARY_PATH:$MKL_ROOT/lib \
TORCH_CUDA_ARCH_LIST=${CUDA_ARCH} TORCH_NVCC_FLAGS="-Xfatbin -compress-all" \
PREFIX=/root/torch ./install.sh
RUN cp -r $MKL_ROOT/lib/* /root/torch/lib
RUN /root/torch/bin/luarocks install tds && \
/root/torch/bin/luarocks install dkjson && \
/root/torch/bin/luarocks install restserver-xavante && \
/root/torch/bin/luarocks install yaml && \
/root/torch/bin/luarocks install bit32 && \
/root/torch/bin/luarocks install luacheck && \
/root/torch/bin/luarocks install luacov && \
/root/torch/bin/luarocks install lua-zmq \
ZEROMQ_LIBDIR=/usr/lib/x86_64-linux-gnu/ ZEROMQ_INCDIR=/usr/include
# Install lua-sentencepiece
RUN git clone https://github.com/google/sentencepiece.git /root/sentencepiece-git && \
cd /root/sentencepiece-git && \
mkdir build && \
cd build && \
cmake -DCMAKE_INSTALL_PREFIX=/root/sentencepiece .. && \
make -j $(nproc) && \
make install && \
rm -r /root/sentencepiece-git
RUN git clone https://github.com/OpenNMT/lua-sentencepiece.git /root/lua-sentencepiece && \
cd /root/lua-sentencepiece && \
CMAKE_LIBRARY_PATH=/root/sentencepiece/lib CMAKE_INCLUDE_PATH=/root/sentencepiece/include \
/root/torch/bin/luarocks make lua-sentencepiece-scm-1.rockspec \
LIBSENTENCEPIECE_DIR=/root/sentencepiece && \
cd /root && \
rm -r /root/lua-sentencepiece
FROM nvidia/cuda:8.0-runtime-ubuntu16.04
MAINTAINER OpenNMT <http://opennmt.net/>
ARG git_owner="singnet"
ARG git_repo="nlp-services"
ARG git_branch="master"
ARG snetd_version
ENV SINGNET_DIR=/opt/singnet
ENV SERVICE_NAME=opennmt-romance-translator
RUN mkdir -p ${SINGNET_DIR}
RUN apt-get update && \
apt-get install -y --no-install-recommends \
libgomp1 \
libprotobuf9v5 \
libzmq1 \
nano \
wget \
curl \
git \
python3-pip \
python3 && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
ENV TORCH_DIR=/root/torch
ENV SENTENCEPIECE_DIR=/root/sentencepiece
COPY --from=torch_builder /root/torch ${TORCH_DIR}
COPY --from=torch_builder /root/sentencepiece ${SENTENCEPIECE_DIR}
ENV LUA_PATH="${TORCH_DIR}/share/lua/5.1/?.lua;${TORCH_DIR}/share/lua/5.1/?/init.lua;./?.lua"
ENV LUA_CPATH="${TORCH_DIR}/lib/lua/5.1/?.so;./?.so;${TORCH_DIR}/lib/?.so"
ENV PATH=${TORCH_DIR}/bin:${PATH}
ENV LD_LIBRARY_PATH=${TORCH_DIR}/lib:${LD_LIBRARY_PATH}
ENV THC_CACHING_ALLOCATOR=0
ENV ONMT_DIR=/root/opennmt
COPY . $ONMT_DIR
# Install snet daemon
RUN SNETD_GIT_VERSION=`curl -s https://api.github.com/repos/singnet/snet-daemon/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")' || echo "v5.0.1"` && \
SNETD_VERSION=${snetd_version:-${SNETD_GIT_VERSION}} && \
cd /tmp && \
wget https://github.com/singnet/snet-daemon/releases/download/${SNETD_VERSION}/snet-daemon-${SNETD_VERSION}-linux-amd64.tar.gz && \
tar -xvf snet-daemon-${SNETD_VERSION}-linux-amd64.tar.gz && \
mv snet-daemon-${SNETD_VERSION}-linux-amd64/snetd /usr/bin/snetd && \
rm -rf snet-daemon*
RUN cd ${SINGNET_DIR} && \
git clone -b ${git_branch} https://github.com/${git_owner}/${git_repo}.git
RUN cd ${SINGNET_DIR}/${git_repo}/${SERVICE_NAME} && \
pip3 install -U pip==20.3.4 && \
pip3 install -r requirements.txt && \
sh buildproto.sh
RUN cd ${SINGNET_DIR}/${git_repo}/${SERVICE_NAME}/utils && \
bash prepare_data.sh ./data
RUN cd ${SINGNET_DIR}/${git_repo}/${SERVICE_NAME} && \
bash buildproto.sh
WORKDIR ${SINGNET_DIR}/${git_repo}/${SERVICE_NAME}