forked from OpenNMT/OpenNMT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
102 lines (90 loc) · 3.36 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
FROM nvidia/cuda:8.0-devel-ubuntu16.04 as torch_builder
RUN apt-get update && \
apt-get install -y \
autoconf \
automake \
build-essential \
cmake \
curl \
g++ \
gcc \
git \
libprotobuf-dev \
libprotobuf9v5 \
libreadline-dev \
libtool \
libzmq-dev \
pkg-config \
protobuf-compiler \
unzip \
wget
# Fetch Intel MKL.
RUN mkdir /root/mkl && \
wget https://anaconda.org/intel/mkl/2018.0.1/download/linux-64/mkl-2018.0.1-intel_4.tar.bz2 && \
tar -xf mkl-2018.0.1-intel_4.tar.bz2 -C /root/mkl && \
rm mkl-2018.0.1-intel_4.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 && \
./autogen.sh && \
./configure --prefix=/root/sentencepiece && \
make && \
make install && \
cd /root && \
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/>
RUN apt-get update && \
apt-get install -y --no-install-recommends \
libgomp1 \
libprotobuf9v5 \
libzmq1 \
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
WORKDIR $ONMT_DIR