Post

Openpose 끄적이기

주의사항

  • Anaconda를 설치한 파이썬 환경에서 진행하면 수많은 오류를 만날 것이다.. 자체적으로 파이썬을 설치하여 진행해보자 -> 이것 때문에 눈물..

내가 필요한 환경

  • ubuntu 18.04
  • CUDA 10.1
  • PYTHON 3.6
  • Tensorflow 1.14.0
  • Pytorch ~

필요한 os 종속성 설치

1
2
3
4
5
6
7
8
9
10
11
12
13
14
sudo apt-get install libgoogle-glog-dev

sudo apt-get install libopencv-dev

sudo apt install build-essential libboost-system-dev libboost-thread-dev libboost-program-options-dev libboost-test-dev libgoogle-golg-dev protobuf-compiler libprotobuf-dev

# boost
sudo apt-get install cmake libblkid-dev e2fslibs-dev libboost-all-dev libaudit-dev

# hdf5
sudo apt-get install libhdf5-dev

# atlas
sudo apt-get install libatlas-base-dev

설치

CMake 설치하기

  • Uninstall your current Cmake-gui version by running sudo apt purge cmake-qt-gui.
  • Install OpenSSL for building CMake by running sudo apt install libssl-dev.
  • Run sudo apt-get install qtbase5-dev.
  • Download the Latest Release of CMake Unix/Linux Source from the CMake download website, called cmake-X.X.X.tar.gz.
  • Unzip it and go inside that folder from the terminal.
  • Run ./configure --qt-gui. Make sure no error occurred.
  • Run ./bootstrap && make -j`nproc` && sudo make install -j`nproc`. Make sure no error occurred.
  • Assuming your CMake downloaded folder is in {CMAKE_FOLDER_PATH}, everytime these instructions mentions cmake-gui, you will have to replace that line by {CMAKE_FOLDER_PATH}/bin/cmake-gui.

Clone & Build

1
2
3
git clone https://github.com/CMU-Perceptual-Computing-Lab/openpose
cd openpose/
git submodule update --init --recursive --remote
1
2
3
mkdir build/
cd build/
cmake-gui ..
  • 한번 Configuration 누르고
  • BUILD PYTHON check

Make

1
make -j4`nproc`

Python

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
sys.path.append('../openpose/build/python')
from openpose import pyopenpose as op

params = dict()
params["model_folder"] = "../openpose/models/"
params["hand"] = True
params["disable_blending"] = True
params['write_json'] = pose_folder

opWrapper = op.WrapperPython()
opWrapper.configure(params)
opWrapper.start()

datum = op.Datum()
datum.name = image_id
imageToProcess = cv2.imread(image_path)
datum.cvInputData = imageToProcess
opWrapper.emplaceAndPop(op.VectorDatum([datum]))
cv2.imwrite(pose_path, datum.cvOutputData)

CUDA 완전삭제

1
2
3
4
sudo apt-get purge nvidia* 
sudo apt-get autoremove 
sudo apt-get autoclean
sudo rm -rf /usr/local/cuda*

CUDNN 설치 후..

1
2
3
4
5
6
7
tar xvzf cudnn-10.1-linux-x64-v8.0.5.39.tgz
sudo cp cuda/include/cudnn* /usr/local/cuda-10.1/include
sudo cp cuda/lib64/libcudnn* /usr/local/cuda-10.1/lib64
sudo chmod a+r /usr/local/cuda-10.1/include/cudnn.h /usr/local/cuda-10.1/lib64/libcudnn*

# version 확인
cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2

내가 필요한 환경

  • ubuntu 20.04
  • CUDA 11.1
  • PYTHON 3.7
This post is licensed under CC BY 4.0 by the author.