OpenPose - Installation ========================== ## Contents 1. [Operating Systems](#operating-systems) 2. [Requirements](#requirements) 3. [Clone OpenPose](#clone-openpose) 4. [Update OpenPose](#update-openpose) 5. [Installation](#installation) 6. [Reinstallation](#reinstallation) 7. [Uninstallation](#uninstallation) 8. [Optional Settings](#optional-settings) 1. [MPI Model](#mpi-model) 2. [OpenPose 3D Reconstruction Module and Demo](#openpose-3d-reconstruction-module-and-demo) 3. [Compiling without cuDNN](#compiling-without-cudnn) 4. [Custom Caffe (Ubuntu Only)](#custom-caffe-ubuntu-only) 5. [Custom OpenCV (Ubuntu Only)](#custom-opencv-ubuntu-only) 6. [Doxygen Documentation Autogeneration (Ubuntu Only)](#doxygen-documentation-autogeneration-ubuntu-only) 7. [CMake Command Line Configuration (Ubuntu Only)](#cmake-command-line-configuration-ubuntu-only) ## Operating Systems - **Ubuntu** 14 and 16. - **Windows** 8 and 10. - **Nvidia Jetson TX2**, installation instructions in [doc/installation_jetson_tx2.md](./installation_jetson_tx2.md). - OpenPose has also been used on **Windows 7**, **Mac**, **CentOS**, and **Nvidia Jetson (TK1 and TX1)** embedded systems. However, we do not officially support them at the moment. ## Requirements - NVIDIA graphics card with at least 1.6 GB available (the `nvidia-smi` command checks the available GPU memory in Ubuntu). - At least 2 GB of free RAM memory. - Highly recommended: cuDNN and a CPU with at least 8 cores. Note: These requirements assume the default configuration (i.e. `--net_resolution "656x368"` and `scale_number 1`). You might need more (with a greater net resolution and/or number of scales) or less resources (with smaller net resolution and/or using the MPI and MPI_4 models). ## Clone OpenPose The first step is to clone the OpenPose repository. 1. Windows: You might use [GitHub Desktop](https://desktop.github.com/). 2. Ubuntu: ```bash git clone https://github.com/CMU-Perceptual-Computing-Lab/openpose ``` ## Update OpenPose OpenPose can be easily updated by: 1. Download the latest changes: 1. Windows: Clicking the `synchronization` button at the top-right part in GitHub Desktop in Windows. 2. Ubuntu: running `git pull origin master`. 2. Perform the [Reinstallation](#reinstallation) section described below. ## Installation The instructions in this section describe the steps to build OpenPose using CMake (GUI). There are 3 main steps: 1. [Prerequisites](#prerequisites) 2. [OpenPose Configuration](#openpose-configuration) 3. [OpenPose Building](#openpose-building) 4. [OpenPose from other Projects (Ubuntu Only)](#openpose-from-other-projects-ubuntu-only) 5. [Run OpenPose](#run-openpose) ### Prerequisites 1. Download and install CMake GUI: - Ubuntu: run the command `sudo apt-get install cmake-qt-gui`. Note: If you prefer to use CMake through the command line, see [Cmake Command Line Build](#cmake-command-line-build-ubuntu-only). - Windows: download and install the latest CMake win64-x64 msi installer from the [CMake website](https://cmake.org/download/), called `cmake-X.X.X-win64-x64.msi`. 2. [**CUDA 8**](https://developer.nvidia.com/cuda-80-ga2-download-archive): - Ubuntu: Run `ubuntu/install_cuda.sh` or alternatively download and install it from their website. - Windows: Install CUDA 8.0 after Visual Studio 2015 is installed to assure that the CUDA installation will generate all necessary files for VS. If CUDA was already installed, re-install CUDA after installing VS! 3. [**cuDNN 5.1**](https://developer.nvidia.com/cudnn): - Ubuntu: Run `ubuntu/install_cudnn.sh` or alternatively download and install it from their website. - Windows (and Ubuntu if manual installation): In order to manually install it, just unzip it and copy (merge) the contents on the CUDA folder, usually `/usr/local/cuda/` in Ubuntu and `C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0` in Windows. 3. Ubuntu - Other prerequisites: - Caffe prerequisites: By default, OpenPose uses Caffe under the hood. If you have not used Caffe previously, install its dependencies by running `bash ./ubuntu/install_cmake.sh`. - OpenCV must be already installed on your machine. It can be installed with `apt-get install libopencv-dev`. You can also use your own compiled OpenCV version. 4. Windows - **Microsoft Visual Studio (VS) 2015 Enterprise Update 3**: - If **Visual Studio 2017 Community** is desired, we do not officially support it, but it might be compiled by firstly [enabling CUDA 8.0 in VS2017](https://stackoverflow.com/questions/43745099/using-cuda-with-visual-studio-2017?answertab=active#tab-top) or use **VS2017 with CUDA 9** by checking the `.vcxproj` file and changing the necessary paths from CUDA 8 to 9. - VS 2015 Enterprise Update 1 will give some compiler errors and VS 2015 Community has not been tested. ### OpenPose Configuration 1. Open CMake GUI and select the OpenPose directory as project source directory, and a non-existing or empty sub-directory (e.g., `build`) where the Makefile files (Ubuntu) or Visual Studio solution (Windows) will be generated. If `build` does not exist, it will ask you whether to create it. Press `Yes`.
2. Press the `Configure` button, keep the generator in `Unix Makefile` (Ubuntu) or set it to `Visual Studio 14 2015 Win64` (Windows), and press `Finish`.
3. If this step is successful, the `Configuring done` text will appear in the bottom box in the last line. Otherwise, some red text will appear in that same bottom box.
4. Press the `Generate` button and proceed to [OpenPose Building](#openpose-building). You can now close CMake. Note: If you prefer to use your own custom Caffe or OpenCV versions, see [Custom Caffe](#custom-caffe) or [Custom OpenCV](#custom-opencv) respectively. ### OpenPose Building #### Ubuntu Finally, build the project by running the following commands. ``` cd build/ make -j`nproc` ``` #### Windows In order to build the project, open the Visual Studio solution (Windows), called `build/OpenPose.sln`. Then, set the configuration from `Debug` to `Release` and press the green triangle icon (alternatively press F5). ### OpenPose from other Projects (Ubuntu Only) If you only intend to use the OpenPose demo, you might skip this step. This step is only recommended if you plan to use the OpenPose API from other projects. To install the OpenPose headers and libraries into the system environment path (e.g. `/usr/local/` or `/usr/`), run the following command. ``` cd build/ sudo make install ``` Once the installation is completed, you can use OpenPose in your other project using the `find_package` cmake command. Below, is a small example `CMakeLists.txt`. In order to use this script, you also need to copy `FindGFlags.cmake` and `FindGlog.cmake` into your `
#### Custom OpenCV (Ubuntu Only) If you have built OpenCV from source and OpenPose cannot find it automatically, you can set the `OPENCV_DIR` variable to the directory where you build OpenCV. #### Doxygen Documentation Autogeneration (Ubuntu Only) You can generate the documentation by setting the `BUILD_DOCS` flag. The documentation will be generated in `doc/doxygen/html/index.html`. You can simply open it with double-click (your default browser should automatically display it). #### CMake Command Line Configuration (Ubuntu Only) Note that this step is unnecessary if you already used the CMake GUI alternative. Create a `build` folder in the root OpenPose folder, where you will build the library -- ```bash cd openpose mkdir build cd build ``` The next step is to generate the Makefiles. Now there can be multiple scenarios based on what the user already has e.x. Caffe might be already installed and the user might be interested in building OpenPose against that version of Caffe instead of requiring OpenPose to build Caffe from scratch. ##### SCENARIO 1 -- Caffe not installed and OpenCV installed using `apt-get` In the build directory, run the below command -- ```bash cmake .. ``` ##### SCENARIO 2 -- Caffe installed and OpenCV build from source In this example, we assume that Caffe and OpenCV are already present. The user needs to supply the paths of the libraries and the include directories to CMake. For OpenCV, specify the include directories and the libraries directory using `OpenCV_INCLUDE_DIRS` and `OpenCV_LIBS_DIR` variables respectively. Alternatively, the user can also specify the path to the `OpenCVConfig.cmake` file by setting the `OpenCV_CONFIG_FILE` variable. For Caffe, specify the include directory and library using the `Caffe_INCLUDE_DIRS` and `Caffe_LIBS` variables. This will be where you installed Caffe. Below is an example of the same. ```bash cmake -DOpenCV_INCLUDE_DIRS=/home/"${USER}"/softwares/opencv/build/install/include \ -DOpenCV_LIBS_DIR=/home/"${USER}"/softwares/opencv/build/install/lib \ -DCaffe_INCLUDE_DIRS=/home/"${USER}"/softwares/caffe/build/install/include \ -DCaffe_LIBS=/home/"${USER}"/softwares/caffe/build/install/lib/libcaffe.so -DBUILD_CAFFE=OFF .. ``` ```bash cmake -DOpenCV_CONFIG_FILE=/home/"${USER}"/softwares/opencv/build/install/share/OpenCV/OpenCVConfig.cmake \ -DCaffe_INCLUDE_DIRS=/home/"${USER}"/softwares/caffe/build/install/include \ -DCaffe_LIBS=/home/"${USER}"/softwares/caffe/build/install/lib/libcaffe.so -DBUILD_CAFFE=OFF .. ``` ##### SCENARIO 3 -- OpenCV already installed If Caffe is not already present but OpenCV is, then use the below command. ```bash cmake -DOpenCV_INCLUDE_DIRS=/home/"${USER}"/softwares/opencv/build/install/include \ -DOpenCV_LIBS_DIR=/home/"${USER}"/softwares/opencv/build/install/lib .. ``` ```bash cmake -DOpenCV_CONFIG_FILE=/home/"${USER}"/softwares/opencv/build/install/share/OpenCV/OpenCVConfig.cmake .. ```