Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release - Dockerfiles with Fixed Model Downloads - CPU / CPU + CUDA + cuDNN #2290

Open
hiibolt opened this issue Apr 4, 2024 · 3 comments
Open

Comments

@hiibolt
Copy link

hiibolt commented Apr 4, 2024

Issue Summary

It seems that something behind the scenes at CMU broke, as their CDN service which a manual build of OpenPose requires to obtain models is currently down.

As a result, OpenPose is currently unusable. However, thanks to the work done in Issue #1567, it's possible to instead disable the model downloads and instead use a third party hosting of the models on DropBox.

CMake also seems to have issues with building to support CMake, which the work here seems to fix - however, it targets a now depreciated version of nvidia/cuda. By changing the target from nvidia/cuda:11.4.0-cudnn8-devel-ubuntu18.04 to nvidia/cuda:11.3.1-cudnn8-devel-ubuntu18.04, it now has a functional source image.

By combining these two fixes, you can create both a CPU + Python API and a CPU + Python API + CUDA + cuDNN Docker image.

CPU + Python API: (Link)

# https://hub.docker.com/r/cwaffles/openpose
FROM ubuntu:focal

#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 caffe-cpu libhdf5-dev libatlas-base-dev

#for python api
RUN pip3 install --upgrade pip
RUN pip3 install numpy opencv-python 

#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
RUN git clone https://github.com/KWNahyun/openpose.git
WORKDIR /openpose
RUN    cd /openpose/models/pose/body_25 && wget -O pose_iter_584000.caffemodel -c https://www.dropbox.com/s/3x0xambj2rkyrap/pose_iter_584000.caffemodel?dl=0
# pose_iter_116000.caffemodel
RUN    cd /openpose/models/face && wget -O pose_iter_116000.caffemodel-c https://www.dropbox.com/s/d08srojpvwnk252/pose_iter_116000.caffemodel?dl=0
# pose_iter_102000.caffemodel
RUN    cd /openpose/models/hand && wget -O pose_iter_102000.caffemodel -c https://www.dropbox.com/s/gqgsme6sgoo0zxf/pose_iter_102000.caffemodel?dl=0

# use 'sed' to comment out the line in the OpenPose repo that downloads the model from the failed link
RUN sed -i 's/executeShInItsFolder "getModels.sh"/# executeShInItsFolder "getModels.sh"/g' /openpose/scripts/ubuntu/install_openpose_JetsonTX2_JetPack3.1.sh
RUN sed -i 's/executeShInItsFolder "getModels.sh"/# executeShInItsFolder "getModels.sh"/g' /openpose/scripts/ubuntu/install_openpose_JetsonTX2_JetPack3.3.sh
RUN sed -i 's/download_model("BODY_25"/# download_model("BODY_25"/g' /openpose/CMakeLists.txt
RUN sed -i 's/78287B57CF85FA89C03F1393D368E5B7/# 78287B57CF85FA89C03F1393D368E5B7/g' /openpose/CMakeLists.txt
RUN sed -i 's/download_model("body (COCO)"/# download_model("body (COCO)"/g' /openpose/CMakeLists.txt
RUN sed -i 's/5156d31f670511fce9b4e28b403f2939/# 5156d31f670511fce9b4e28b403f2939/g' /openpose/CMakeLists.txt
RUN sed -i 's/download_model("body (MPI)"/# download_model("body (MPI)"/g' /openpose/CMakeLists.txt
RUN sed -i 's/2ca0990c7562bd7ae03f3f54afa96e00/# 2ca0990c7562bd7ae03f3f54afa96e00/g' /openpose/CMakeLists.txt
RUN sed -i 's/download_model("face"/# download_model("face"/g' /openpose/CMakeLists.txt
RUN sed -i 's/e747180d728fa4e4418c465828384333/# e747180d728fa4e4418c465828384333/g' /openpose/CMakeLists.txt
RUN sed -i 's/download_model("hand"/# download_model("hand"/g' /openpose/CMakeLists.txt
RUN sed -i 's/a82cfc3fea7c62f159e11bd3674c1531/# a82cfc3fea7c62f159e11bd3674c1531/g' /openpose/CMakeLists.txt

#build it
WORKDIR /openpose/build
RUN cmake -DBUILD_PYTHON=ON -DGPU_MODE=CPU_ONLY -DOWNLOAD_HAND_MODEL=OFF -DOWNLOAD_FACE_MODEL=OFF .. && make -j `nproc`

CPU + Python API + CUDA + cuDNN (Link)

# https://hub.docker.com/r/cwaffles/openpose
FROM nvidia/cuda:11.3.1-cudnn8-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 --upgrade pip
RUN pip3 install numpy opencv-python 

#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 https://github.com/CMU-Perceptual-Computing-Lab/openpose.git .

RUN    cd /openpose/models/pose/body_25 && wget -O pose_iter_584000.caffemodel -c https://www.dropbox.com/s/3x0xambj2rkyrap/pose_iter_584000.caffemodel?dl=0
# pose_iter_116000.caffemodel
RUN    cd /openpose/models/face && wget -O pose_iter_116000.caffemodel-c https://www.dropbox.com/s/d08srojpvwnk252/pose_iter_116000.caffemodel?dl=0
# pose_iter_102000.caffemodel
RUN    cd /openpose/models/hand && wget -O pose_iter_102000.caffemodel -c https://www.dropbox.com/s/gqgsme6sgoo0zxf/pose_iter_102000.caffemodel?dl=0

