Install OpenPose with CUDA 10.1 and cuDNN for Ubuntu 18.04 in 2020 year

Alister Enikeev
3 min readDec 19, 2020

First of all update and upgrade your system

sudo apt-get update
sudo apt-get upgrade

Now install the lastest NVIDIA driver for your system using “Software & Updates” (in my case it’s 450 version)

After installation reload system. Verify that driver installed successfully using command nvidia-smi

Now go to CMake site and download the lastest version (https://cmake.org/download/). Choose Unix/Linux Source tar.gz file

Unzip that tar.gz, go into folder and open terminal there, then type

sudo apt-get install qtbase5-dev
./configure --qt-gui
./bootstrap && make -j`nproc` && sudo make install -j`nproc`

Now it’s time for CUDA installation. Go to official website NVIDIA for CUDA 10.1 (https://developer.nvidia.com/cuda-10.1-download-archive-base). Here select Linux => x86_64 => Ubuntu => 18.04 => runfile(local). After that, the file will start downloading. When it loads, write this

sudo sh cuda_10.1.105_418.39_linux.run

In installation settings uncheck parameter of installing driver for videocard and start installing of CUDA to your system

After successfull installation add paths for CUDA to your bashrc file

sudo nano ~/.bashrc

Add those lines to the end of file:

export PATH=/usr/local/cuda-10.1/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-10.1/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

After that, save file and run

source ~/.bashrc

Now go to download cuDNN 7.5.1. For that visit site (https://developer.nvidia.com/rdp/cudnn-archive). Log in or register there.
Choose Download cuDNN v7.5.1 (April 22, 2019), for CUDA 10.1.

After downloading unzip that cudnn-10.1-linux-x64-v7.5.1.10.tgz
Then just copy those files to your cuda directory using those commands

sudo cp cuda/include/cudnn.h /usr/local/cuda/include/
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64/

Add permisions

sudo chmod a+r /usr/local/cuda/include/cudnn.h
sudo chmod a+r /usr/local/cuda/lib64/libcudnn*

Now that’s all for installing CUDA 10.1 + cuDNN 7.5.1. Now it’s time for installing other OpenPose prerequisites. Install OpenCV to your system. Run command below

sudo apt-get install libopencv-dev

Now its time to git clone OpenPose rep. For that mkdir openpose_folder, and cd openpose_folder

In openpose_folder git clone OpenPose

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

After that, install Caffe prerequisites.
Go to OpenPose folder and run install_deps.sh

cd openpose
sudo bash ./scripts/ubuntu/install_deps.sh

Now build Caffe from source for Openpose, type that

cd 3rdparty
git clone https://github.com/CMU-Perceptual-Computing-Lab/caffe.git

Then install Python prerequisites

sudo apt-get install python3-dev
sudo pip3 install numpy opencv-python

Now create an empty subcategory “build” folder inside Openpose folder

mkdir build

Now close your terminal and start CMake GUI from your apps , select “Browse Source” => Choose your OpenPose directory, then select “Browse Build” => Choose OpenPose/build folder

Select Configure to compile the files. A dialog box appears CMakeSetup.
Choose Unix Makefiles and Use defaults native compilers

It takes some time to download models and compiling it. After successful configuration, check the “BUILD_PYTHON” inside the red box

Now click “Generate”

After ending of generation, close CMake. Open terminal, go to build folder

cd openpose/build/
make -j`nproc`

Compile the Openpose source. Run command below from build folder

sudo make install

Compile and build the python Openpose

cd openpose/build/python/openpose
sudo make install

And that’s all! Congratulations, you have installed the OpenPose!

Now let’s test it! Go to tutorial_api_python run test image using python3

cd openpose/build/examples/tutorial_api_python
python3 01_body_from_image.py

--

--