Skip to content

Instantly share code, notes, and snippets.

@derlin
Last active February 2, 2021 03:01
Show Gist options
  • Save derlin/5b64b886efdc29e12e0d1dcb7dfd14a8 to your computer and use it in GitHub Desktop.
Save derlin/5b64b886efdc29e12e0d1dcb7dfd14a8 to your computer and use it in GitHub Desktop.
Dockerfile with openpose CPU & Python 3 API
# Dockerfile for openpose <https://github.com/CMU-Perceptual-Computing-Lab/openpose>
# CPU only and with the Python 3 API avilable.
# Last tested commit ID: 0a7d5b8e22db0b26b14ca3f3f8060299d3ee967d
# Author: Lucy Linder
FROM ubuntu:18.04
# get dependendies
# this will also install caffe-cpu so we don't have to build it from source (a pain in the schtroumpf)
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
python3-dev python3-pip git g++ wget make libprotobuf-dev protobuf-compiler libopencv-dev \
libgoogle-glog-dev libboost-all-dev libhdf5-dev libatlas-base-dev cmake caffe-cpu libcaffe-cpu-dev
# for python api
RUN pip3 install numpy opencv-python
#get openpose
WORKDIR /openpose
RUN git clone https://github.com/CMU-Perceptual-Computing-Lab/openpose.git .
# BUILD
WORKDIR /openpose/build
# run cmake for CPU only & python api + ensure we use the installed caffe lib
RUN cmake -DBUILD_PYTHON=ON -DGPU_MODE=CPU_ONLY -DUSE_MKL=OFF \
-DBUILD_CAFFE=OFF \
-DCaffe_LIBS=/usr/lib/x86_64-linux-gnu/libcaffe.so \
-DCaffe_INCLUDE_DIRS=/usr/include/caffe ..
# actually build
RUN make -j8
# rename the pyopenpose-xxxx-gnu.so to avoid ImportError in python
RUN ln -s python/openpose/*.so python/openpose/pyopenpose.so
# make it available for the system
ENV PYTHONPATH=/openpose/build/python/openpose
WORKDIR /openpose
@derlin
Copy link
Author

derlin commented Aug 8, 2019

You can also use the python:3 base image, just remove the installation of python and pip then.

Build it with:

docker build -t derlin/pyopenpose --rm .

Test it with:

docker run -it derlin/pyopenpose bash
> cd build/examples/tutorial_api_python
> python3 01_body_from_image.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment