build openposewith opencv-2.4.13,cuda9(9.0 - 9.2)

基本的流程参见 docker image

这里强调几点重点, 编辑opencv时, 要安装好gtk, 否则摄像头功能不能用, 要安装好
libavcodec-dev
libavformat-dev
libavutil-dev
libswscale-dev
否则视频功能不能用

安装完后, 用下面命令测试视频

./build/examples/openpose/openpose.bin --video ./examples/media/video.avi 

#FROM ubuntu:18.04


FROM nvidia/cuda:9.0-cudnn7-devel-ubuntu16.04
#FROM nvidia/cuda:9.0-cudnn7-runtime


ENV NVIDIA_VISIBLE_DEVICES all
ENV NVIDIA_DRIVER_CAPABILITIES compute,utility

RUN "sh" "-c" "echo nameserver 8.8.8.8 >> /etc/resolv.conf"


ENV CUDA_ARCH_BIN "35 52 60 61"
ENV CUDA_ARCH_PTX "61"

# tj - : add variable for window display

#ENV PATH="/usr/lib/nvidia-418/bin":${PATH}
#ENV LD_LIBRARY_PATH="/usr/lib/nvidia-418:/usr/lib32/nvidia-418":${LD_LIBRARY_PATH}


MAINTAINER Tao Jiang <tjiang.work@gmail.com>


RUN apt-get update 

# tj - : remove python-3.5
#RUN apt-get remove python3
#RUN ls /usr/bin/python*


# tj - : install python-3.6 
RUN apt-get install -y software-properties-common
RUN add-apt-repository ppa:deadsnakes/ppa
#RUN add-apt-repository ppa:jonathonf/python-3.6

RUN apt-get update 
#RUN ls /usr/bin/pytho*


#RUN apt-get upgrade -y python3.6

#RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.5 1
#RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 2
#RUN update-alternatives --config python3
# - tj : switch to python3.6




#RUN ls /usr/bin/pytho*
#RUN which python3
RUN python3 -V

RUN apt-get install -y git \
		       cmake \
		       build-essential \
		       wget \
		       ffmpeg \
		       libatlas-base-dev \
           libboost-all-dev \
           libgflags-dev \
           libgoogle-glog-dev \
           libhdf5-serial-dev \
           libleveldb-dev \
           liblmdb-dev \
           libprotobuf-dev \
           libsnappy-dev \
           protobuf-compiler \
           python-dev \
           python-numpy \
           python-pip \
           python-setuptools \
           python-scipy\
           python3.7 \
           python3-pip \
           libavcodec-dev \
           libavformat-dev \
           libavutil-dev \
           libswscale-dev
#&& \
#rm -rf /var/lib/apt/lists/*


#RUN ls /usr/bin/python*


# tj - : install opencv-2.4.13.6 from my private repo


# tj - : Copy SSH key for git private repos
ADD id_rsa /root/.ssh/id_rsa
RUN chmod 600 /root/.ssh/id_rsa


# tj - : Create known_hosts
RUN touch /root/.ssh/known_hosts

# tj - : Add github key
RUN ssh-keyscan github.com >> /root/.ssh/known_hosts


RUN git clone git@github.com:seamanj/opencv-2.4.13.6.git
RUN cd opencv-2.4.13.6; mkdir build; cd build; cmake ..; make -j$(nproc) install






#RUN apt-get autoremove -y && apt-get autoclean -y		

# tj - : build caffe

RUN apt-get install -y liblmdb-dev libleveldb-dev libsnappy-dev

# 
ENV CAFFE_ROOT=/opt/caffe
WORKDIR $CAFFE_ROOT
#ENV CAFFE_CLONE_TAG=1.0
#
RUN git clone https://github.com/CMU-Perceptual-Computing-Lab/caffe.git . && \
	mkdir build && cd build && \
	cmake -DCUDA_ARCH_NAME=Manual -DCUDA_ARCH_BIN="${CUDA_ARCH_BIN}" -DCUDA_ARCH_PTX="${CUDA_ARCH_PTX}" -DCUDA_USE_STATIC_CUDA_RUNTIME=OFF .. && \
	make -j$(nproc) install



#    python -m pip install --upgrade pip setuptools wheel && \
#    cd python && for req in $(cat requirements.txt); do pip install $req; done && cd .. && \
#    mkdir build && cd build && \
#    cmake -DUSE_CUDNN=1 -DCUDA_ARCH_NAME=Manual -DCUDA_ARCH_BIN="${CUDA_ARCH_BIN}" #-DCUDA_ARCH_PTX="${CUDA_ARCH_PTX}" -DCUDA_USE_STATIC_CUDA_RUNTIME=OFF .. && \
#    make all -j && \
#    make install
#
#ENV PYCAFFE_ROOT $CAFFE_ROOT/python
#ENV PYTHONPATH $PYCAFFE_ROOT:$PYTHONPATH
#ENV PATH $CAFFE_ROOT/build/tools:$PYCAFFE_ROOT:$PATH
#RUN echo "$CAFFE_ROOT/build/lib" >> /etc/ld.so.conf.d/caffe.conf && ldconfig
#
#RUN python -m pip install --upgrade numpy protobuf


# tj - : build openpose


ENV OPENPOSE_ROOT=/opt/openpose
WORKDIR $OPENPOSE_ROOT

#ENV OPENPOSE_SHA=99855c6a42836989272329747a24ac23f71217e8


# tj - : component to support caffe
#RUN apt-get install -y nvidia-modprobe \
#                      module-init-tools

#RUN apt-get -y purge nvidia-*
#RUN apt-get -y autoremove
#RUN add-apt-repository ppa:graphics-drivers/ppa
#RUN apt update
#RUN DEBIAN_FRONTEND=noninteractive apt-get install -y -f  *nvidia*396*
#RUN reboot

# tj - : sed replace the string

RUN git clone https://github.com/CMU-Perceptual-Computing-Lab/openpose.git . && \
    sed -i 's/set(Caffe_known_gpu_archs "${KEPLER} ${MAXWELL} ${PASCAL} ${VOLTA} ${TURING}")/set(Caffe_known_gpu_archs "${KEPLER} ${MAXWELL} ${PASCAL}")/' /opt/openpose/cmake/Cuda.cmake && \
    mkdir build && cd build && \
    cmake -DDOWNLOAD_BODY_COCO_MODEL=OFF \
          -DDOWNLOAD_BODY_MPI_MODEL=OFF \
          -DCUDA_USE_STATIC_CUDA_RUNTIME=OFF \
	  -DCUDA_ARCH_NAME=Manual \
	  -DCUDA_ARCH_BIN="${CUDA_ARCH_BIN}" \
	  -DCaffe_INCLUDE_DIRS=$CAFFE_ROOT/build/install/include \
          -DCaffe_LIBS=$CAFFE_ROOT/build/install/lib/libcaffe.so \
	  -DBUILD_CAFFE=OFF \
          .. && \
    make -j$(nproc)


## tj - : build Ceres-Solver
#ENV CERES_SOLVER_ROOT=/opt/CERES_SOLVER
#WORKDIR $CERES_SOLVER_ROOT
#
#
#RUN apt-get install -y libeigen3-dev \
#                       libsuitesparse-dev 
#
#
#RUN git clone git@github.com:ceres-solver/ceres-solver.git -b 1.13.0 . && \
#  mkdir build && cd build && \
#  cmake .. && \
#  make -j$(nproc) install
#
#
#
## tj - : build libigl
#
#ENV LIBIGL_ROOT=/opt/libigl
#WORKDIR $LIBIGL_ROOT
#
#RUN apt-get install -y mesa-common-dev \
#                       libglu1-mesa-dev \
#                       freeglut3-dev \
#                       xorg-dev 
#
#
#RUN git clone https://github.com/libigl/libigl.git .
#
## - tj : do not need build
#
##. && \
##  mkdir build && cd build && \
##  cmake .. && \
##  make -j$(nproc) install
#  
#
#
## tj - : build MTC
#
###ADD ./requirements.txt ./
###RUN pip3 install -r requirements.txt
#RUN pip3 install --upgrade pip
#RUN pip3 install --upgrade setuptools
#RUN pip3 install tensorflow-gpu==1.12.0
#RUN pip3 install opencv-python
#RUN pip3 install scikit-image
#
#
#RUN apt-get install -y libglew-dev \
#                       libxmu-dev \
#                       libxi-dev \
#                       libglm-dev \
#                       python3-matplotlib \
#                       unzip \
#                       mesa-utils 
#        
## tj : build mesa
#
#
#RUN apt-get install -y llvm-6.0\
#                       freeglut3\
#                       freeglut3-dev
#
#RUN pip install Mako                       
#
#ENV MESA_ROOT=/opt/mesa
#WORKDIR $MESA_ROOT
#
#RUN wget ftp://ftp.freedesktop.org/pub/mesa/mesa-18.3.3.tar.gz
#RUN tar xfv mesa-18.3.3.tar.gz
#RUN cd mesa-18.3.3 && ./configure --prefix=/usr/local \
#            --enable-opengl --disable-gles1 --disable-gles2   \
#            --disable-va --disable-xvmc --disable-vdpau       \
#            --enable-shared-glapi                             \
#            --disable-texture-float                           \
#            --enable-gallium-llvm --enable-llvm-shared-libs   \
#            --with-gallium-drivers=swrast,swr                 \
#            --disable-dri --with-dri-drivers=                 \
#            --disable-egl --with-egl-platforms= --disable-gbm \
#            --disable-glx                                     \
#            --disable-osmesa --enable-gallium-osmesa          \
#            ac_cv_path_LLVM_CONFIG=llvm-config-6.0 && make -j$(nproc) install
#
#
#
#ENV MTC_ROOT=/opt/MTC
#WORKDIR $MTC_ROOT

# tj - : add this line to break cache
ARG INCUBATOR_VER=unknown


#RUN git clone git@github.com:seamanj/MonocularTotalCapture.git . && cd FitAdam && \
#  mkdir build && cd build && \
#  cmake -DCUDA_USE_STATIC_CUDA_RUNTIME=OFF \
#        .. && \
#  make -j$(nproc)


#RUN DEBIAN_FRONTEND=noninteractive apt-get install -y keyboard-configuration



#RUN add-apt-repository ppa:graphics-drivers/ppa
#RUN apt update
#RUN apt install -y nvidia-384
#RUN add-apt-repository ppa:graphics-drivers/ppa
#RUN apt update
#RUN apt --fix-broken install
#RUN DEBIAN_FRONTEND=noninteractive apt-get install -y -f *nvidia*384*


#RUN wget http://uk.download.nvidia.com/XFree86/Linux-x86_64/430.50/NVIDIA-Linux-x86_64-430.50.run





  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值