-
-
Notifications
You must be signed in to change notification settings - Fork 351
umaru docker镜像
wanghaisheng edited this page May 16, 2016
·
10 revisions
[wanghs@db2 docker-umaru]$ docker run -it -v /home/wanghs/ocr/docker-umaru/work/pic_simsun_20words_1line:/umaru/work datacenter/umaru /bin/bash
root@f7138bdf3801:/umaru# cat 7000_setting.json
{
"project_name": "total_7000_words",
"raw_input": false,
"hidden_size": 800,
"nthread": 28,
"ctc_lua": false,
"test_every": 1000,
"stride": 5,
"save_every": 1000,
"gpu": false,
"show_every": 100,
"input_size": 48,
"clamp_size": 1,
"max_param_norm": false,
"testing_ratio": 0.9,
"momentum": 0.9,
"dropout_rate": 0,
"max_iter": 10000000000,
"feature_size": 240,
"learning_rate": 0.0001,
"training_list_file": "all-trainning.txt",
"omp_threads": 1,
"recurrent_unit": "gru",
"windows_size": 10
}
root@f7138bdf3801:/umaru# th main.lua -setting 7000_setting.json
[0.0001][0.0001]loading setting file 7000_setting.json
[0.0010][0.0010]setting file loaded successfully.
[program started on Mon May 16 06:21:55 2016]
[command line arguments]
project_name total_7000_words
raw_input false
hidden_size 800
nthread 28
ctc_lua false
test_every 1000
testing_ratio 0.9
show_every 100
recurrent_unit gru
input_size 48
clamp_size 1
max_param_norm false
omp_threads 1
training_list_file all-trainning.txt
momentum 0.9
dropout_rate 0
max_iter 10000000000
save_every 1000
learning_rate 0.0001
feature_size 240
stride 5
gpu false
windows_size 10
1.torch的docker镜像 https://github.com/vifino/docker-torch-alpine
最终选择基于ubuntu的
[wanghs@db2 docker-umaru]$ cat Dockerfile
From datacenter/torch7-ubuntu
# install cuda before cunn
#RUN apt-get update && \
# apt-get -y install linux-generic && \
# dpkg -i cuda-repo-ubuntu1404-7-5-local_7.5-18_amd64.deb && \
# apt-get update && \
# apt-get install cuda && \
# echo "export PATH=/usr/local/cuda/bin/:\$PATH; export LD_LIBRARY_PATH=/usr/local/cuda/lib64/:\$LD_LIBRARY_PATH; " >>~/.bashrc && source ~/.bashrc
RUN luarocks install image
# luarocks install cunn && \
RUN luarocks install optim
RUN luarocks install rnn
RUN luarocks install json
RUN luarocks install utf8
# 已经包含在源码中
#RUN git clone https://github.com/nhammerla/torchRBM && cd torchRBM
#RUN luarocks install torchRBM
RUN git clone https://github.com/edward-zhu/umaru.git && \
cd umaru && mkdir work && \
./build.sh
WORKDIR /umaru/work
VOLUME /umaru/work
[wanghs@db2 docker-umaru]$
FROM ubuntu:14.04
MAINTAINER Soumith Chintala <[email protected]>
RUN apt-get update
###############################
#### Install dependencies for torch
###############################
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update
RUN apt-get dist-upgrade -y
RUN apt-get -y dist-upgrade
RUN apt-get -y install python-software-properties
RUN apt-get -y install software-properties-common
RUN apt-get update
RUN apt-get install -y build-essential
RUN apt-get install -y gcc g++
RUN apt-get install -y cmake
RUN apt-get install -y curl
RUN apt-get install -y libreadline-dev
RUN apt-get install -y git-core
RUN apt-get install -y libqt4-core libqt4-gui libqt4-dev
RUN apt-get install -y libjpeg-dev
RUN apt-get install -y libpng-dev
RUN apt-get install -y ncurses-dev
RUN apt-get install -y imagemagick
RUN apt-get install -y libzmq3-dev
RUN apt-get install -y gfortran
RUN apt-get install -y unzip
RUN apt-get install -y gnuplot
RUN apt-get install -y gnuplot-x11
RUN apt-get install -y libsdl2-dev
RUN apt-get install -y libgraphicsmagick1-dev
RUN apt-get install -y nodejs
RUN apt-get install -y npm
RUN apt-get install -y libfftw3-dev sox libsox-dev libsox-fmt-all
RUN apt-get update
RUN git clone https://github.com/xianyi/OpenBLAS.git /tmp/OpenBLAS
RUN cd /tmp/OpenBLAS && make NO_AFFINITY=1 USE_OPENMP=1 && make install
###########################################
### Now install torch
###########################################
ENV CMAKE_LIBRARY_PATH /opt/OpenBLAS/include:/opt/OpenBLAS/lib:$CMAKE_LIBRARY_PATH
ENV PATH /usr/local/bin:$PATH
RUN git clone https://github.com/torch/luajit-rocks.git /tmp/luajit-rocks
WORKDIR /tmp/luajit-rocks
RUN mkdir build;
WORKDIR /tmp/luajit-rocks/build
RUN git checkout master;
RUN git pull
RUN rm -f CMakeCache.txt
RUN cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_BUILD_TYPE=Release -DWITH_LUAJIT21=ON
RUN make
RUN make install
RUN luarocks install sundown
RUN luarocks install cwrap
RUN luarocks install paths
RUN luarocks install torch
RUN luarocks install nn
RUN luarocks install dok
RUN luarocks install gnuplot
RUN luarocks install qtlua
RUN luarocks install qttorch
RUN luarocks install luafilesystem
RUN luarocks install penlight
RUN luarocks install sys
RUN luarocks install xlua
RUN luarocks install image
RUN luarocks install optim
RUN luarocks install lua-cjson
RUN luarocks install trepl
RUN luarocks install nnx
RUN luarocks install threads
RUN luarocks install graphicsmagick
RUN luarocks install argcheck
RUN luarocks install audio
RUN luarocks install signal
RUN luarocks install gfx.js
ENV LD_LIBRARY_PATH /usr/local/lib:/opt/OpenBLAS/lib:$LD_LIBRARY_PATH
[wanghs@db2 docker-umaru]$ cat Dockerfile
####################
# Torch Dockerfile #
# Alpine-based #
####################
FROM alpine
MAINTAINER wanghaisheng
RUN \
echo http://dl-cdn.alpinelinux.org/alpine/edge/testing >> /etc/apk/repositories && \
sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/' /etc/apk/repositories && \
apk update && \
apk upgrade && \
apk add \
alpine-sdk openblas-dev cmake curl readline-dev ncurses ncurses-dev wget \
git gnuplot unzip libjpeg-turbo-dev libpng-dev gfortran perl openssl-dev \
imagemagick-dev graphicsmagick-dev fftw-dev zeromq-dev bash jemalloc-dev \
&& \
git clone https://github.com/torch/distro.git /usr/src/torch --recursive && \
git clone --depth=1 --branch=v2.1 https://github.com/luajit/luajit /usr/src/luajit && \
cd /usr/src/torch && \
sed -i 's/PREFIX=\$.*/PREFIX=\/torch/g' install.sh && \
sed -i "s/\-DHAVE_MALLOC_USABLE_SIZE=1/\-DHAVE_MALLOC_USABLE_SIZE=0/" /usr/src/torch/pkg/torch/lib/TH/CMakeLists.txt && \
mkdir /torch && \
./install.sh && \
ln -sf /torch/bin/torch-activate /etc/profile.d/torch.sh && \
cd /usr/src/luajit && \
make PREFIX=/torch LDFLAGS="-ljemalloc" && \
make PREFIX=/torch LDFLAGS="-ljemalloc" install && \
ln -sf luajit-2.1.0-beta1 /torch/bin/luajit && \
rm /torch/lib/libluajit.so && ln -sf /torch/lib/libluajit-5.1.so /torch/lib/libluajit.so && \
cp /torch/lib/pkgconfig/luajit.pc /usr/lib/pkgconfig/luajit.pc && \
ln -sf /torch/bin/* /usr/bin/ && \
ln -sf /torch/lib/pkgconfig/* /usr/lib/pkgconfig/* && \
ln -sf /torch/include/* /usr/include && \
cd / && \
rm -rf /usr/src && \
apk del --purge cmake perl && \
rm -rf /var/cache/apk/*
# Lua Path and more.
env LUA_PATH '/root/.luarocks/share/lua/5.1/?.lua;/root/.luarocks/share/lua/5.1/?/init.lua;/torch/share/lua/5.1/?.lua;/torch/share/lua/5.1/?/init.lua;./?.lua;/torch/share/luajit-2.1.0-beta1/?.lua;/usr/local/share/lua/5.1/?.lua;/usr/local/share/lua/5.1/?/init.lua'
env LUA_CPATH '/root/.luarocks/lib/lua/5.1/?.so;/torch/lib/?.so;/torch/lib/lua/5.1/?.so;./?.so;/usr/local/lib/lua/5.1/?.so;/usr/local/lib/lua/5.1/loadall.so'
CMD ["/torch/bin/luajit", "-ltorch"]
[wanghs@db2 docker-umaru]$ cat torch.pc
# Package information for Torch7 to be used by pkg-config.
majver=2
minver=1
relver=0
version=${majver}.${minver}.${relver}
abiver=5.1
prefix=/torch
multilib=lib
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
libname=luajit
includedir=${prefix}/include
INSTALL_LMOD=${prefix}/share/lua/${abiver}
INSTALL_CMOD=${prefix}/lib/lua/${abiver}
Name: LuaJIT
Description: Just-in-time compiler for Lua
URL: http://luajit.org
Version: ${version}
Requires:
Libs: -L${libdir} -l${libname}
Libs.private: -Wl,-E -lm -ldl
- umaru的docker镜像 torch (and following packages) image nn/cunn optim rnn json utf8 torchRBM
luarocks install image
luarocks install nn
luarocks install cunn
luarocks install optim
luarocks install rnn
luarocks install json
luarocks install utf8
luarocks install torchRBM
3.使用torch7官方推荐的安装方法 会提示alpine linux不支持此种方式安装
[wanghs@db2 ~]$ cat ocr/docker-umaru/Dockerfile
####################
# Torch Dockerfile #
# Alpine-based #
####################
FROM alpine
MAINTAINER wanghaisheng
RUN \
echo http://dl-cdn.alpinelinux.org/alpine/edge/testing >> /etc/apk/repositories && \
sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/' /etc/apk/repositories && \
apk update && \
apk upgrade && \
apk add \
alpine-sdk openblas-dev cmake curl readline-dev ncurses ncurses-dev wget \
git gnuplot unzip libjpeg-turbo-dev libpng-dev gfortran perl openssl-dev \
imagemagick-dev graphicsmagick-dev fftw-dev zeromq-dev bash jemalloc-dev \
&& \
git clone https://github.com/torch/distro.git /usr/src/torch --recursive && \
git clone --depth=1 --branch=v2.1 https://github.com/luajit/luajit /usr/src/luajit && \
cd /usr/src/torch && \
sed -i 's/PREFIX=\$.*/PREFIX=\/torch/g' install.sh && \
sed -i "s/\-DHAVE_MALLOC_USABLE_SIZE=1/\-DHAVE_MALLOC_USABLE_SIZE=0/" /usr/src/torch/pkg/torch/lib/TH/CMakeLists.txt && \
mkdir /torch && \
./install.sh && \
ln -sf /torch/bin/torch-activate /etc/profile.d/torch.sh && \
cd /usr/src/luajit && \
make PREFIX=/torch LDFLAGS="-ljemalloc" && \
make PREFIX=/torch LDFLAGS="-ljemalloc" install && \
ln -sf luajit-2.1.0-beta1 /torch/bin/luajit && \
rm /torch/lib/libluajit.so && ln -sf /torch/lib/libluajit-5.1.so /torch/lib/libluajit.so && \
cp /torch/lib/pkgconfig/luajit.pc /usr/lib/pkgconfig/luajit.pc && \
ln -sf /torch/bin/* /usr/bin/ && \
ln -sf /torch/lib/pkgconfig/* /usr/lib/pkgconfig/* && \
ln -sf /torch/include/* /usr/include && \
cd / && \
rm -rf /usr/src && \
apk del --purge cmake perl && \
rm -rf /var/cache/apk/*
# Lua Path and more.
env LUA_PATH '/root/.luarocks/share/lua/5.1/?.lua;/root/.luarocks/share/lua/5.1/?/init.lua;/torch/share/lua/5.1/?.lua;/torch/share/lua/5.1/?/init.lua;./?.lua;/torch/share/luajit-2.1.0-beta1/?.lua;/usr/local/share/lua/5.1/?.lua;/usr/local/share/lua/5.1/?/init.lua'
env LUA_CPATH '/root/.luarocks/lib/lua/5.1/?.so;/torch/lib/?.so;/torch/lib/lua/5.1/?.so;./?.so;/usr/local/lib/lua/5.1/?.so;/usr/local/lib/lua/5.1/loadall.so'
CMD ["/torch/bin/luajit", "-ltorch"]
[wanghs@db2 ~]$ cat ocr/docker-umaru/Dockerfile.failed.notsupport.alpine
From datacenter/torch7
env LUA_PATH '/root/.luarocks/share/lua/5.1/?.lua;/root/.luarocks/share/lua/5.1/?/init.lua;/torch/share/lua/5.1/?.lua;/torch/share/lua/5.1/?/init.lua;./?.lua;/torch/share/luajit-2.1.0-beta1/?.lua;/usr/local/share/lua/5.1/?.lua;/usr/local/share/lua/5.1/?/init.lua'
env LUA_CPATH '/root/.luarocks/lib/lua/5.1/?.so;/torch/lib/?.so;/torch/lib/lua/5.1/?.so;./?.so;/usr/local/lib/lua/5.1/?.so;/usr/local/lib/lua/5.1/loadall.so'
# Build Luarocks.
RUN wget http://luarocks.org/releases/luarocks-2.3.0.tar.gz && \
tar zxpf luarocks-2.3.0.tar.gz && \
cd luarocks-2.3.0 && \
./configure; make bootstrap
RUN luarocks install image && \
luarocks install nn && \
luarocks install cunn && \
luarocks install optim && \
luarocks install rnn && \
luarocks install json && \
luarocks install utf8 && \
luarocks install torchRBM
RUN git clone https://github.com/edward-zhu/umaru.git && \
cd umaru && mkdir work && \
./build.sh
WORKDIR /umaru/work
VOLUME /umaru/work