Closed DEKHTIARJonathan closed 5 years ago
This looks more like a problem with the openpose shutting down (cafe cleanup?). Can you share a bit more information on your setup?
I use nvidia-docker and compile OpenPose / PyOpenpose as follows:
# Build OpenPose
RUN cd /opt && \
git clone https://github.com/CMU-Perceptual-Computing-Lab/openpose && \
cd openpose && \
git fetch origin e38269862f05beca9497960eef3d35f9eecc0808 && \
git checkout FETCH_HEAD && \
git clone https://github.com/CMU-Perceptual-Computing-Lab/caffe.git 3rdparty/caffe && \
cd 3rdparty/caffe && \
git fetch origin 9453eb00f6073ab9091f8a3a973538c7bdcb6785 && \
git checkout FETCH_HEAD && \
cd /opt/openpose && \
sed -i \
's/set(Caffe_known_gpu_archs "20 21(20) 30 35 50 52 60 61")/set(Caffe_known_gpu_archs "30 32 35 37 50 52 53 60 61 62 70 72 75")/g' \
/opt/openpose/cmake/Cuda.cmake && \
sed -i \
's/set(Caffe_known_gpu_archs "20 21(20) 30 35 50 60 61")/set(Caffe_known_gpu_archs "30 32 35 37 50 52 53 60 61 62 70 72 75")/g' \
/opt/openpose/3rdparty/caffe/cmake/Cuda.cmake && \
mkdir build && cd build && \
cmake .. && \
make -j $nproc && \
make install && \
ldconfig && \
cd /opt/openpose/models && chmod +x getModels.sh && ./getModels.sh
# Build PyOpenPose
RUN cd /opt && \
git clone https://github.com/FORTH-ModelBasedTracker/PyOpenPose.git && \
cd PyOpenPose && \
mkdir build && cd build && \
cmake .. \
-DPYTHON_INCLUDE_DIR=/usr/include/python3.5 \
-DPYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython3.5m.so \
-DWITH_PYTHON3=True && \
make all -j $nproc && \
make install && \
ldconfig && \
cp PyOpenPoseLib/PyOpenPose.so /usr/lib/python3.5/dist-packages/
By the way, I use CUDA 10.0.130, NVIDIA Driver: 410.73 and CuDNN 7.4.0
PyOpenpose is used as follows:
openpose_model = OP.OpenPose(
# poseSize
(656, 368),
# faceHandSize
(368, 368),
# outSize
(1280, 720) if not args.square_ratio else (512, 512),
# model_type
"COCO",
# modelFolder
os.path.join(OPENPOSE_ROOT, "models", ""),
# logLevel
0,
# downloadHeatmaps
False,
OP.OpenPose.ScaleMode.ZeroToOne,
# detectFace
True,
# detectHands
True
)
I don't do any attempt to del openpose_model
or free its memory. Shall I manually call a method ?
There is no need to delete the instance manually. It is taken care of when the script ends. Your configuration looks ok. Do the Openpose examples run without crashing on exit?
If I run this code (from scripts):
import cv2
import os
import PyOpenPose as OP
OPENPOSE_ROOT = os.environ["OPENPOSE_ROOT"]
img = cv2.imread("galloping knights.jpg")
op = OP.OpenPose((656, 368), (368, 368), (1280, 720), "COCO", OPENPOSE_ROOT + os.sep + "models" + os.sep, 0, False)
op.detectPose(img)
viz = op.render(img)
cv2.imwrite("result.jpeg", viz)
# getKeypoints returns an array of matrices
# When POSE is requested the return array contains one entry with all persons.
persons = op.getKeypoints(op.KeypointType.POSE)[0]
print("Found", persons.shape[0],"persons.")
print("Result info:",persons.shape, persons.dtype)
print(persons[0])
I have the exact same error as above. It doesn't make the program unable to run, it just crash at the end and it's quite annoying ...
See the results (perfectly fine):
ok. But can you run the openpose examples (c++, binaries build along with the openpose project) and see if they also crash on exit?
OK so it seems I found the issue ... For a weird reason it could be linked with OpenCV building flags:
Building as follows solve the issue:
RUN apt-get update && \
apt-get install -y software-properties-common && \
add-apt-repository -y ppa:jonathonf/ffmpeg-3 && \
apt-get update && \
apt-get install -y \
build-essential cmake pkg-config python-dev python3-dev \
doxygen git vim unzip wget python-numpy python3-numpy \
libtbb2 libtbb-dev libpng-dev libpng12-dev \
libjpeg-dev libtiff-dev libtiff5-dev libjasper-dev \
libxvidcore-dev libx264-dev libv4l-dev libopencv-dev \
libgtk2.0-dev libgtk-3-dev liblapack-dev \
libgflags-dev libgoogle-glog-dev liblmdb-dev libdc1394-22 \
libhdf5-serial-dev libatlas-dev libatlas-base-dev libdc1394-22-dev \
libblkid-dev e2fslibs-dev libboost-all-dev libaudit-dev \
libsm6 libxrender1 libfontconfig1 libxext6 libgl1-mesa-glx \
libprotobuf-dev protobuf-compiler libleveldb-dev libsnappy-dev \
libavcodec-dev libavformat-dev libswscale-dev \
libavdevice-dev ffmpeg libav-tools x264 x265 vtk6 \
libavutil-dev libswresample-dev libavfilter-dev \
libcanberra-gtk-module libcanberra-gtk3-module libtheora-dev \
graphicsmagick libgraphicsmagick1-dev qtbase5-dev libopencore-amrnb-dev libopencore-amrwb-dev \
libxine2-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libfaac-dev libmp3lame-dev \
liblapacke-dev libopenblas-dev libgdal-dev checkinstall && \
apt-get -y install libcanberra-gtk* && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* && \
rm -f /usr/bin/python && ln -s /usr/bin/python3 /usr/bin/python && \
rm -f /usr/bin/python-config && ln -s /usr/bin/python3.5-config /usr/bin/python-config
# Second: get and build OpenCV 3.4.3
RUN cd /opt \
&& wget https://github.com/opencv/opencv_contrib/archive/3.4.3.zip \
&& unzip 3.4.3.zip \
&& rm 3.4.3.zip \
&& wget https://github.com/opencv/opencv/archive/3.4.3.zip \
&& unzip 3.4.3.zip \
&& rm 3.4.3.zip \
&& cd opencv-3.4.3 \
&& mkdir build \
&& cd build \
&& cmake \
-D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=$CMAKE_INSTALL_PREFIX \
-D PYTHON3_LIBRARY=$PYTHON3_LIBRARY \
-D PYTHON3_INCLUDE_DIR=$PYTHON3_INCLUDE_DIR \
-D PYTHON3_EXECUTABLE=$PYTHON3_EXECUTABLE \
-D BUILD_opencv_python2=OFF \
-D BUILD_opencv_python3=ON \
-D FORCE_VTK=ON \
-D WITH_TBB=ON \
-D WITH_V4L=ON \
-D WITH_QT=ON \
-D WITH_OPENGL=ON \
-D WITH_CUBLAS=ON \
-D CUDA_NVCC_FLAGS="-D_FORCE_INLINES" \
-D WITH_GDAL=ON \
-D WITH_XINE=ON \
-D INSTALL_PYTHON_EXAMPLES=OFF \
-D INSTALL_C_EXAMPLES=OFF \
-D BUILD_EXAMPLES=OFF \
.. \
&& make -j $nproc \
&& make install \
&& echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf \
&& ldconfig \
&& ln -s /usr/local/lib/python3.5/site-packages/cv2.cpython-35m.so cv2.so
Thanks for your help
Everytime a script finishes which has loaded PyOpenPose, I obtain the following displayed below.
It seems that python has difficulties to free the memory at the end of the program. Any idea how I can solve this issue ?