前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >crnn docker/nvidia-docker 安装

crnn docker/nvidia-docker 安装

作者头像
bear_fish
发布2018-09-14 09:49:07
1.1K0
发布2018-09-14 09:49:07
举报

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://cloud.tencent.com/developer/article/1338339

本文主要是记录使用docker/nvidia-docker安装深度学习图片文字识别,开发运行环境.

在做图片文字识别的,需要用到CTPN以及crnn,服务器是ubuntu16的,但是上述两种框架(github现有的)只能运行在ubuntu14上面。考虑到,发布等问题,决定使用docker在ubuntu16搭建ubuntu14 cuda7.5 cudnn3开发运行环境。 crnn的docker安装是在CTPN的docker的基础上面安装。

安装之前记得thpp_build.sh文件要做一定的修改(cuda兼容):

代码语言:javascript
复制
# replace error, https://github.com/facebook/thpp/commit/d9f982c68d7522db9e77e50d135eaa86d84bab85#diff-22577c98d557ea9eca089e8e84d7f98d
sed -i '191s/.*/return THTensor_(max)(values, indices, t, dim,1);/' detail/TensorGeneric.h
sed -i '195s/.*/return THTensor_(min)(values, indices, t, dim,1);/' detail/TensorGeneric.h
sed -i '198s/.*/return THTensor_(sum)(r, t, dim,1);/' detail/TensorGeneric.h 
sed -i '201s/.*/return THTensor_(prod)(r, t, dim,1);/' detail/TensorGeneric.h 

docker文件如下:

代码语言:javascript
复制
# 基于前面的CTPN
FROM ctpn_docker
MAINTAINER xiongyu haluoluo@qq.com

RUN apt-get update && apt-get install -y \
  software-properties-common \
  libssl-dev \
  libzmq3-dev \
  python-dev \
  python-zmq \
  sudo

# Run Torch7 installation scripts
RUN git clone https://github.com/torch/distro.git /root/torch --recursive && cd /root/torch && \
  bash install-deps && \
  ./install.sh

# Export environment variables manually
ENV LUA_PATH='/root/.luarocks/share/lua/5.1/?.lua;/root/.luarocks/share/lua/5.1/?/init.lua;/root/torch/install/share/lua/5.1/?.lua;/root/torch/install/share/lua/5.1/?/init.lua;./?.lua;/root/torch/install/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;/root/torch/install/lib/lua/5.1/?.so;./?.so;/usr/local/lib/lua/5.1/?.so;/usr/local/lib/lua/5.1/loadall.so'
ENV PATH=/root/torch/install/bin:$PATH
ENV LD_LIBRARY_PATH=/root/torch/install/lib:$LD_LIBRARY_PATH
ENV DYLD_LIBRARY_PATH=/root/torch/install/lib:$DYLD_LIBRARY_PATH
ENV LUA_CPATH='/root/torch/install/lib/?.so;'$LUA_CPATH

ADD torch-0.1.12.post2-cp27-none-linux_x86_64.whl /root/pytorch_install/torch-0.1.12.post2-cp27-none-linux_x86_64.whl
WORKDIR /root/pytorch_install/
RUN pip install torch-0.1.12.post2-cp27-none-linux_x86_64.whl &&\
    rm torch-0.1.12.post2-cp27-none-linux_x86_64.whl
RUN pip install torchvision
RUN pip install lmdb -i https://pypi.tuna.tsinghua.edu.cn/simple/
RUN pip install mahotas -i https://pypi.tuna.tsinghua.edu.cn/simple/
RUN pip install Flask -i https://pypi.tuna.tsinghua.edu.cn/simple/
# Install fblualib and its dependencies :
ADD install_all.sh /root/install_all.sh
ADD thpp_build.sh /root/thpp_build.sh

WORKDIR /root
RUN chmod +x ./install_all.sh
RUN ./install_all.sh

# Clone the crnn repo :
RUN git clone https://github.com/bgshih/crnn.git
RUN apt-get update && apt-get install -y \
        liblmdb-dev

WORKDIR /root/crnn/src
RUN chmod +x build_cpp.sh
RUN ./build_cpp.sh
# 下面的locale是为了,显示中文
RUN locale-gen en_US.UTF-8
ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8'

运行结果:

最终基于flask做了一个web demo,运行结果如下:

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2018年03月22日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
容器服务
腾讯云容器服务(Tencent Kubernetes Engine, TKE)基于原生 kubernetes 提供以容器为核心的、高度可扩展的高性能容器管理服务,覆盖 Serverless、边缘计算、分布式云等多种业务部署场景,业内首创单个集群兼容多种计算节点的容器资源管理模式。同时产品作为云原生 Finops 领先布道者,主导开源项目Crane,全面助力客户实现资源优化、成本控制。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档