# use 'sed' to comment out the line in the OpenPose repo that downloads the model from the failed link
RUN sed -i 's/executeShInItsFolder "getModels.sh"/# executeShInItsFolder "getModels.sh"/g' /openpose/scripts/ubuntu/install_openpose_JetsonTX2_JetPack3.1.sh
RUN sed -i 's/executeShInItsFolder "getModels.sh"/# executeShInItsFolder "getModels.sh"/g' /openpose/scripts/ubuntu/install_openpose_JetsonTX2_JetPack3.3.sh
RUN sed -i 's/download_model("BODY_25"/# download_model("BODY_25"/g' /openpose/CMakeLists.txt
RUN sed -i 's/78287B57CF85FA89C03F1393D368E5B7/# 78287B57CF85FA89C03F1393D368E5B7/g' /openpose/CMakeLists.txt
RUN sed -i 's/download_model("body (COCO)"/# download_model("body (COCO)"/g' /openpose/CMakeLists.txt
RUN sed -i 's/5156d31f670511fce9b4e28b403f2939/# 5156d31f670511fce9b4e28b403f2939/g' /openpose/CMakeLists.txt
RUN sed -i 's/download_model("body (MPI)"/# download_model("body (MPI)"/g' /openpose/CMakeLists.txt
RUN sed -i 's/2ca0990c7562bd7ae03f3f54afa96e00/# 2ca0990c7562bd7ae03f3f54afa96e00/g' /openpose/CMakeLists.txt
RUN sed -i 's/download_model("face"/# download_model("face"/g' /openpose/CMakeLists.txt
RUN sed -i 's/e747180d728fa4e4418c465828384333/# e747180d728fa4e4418c465828384333/g' /openpose/CMakeLists.txt
RUN sed -i 's/download_model("hand"/# download_model("hand"/g' /openpose/CMakeLists.txt
RUN sed -i 's/a82cfc3fea7c62f159e11bd3674c1531/# a82cfc3fea7c62f159e11bd3674c1531/g' /openpose/CMakeLists.txt

#build it
WORKDIR /openpose/build
RUN cmake -DBUILD_PYTHON=ON .. && make -j `nproc`
WORKDIR /openpose

Type of Issue

  • Enhancement / offering possible extensions / pull request / etc
@hiibolt
Copy link
Author

hiibolt commented Apr 4, 2024

Dockerfiles, example usage, and expected output can be found here:

CPU + Python API + CUDA + cuDNN Docker Image:

@hiibolt hiibolt changed the title Dockerfiles with Fixed Model Downloads - CPU / CPU + CUDA + cuDNN Release - Dockerfiles with Fixed Model Downloads - CPU / CPU + CUDA + cuDNN Apr 4, 2024
@xiangyann
Copy link
Contributor

Nice! But I think the problem that needs to be fixed first is the performance degradation using cudnn>=8, or else a docker update might not be any useful.
Does 18.04+CUDA11+cudnn8 make a performant combo?

@hiibolt
Copy link
Author

hiibolt commented Apr 28, 2024

Nice! But I think the problem that needs to be fixed first is the performance degradation using cudnn>=8, or else a docker update might not be any useful. Does 18.04+CUDA11+cudnn8 make a performant combo?

It has been very performant for our use case so far, the computation time for x2 57 second videos at 1080p (~60MB each) is less than a minute. Sadly, I do not have computation times for CuDNN<8 to compare to.

Specs:
Allocated CPU: 1 VCPU from AMD EPYC 7713
Allocated RAM: 1GB from 512GB pool
Allocated GPU: NVIDIA A100
Launch Arguments: --video "..." --display 0 --write_video "..." --write_json "..."

[ :3 - Starting OpenPose pose estimation... - :3 ]
Starting OpenPose demo...
Configuring OpenPose...
Starting thread(s)...
Auto-detecting all available GPUs... Detected 1 GPU(s), using 1 of them starting at GPU 0.
Empty frame detected, frame number 0 of 479. In /openpose/src/openpose/producer/producer.cpp:checkFrameIntegrity():290
OpenCV: FFMPEG: tag 0x47504a4d/'MJPG' is not supported with codec id 8 and format 'mov / QuickTime / MOV'
OpenCV: FFMPEG: fallback to use tag 0x6765706a/'jpeg'
OpenPose demo successfully finished. Total time: 19.738495 seconds.
Starting OpenPose demo...
Configuring OpenPose...
Starting thread(s)...
Auto-detecting all available GPUs... Detected 1 GPU(s), using 1 of them starting at GPU 0.
OpenCV: FFMPEG: tag 0x47504a4d/'MJPG' is not supported with codec id 8 and format 'mov / QuickTime / MOV'
OpenCV: FFMPEG: fallback to use tag 0x6765706a/'jpeg'
OpenPose demo successfully finished. Total time: 25.475751 seconds.
[ :3 - Finished OpenPose pose estimations! - :3 ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants