BUILD TO OPENPOSE-DOCKER ON SSH SERVER

bk jang
2 min readJul 8, 2021

Reference:

https://github.com/CMU-Perceptual-Computing-Lab/openpose

https://hub.docker.com/r/cwaffles/openpose

https://github.com/u0251077/openpose-docker/commit/f7cb071b6cca51de7c0404e064b4344eb1c075df

본 프로세스는 nvidia/cuda:10.1-cudnn7-devel-ubuntu18.04 기준입니다.

각 ssh 서버 환경에 맞게 조정해서 사용하시기 바랍니다.

Openpose 모델은 기본적으로 Ubuntu,Window,Mac 환경에서 실행되도록 짜여진 모델.

CentOS7 기반의 서버에서 사용하기 위해서는 모듈 설치가 매우 복잡하기 때문에 Docker 사용을 선택.

SETUP

A build of openpose using CUDA 10.1

Requirements

Getting started

cloning the repo.

$ git clone <https://github.com/esemeniuc/openpose-docker.git>

Fix Dockerfile.

https://github.com/CMU-Perceptual-Computing-Lab/openpose/issues/1753

# <https://hub.docker.com/r/cwaffles/openpose>
FROM nvidia/cuda:10.1-cudnn7-devel-ubuntu18.04
#get deps
RUN apt-get update && \\
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \\
python3-dev python3-pip python3-setuptools git g++ wget make libprotobuf-dev protobuf-compiler libopencv-dev \\
libgoogle-glog-dev libboost-all-dev libcaffe-cuda-dev libhdf5-dev libatlas-base-dev
#for python api
#RUN pip3 install scikit-build
RUN pip3 install scikit-build numpy opencv-python==4.1.1.26
#replace cmake as old version has CUDA variable bugs
RUN wget <https://github.com/Kitware/CMake/releases/download/v3.16.0/cmake-3.16.0-Linux-x86_64.tar.gz> && \\
tar xzf cmake-3.16.0-Linux-x86_64.tar.gz -C /opt && \\
rm cmake-3.16.0-Linux-x86_64.tar.gz
ENV PATH="/opt/cmake-3.16.0-Linux-x86_64/bin:${PATH}"
#get openpose
WORKDIR /openpose
RUN git clone -q --depth 1 <https://github.com/CMU-Perceptual-Computing-Lab/openpose.git> .
#build it
WORKDIR /openpose/build
RUN cmake -DBUILD_PYTHON=ON \\
-DDOWNLOAD_BODY_25_MODEL=ON \\
-DDOWNLOAD_BODY_MPI_MODEL=OFF \\
-DDOWNLOAD_HAND_MODEL=OFF \\
-DDOWNLOAD_FACE_MODEL=OFF \\
..
RUN sed -ie 's/set(AMPERE "80 86")/#&/g' ../cmake/Cuda.cmake && \\
sed -ie 's/set(AMPERE "80 86")/#&/g' ../3rdparty/caffe/cmake/Cuda.cmake
RUN make -j`nproc`
RUN make install
WORKDIR /openpose

build the image using dockerfile

$ cd ./openpose-docker
$ sudo docker build -t openpose .
  • 원격 서버에서 docker 사용시 GUI사용

start docker env.

$ docker run --gpus all --name openpose -v /tmp/.X11-unix:/tmp/.X11-unix -v /dev/snd:/dev/snd -e DISPLAY=unix$DISPLAY -it bongkyung/openpose:latest /bin/bash

build python openpose

$ cd /openpose/build/python/openpose
$ make install

setup env. for pyopenpose and import check

$ cd /openpose/build/python/openpose
$ cp ./pyopenpose.cpython-36m-x86_64-linux-gnu.so /usr/local/lib/python3.6/dist-packages
$ cd /usr/local/lib/python3.6/dist-packages
$ ln -s pyopenpose.cpython-36m-x86_64-linux-gnu.so pyopenpose
$ export LD_LIBRARY_PATH=/openpose/build/python/openpose
$ python3
>>> import pyopenpose as op
>>>

RUNNING

after docker attach

./build/examples/openpose/openpose.bin --video /openpose/sample.mp4 --display 0 --face --hand --write_video ./output.avi

gui 사용 안할 시 — display 0

--

--