Update 'Unix installation'

Andreas Bulling 2023-02-13 16:27:04 +01:00
parent a94593efb9
commit f7d21d07e3

@ -1,220 +1,220 @@
This installation was tested on the following configuration: This installation was tested on the following configuration:
* OS: Ubuntu 16.04 * OS: Ubuntu 16.04
* CUDA 9.0 * CUDA 9.0
* CUDNN 7.1 * CUDNN 7.1
* OpenCV 3.4 * OpenCV 3.4
* Caffe 1.0 * Caffe 1.0
* OpenFace 2.0 * OpenFace 2.0
* Boost 1.5 * Boost 1.5
**If you have Ubuntu 18.04, please refer to the [configuration information](https://git.hcics.simtech.uni-stuttgart.de/public-projects/opengaze/wikis/Unix-installation#ubuntu-1804).** **If you have Ubuntu 18.04, please refer to the [configuration information](https://git.hcics.simtech.uni-stuttgart.de/public-projects/opengaze/wikis/Unix-installation#ubuntu-1804).**
## Dependency installation ## Dependency installation
OpenGaze requires cmake, OpenCV 3.1.0 (or newer), Caffe, OpenFace, and boost. OpenFace relies on tbb, OpenBlas and dlib. Caffe relies on protobuf, glog, gflags, hdf5 and cuDNN. OpenGaze requires cmake, OpenCV 3.1.0 (or newer), Caffe, OpenFace, and boost. OpenFace relies on tbb, OpenBlas and dlib. Caffe relies on protobuf, glog, gflags, hdf5 and cuDNN.
Since we use convolutional neural networks as our model, the speed performance can be optimized with a powerful Nvidia GPU. Here we will show you how to install the driver and GPU library. Since we use convolutional neural networks as our model, the speed performance can be optimized with a powerful Nvidia GPU. Here we will show you how to install the driver and GPU library.
### Install GPU driver and library ### Install GPU driver and library
1. Install GPU driver:<br/> 1. Install GPU driver:<br/>
Check if you already have the Nvidia driver with `nvidia-smi`, which should give you the GPU information. Note that we tested on driver version 384.130.<br/> Check if you already have the Nvidia driver with `nvidia-smi`, which should give you the GPU information. Note that we tested on driver version 384.130.<br/>
If you do not have the driver, then you can install the driver with `sudo ubuntu-drivers autoinstall`<br/> If you do not have the driver, then you can install the driver with `sudo ubuntu-drivers autoinstall`<br/>
Then reboot your computer<br/> Then reboot your computer<br/>
You now should test the Nvidia driver with `nvidia-smi` <br/> You now should test the Nvidia driver with `nvidia-smi` <br/>
2. Install CUDA <br/> 2. Install CUDA <br/>
CUDA is a parallel computing platform and programming model invented by NVIDIA. You can check with `nvcc --version` to see if you already have the GPU or not. We tested on version 9.0.176. You can install CUDA with the following steps:<br/> CUDA is a parallel computing platform and programming model invented by NVIDIA. You can check with `nvcc --version` to see if you already have the GPU or not. We tested on version 9.0.176. You can install CUDA with the following steps:<br/>
``` ```
wget https://developer.nvidia.com/compute/cuda/9.0/Prod/local_installers/cuda_9.0.176_384.81_linux-run wget https://developer.nvidia.com/compute/cuda/9.0/Prod/local_installers/cuda_9.0.176_384.81_linux-run
sudo bash cuda_9.0.176_384.81_linux-run --override sudo bash cuda_9.0.176_384.81_linux-run --override
``` ```
Answer these questions as follows while installation begins: Answer these questions as follows while installation begins:
- Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 384.81? n - Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 384.81? n
- Install the CUDA 9.0 Toolkit? y - Install the CUDA 9.0 Toolkit? y
- Do you want to install a symbolic link at /usr/local/cuda? y - Do you want to install a symbolic link at /usr/local/cuda? y
- Install the CUDA 10.0 Samples? n - Install the CUDA 10.0 Samples? n
Set up your paths: <br/> Set up your paths: <br/>
``` ```
echo 'export PATH=/usr/local/cuda/bin:$PATH' >> ~/.bashrc echo 'export PATH=/usr/local/cuda/bin:$PATH' >> ~/.bashrc
echo 'export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH' >> ~/.bashrc echo 'export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH' >> ~/.bashrc
echo 'export CPATH=/usr/local/cuda/include:$CPATH' >> ~/.bashrc echo 'export CPATH=/usr/local/cuda/include:$CPATH' >> ~/.bashrc
source ~/.bashrc source ~/.bashrc
``` ```
You can now test your CUDA installation with `nvcc --version`, which should show your nvcc version.<br/> You can now test your CUDA installation with `nvcc --version`, which should show your nvcc version.<br/>
3. Install cuDNN<br/> 3. Install cuDNN<br/>
cuDNN is a GPU-accelerated library from Nvidia.<br/> cuDNN is a GPU-accelerated library from Nvidia.<br/>
Go to [cuDNN archive](https://developer.nvidia.com/rdp/cudnn-archive) to download "cuDNN v7.1.4 (May 16, 2018), for CUDA 9.0", and then install it with:<br/> Go to [cuDNN archive](https://developer.nvidia.com/rdp/cudnn-archive) to download "cuDNN v7.1.4 (May 16, 2018), for CUDA 9.0", and then install it with:<br/>
``` ```
tar -xzvf cudnn-9.0-linux-x64-v7.1.tgz tar -xzvf cudnn-9.0-linux-x64-v7.1.tgz
sudo cp cuda/include/cudnn.h /usr/local/cuda/include sudo cp cuda/include/cudnn.h /usr/local/cuda/include
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64 sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64
sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn* sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*
``` ```
## Install OpenGaze with pre-compiled binary ## Install OpenGaze with pre-compiled binary
You can easily install OpenGaze with our pre-compiled binary file. You can easily install OpenGaze with our pre-compiled binary file.
1. Install other dependencies with `bash install.sh`. This will install all the dependencies (tbb, boost, OpenBlas, dlib, protobuf, glog, gflags and hdf5) except OpenFace and Caffe. 1. Install other dependencies with `bash install.sh`. This will install all the dependencies (tbb, boost, OpenBlas, dlib, protobuf, glog, gflags and hdf5) except OpenFace and Caffe.
2. Install OpenGaze with `sudo dpkg -i opengaze.deb`. This will install the OpenGaze library itself and also the OpenFace and Caffe library. 2. Install OpenGaze with `sudo dpkg -i opengaze.deb`. This will install the OpenGaze library itself and also the OpenFace and Caffe library.
4. Compile the test example: 4. Compile the test example:
``` ```
cd exe/ cd exe/
mkdir build mkdir build
cd build cd build
cmake .. cmake ..
make make
``` ```
4. Run the test [Run the test](https://git.hcics.simtech.uni-stuttgart.de/public-projects/opengaze/wikis/Unix-installation#test-opengaze)<br/> 4. Run the test [Run the test](https://git.hcics.simtech.uni-stuttgart.de/public-projects/opengaze/wiki/Unix-installation#test-opengaze)<br/>
## Compile OpenGaze from source ## Compile OpenGaze from source
If the pre-compiled file does not work for you, or you want to make changes to the OpenGaze source code, then you can compile it from source.<br/> If the pre-compiled file does not work for you, or you want to make changes to the OpenGaze source code, then you can compile it from source.<br/>
### Install OpenFace v2.0<br/> ### Install OpenFace v2.0<br/>
1. Install 1. Install
``` ```
git clone https://github.com/TadasBaltrusaitis/OpenFace.git git clone https://github.com/TadasBaltrusaitis/OpenFace.git
cd OpenFace cd OpenFace
``` ```
Open the file 'install.sh', and change the "BUILD_SHARED_LIBS=OFF" to "BUILD_SHARED_LIBS=ON" for OpenCV. Then run Open the file 'install.sh', and change the "BUILD_SHARED_LIBS=OFF" to "BUILD_SHARED_LIBS=ON" for OpenCV. Then run
``` ```
yes | bash install.sh yes | bash install.sh
``` ```
<br/> <br/>
2. Download the necessary models: 2. Download the necessary models:
Open the file "download_models.sh", set your OpenGaze root directory, which defualt value is "~/OpenGaze".<br/> Open the file "download_models.sh", set your OpenGaze root directory, which defualt value is "~/OpenGaze".<br/>
``` ```
bash download_models.sh bash download_models.sh
``` ```
3. Test it: 3. Test it:
``` ```
cd build/ cd build/
cp ../lib/local/LandmarkDetector/model/patch_experts/cen_patches_0.25_of.dat ./bin/model/patch_experts/ cp ../lib/local/LandmarkDetector/model/patch_experts/cen_patches_0.25_of.dat ./bin/model/patch_experts/
cp ../lib/local/LandmarkDetector/model/patch_experts/cen_patches_0.35_of.dat ./bin/model/patch_experts/ cp ../lib/local/LandmarkDetector/model/patch_experts/cen_patches_0.35_of.dat ./bin/model/patch_experts/
cp ../lib/local/LandmarkDetector/model/patch_experts/cen_patches_0.50_of.dat ./bin/model/patch_experts/ cp ../lib/local/LandmarkDetector/model/patch_experts/cen_patches_0.50_of.dat ./bin/model/patch_experts/
cp ../lib/local/LandmarkDetector/model/patch_experts/cen_patches_1.00_of.dat ./bin/model/patch_experts/ cp ../lib/local/LandmarkDetector/model/patch_experts/cen_patches_1.00_of.dat ./bin/model/patch_experts/
./bin/FaceLandmarkVid -f "../samples/changeLighting.wmv" -f "../samples/2015-10-15-15-14.avi" ./bin/FaceLandmarkVid -f "../samples/changeLighting.wmv" -f "../samples/2015-10-15-15-14.avi"
``` ```
For more details, please visit the OpenFace installation [guidelines](https://github.com/TadasBaltrusaitis/OpenFace/wiki/Unix-Installation).<br/> For more details, please visit the OpenFace installation [guidelines](https://github.com/TadasBaltrusaitis/OpenFace/wiki/Unix-Installation).<br/>
### Install Caffe:<br/> ### Install Caffe:<br/>
Install general dependencies: <br/> Install general dependencies: <br/>
`sudo apt-get install cmake libprotobuf-dev libleveldb-dev libsnappy-dev libhdf5-serial-dev protobuf-compiler libgflags-dev libgoogle-glog-dev liblmdb-dev`<br/> `sudo apt-get install cmake libprotobuf-dev libleveldb-dev libsnappy-dev libhdf5-serial-dev protobuf-compiler libgflags-dev libgoogle-glog-dev liblmdb-dev`<br/>
Download Caffe:<br/> Download Caffe:<br/>
`git clone https://github.com/BVLC/caffe.git`<br/> `git clone https://github.com/BVLC/caffe.git`<br/>
Download OpenGaze:<br/> Download OpenGaze:<br/>
`git clone https://git.hcics.simtech.uni-stuttgart.de/public-projects/opengaze.git`<br/> `git clone https://git.hcics.simtech.uni-stuttgart.de/public-projects/opengaze.git`<br/>
Copy the customized layers from OpenGaze to caffe:<br/> Copy the customized layers from OpenGaze to caffe:<br/>
`cp -r opengaze/caffe-layers/include caffe/`<br/> `cp -r opengaze/caffe-layers/include caffe/`<br/>
`cp -r opengaze/caffe-layers/src caffe/`<br/> `cp -r opengaze/caffe-layers/src caffe/`<br/>
Compile:<br/> Compile:<br/>
``` ```
cd caffe/ cd caffe/
mkdir build mkdir build
cd build cd build
cmake .. -DUSE_CUDNN=1 -DOPENCV_VERSION=3 -DBLAS=Open cmake .. -DUSE_CUDNN=1 -DOPENCV_VERSION=3 -DBLAS=Open
make all make all
make install make install
``` ```
For details please visit the [Caffe website](http://caffe.berkeleyvision.org/installation.html). For details please visit the [Caffe website](http://caffe.berkeleyvision.org/installation.html).
Now you should have successfully installed all the dependencies. Now you should have successfully installed all the dependencies.
## Compile OpenGaze ## Compile OpenGaze
Copy **CMakeLists.txt.example** and rename it to **CMakeLists.txt**. Copy **CMakeLists.txt.example** and rename it to **CMakeLists.txt**.
Configure the build by modifying the **CMakeLists.txt** for your setup. Configure the build by modifying the **CMakeLists.txt** for your setup.
1. **Caffe**<br/> 1. **Caffe**<br/>
Set the Caffe install path with "CAFFE_INSTALL_DIR"<br/> Set the Caffe install path with "CAFFE_INSTALL_DIR"<br/>
2. **OpenFace**<br/> 2. **OpenFace**<br/>
Set the OpenFace root directory with "OPENFACE_ROOT_DIR" Set the OpenFace root directory with "OPENFACE_ROOT_DIR"
3. **OpenGaze root path**<br/> 3. **OpenGaze root path**<br/>
Set the OpenGaze root path with "OPENGAZE_DIR", it will be the directory include Caffe models and camera calibration files etc. The defualt path is `/home/USER_NAME/OpenGaze` Set the OpenGaze root path with "OPENGAZE_DIR", it will be the directory include Caffe models and camera calibration files etc. The defualt path is `/home/USER_NAME/OpenGaze`
3. **Create an out-of-source build directory to store the compiled artifacts**:<br/> 3. **Create an out-of-source build directory to store the compiled artifacts**:<br/>
``` ```
cd OpenGaze cd OpenGaze
mkdir build mkdir build
cd build cd build
cmake .. cmake ..
make make
sudo make install sudo make install
``` ```
## Test OpenGaze ## Test OpenGaze
Download the pre-trained gaze estimation models by running:<br/> Download the pre-trained gaze estimation models by running:<br/>
`./download_models.sh` <br/> `./download_models.sh` <br/>
Note that all the configuration and model files will be located in the "~/OpenGaze" directory.<br/> Note that all the configuration and model files will be located in the "~/OpenGaze" directory.<br/>
Go to "exe" folder, open "CMakeLists.txt" file, modify "OPENGAZE_DIR" if necessary. Then compile the test examples: Go to "exe" folder, open "CMakeLists.txt" file, modify "OPENGAZE_DIR" if necessary. Then compile the test examples:
``` ```
cd exe/ cd exe/
mkdir build mkdir build
cd build/ cd build/
cmake .. cmake ..
make make
``` ```
Make sure your camera is connected to your computer, and then test it with:<br/> Make sure your camera is connected to your computer, and then test it with:<br/>
`./bin/GazeVisualization -d -t camera -i 0`<br/> `./bin/GazeVisualization -d -t camera -i 0`<br/>
Or test it with an existing video file:<br/> Or test it with an existing video file:<br/>
`./bin/GazeVisualization -d -t video -i ../exe/test.mp4`<br/> `./bin/GazeVisualization -d -t video -i ../exe/test.mp4`<br/>
### Make the .deb package file ### Make the .deb package file
I use [Checkinstall](https://wiki.debian.org/CheckInstall) to make the .deb file. When you reach the `make` step before "sudo make install" for OpenGaze, you can just type <br/> I use [Checkinstall](https://wiki.debian.org/CheckInstall) to make the .deb file. When you reach the `make` step before "sudo make install" for OpenGaze, you can just type <br/>
`sudo checkinstall --install=no` `sudo checkinstall --install=no`
to make a .deb file.<br/> to make a .deb file.<br/>
Follow the instructions to edit the software description, version, and organization. At last, you will find the compressed .deb file.<br/> Follow the instructions to edit the software description, version, and organization. At last, you will find the compressed .deb file.<br/>
## Ubuntu 18.04 ## Ubuntu 18.04
The default GCC version is 7.X with Ubuntu 18.04, which is not compatible with CUDA 9.0 (only works with GCC <= 6). This complicated situation results: GCC 7.x requires CUDA 9.2 and CUDA 9.2 requires a Nvidia driver version >= 396. <br/> The default GCC version is 7.X with Ubuntu 18.04, which is not compatible with CUDA 9.0 (only works with GCC <= 6). This complicated situation results: GCC 7.x requires CUDA 9.2 and CUDA 9.2 requires a Nvidia driver version >= 396. <br/>
### Install Nvidia driver ### Install Nvidia driver
Add the Nvidia ppa: <br/> Add the Nvidia ppa: <br/>
``` ```
sudo apt update sudo apt update
sudo apt upgrade sudo apt upgrade
sudo add-apt-repository ppa:graphics-drivers/ppa sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt update sudo apt update
sudo apt upgrade sudo apt upgrade
``` ```
If you try to install driver version 396 here, it will tell you there are some packages missing. However, you can install the driver from elsewhere.<br/> If you try to install driver version 396 here, it will tell you there are some packages missing. However, you can install the driver from elsewhere.<br/>
After that, go to the "Software & Update" in Ubuntu 18 system, go to "Additional Drivers", select `nvidia-driver-396`, and "Apply Changes".<br/> After that, go to the "Software & Update" in Ubuntu 18 system, go to "Additional Drivers", select `nvidia-driver-396`, and "Apply Changes".<br/>
Reboot the computer, then test the driver installation with `nvidia-smi`. <br/> Reboot the computer, then test the driver installation with `nvidia-smi`. <br/>
### Install CUDA ### Install CUDA
``` ```
wget https://developer.nvidia.com/compute/cuda/9.2/Prod2/local_installers/cuda_9.2.148_396.37_linux wget https://developer.nvidia.com/compute/cuda/9.2/Prod2/local_installers/cuda_9.2.148_396.37_linux
chmod +x cuda_9.2.148_396.37_linux chmod +x cuda_9.2.148_396.37_linux
sudo ./cuda_9.2.148_396.37_linux --override sudo ./cuda_9.2.148_396.37_linux --override
``` ```
Answer the following questions while installation begins: Answer the following questions while installation begins:
- You are attempting to install on an unsupported configuration. Do you wish to continue? y - You are attempting to install on an unsupported configuration. Do you wish to continue? y
- Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 384.81? n - Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 384.81? n
- Install the CUDA 9.0 Toolkit? y - Install the CUDA 9.0 Toolkit? y
- Do you want to install a symbolic link at /usr/local/cuda? y - Do you want to install a symbolic link at /usr/local/cuda? y
- Install the CUDA 10.0 Samples? n - Install the CUDA 10.0 Samples? n
and set up your paths: <br/> and set up your paths: <br/>
``` ```
echo 'export PATH=/usr/local/cuda/bin:$PATH' >> ~/.bashrc echo 'export PATH=/usr/local/cuda/bin:$PATH' >> ~/.bashrc
echo 'export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH' >> ~/.bashrc echo 'export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH' >> ~/.bashrc
echo 'export CPATH=/usr/local/cuda/include:$CPATH' >> ~/.bashrc echo 'export CPATH=/usr/local/cuda/include:$CPATH' >> ~/.bashrc
source ~/.bashrc source ~/.bashrc
``` ```
You can now test your CUDA installation with `nvcc --version`, which should show your nvcc version.<br/> You can now test your CUDA installation with `nvcc --version`, which should show your nvcc version.<br/>
### Install cuDNN ### Install cuDNN
Go to the [cuDNN archive](https://developer.nvidia.com/rdp/cudnn-archive) to download the "cuDNN v7.1.4 (May 16, 2018), for CUDA 9.2", and then install it with:<br/> Go to the [cuDNN archive](https://developer.nvidia.com/rdp/cudnn-archive) to download the "cuDNN v7.1.4 (May 16, 2018), for CUDA 9.2", and then install it with:<br/>
``` ```
tar -xzvf cudnn-9.2-linux-x64-v7.1.tgz tar -xzvf cudnn-9.2-linux-x64-v7.1.tgz
sudo cp cuda/include/cudnn.h /usr/local/cuda/include sudo cp cuda/include/cudnn.h /usr/local/cuda/include
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64 sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64
sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn* sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*
``` ```
You now can go compile it from the source and note that the pre-compiled file is only for Ubuntu 16.04. You now can go compile it from the source and note that the pre-compiled file is only for Ubuntu 16.04.