diff --git a/Unix-installation.md b/Unix-installation.md new file mode 100644 index 0000000..8cb573b --- /dev/null +++ b/Unix-installation.md @@ -0,0 +1,222 @@ +This installation was tested on the following configuration: +* OS: Ubuntu 16.04 +* CUDA 9.0 +* CUDNN 7.1 +* OpenCV 3.4 +* Caffe 1.0 +* OpenFace 2.0 +* Boost 1.5 + +**If you have Ubuntu 18.04, please refer to the [configuration information](https://github.molgen.mpg.de/perceptual/opengaze_old/wiki/Unix-Installation#ubuntu-1804).** + +## 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. + +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 +1. Install GPU driver:
+ 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.
+ If you do not have the driver, then you can install the driver with `sudo ubuntu-drivers autoinstall`
+ Then reboot your computer
+ You now should test the Nvidia driver with `nvidia-smi`
+ +2. Install CUDA
+ 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:
+ +``` + wget https://developer.nvidia.com/compute/cuda/9.0/Prod/local_installers/cuda_9.0.176_384.81_linux-run + chmod +x cuda_9.0.176_384.81_linux-run + sudo ./cuda_9.0.176_384.81_linux-run --override +``` + Answer these questions as follows while installation begins: + - Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 384.81? n + - Install the CUDA 9.0 Toolkit? y + - Do you want to install a symbolic link at /usr/local/cuda? y + - Install the CUDA 10.0 Samples? n + + Set up your paths:
+``` + echo 'export PATH=/usr/local/cuda/bin:$PATH' >> ~/.bashrc + echo 'export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH' >> ~/.bashrc + echo 'export CPATH=/usr/local/cuda/include:$CPATH' >> ~/.bashrc + source ~/.bashrc +``` + You can now test your CUDA installation with `nvcc --version`, which should show your nvcc version.
+ +3. Install cuDNN
+ cuDNN is a GPU-accelerated library from Nvidia.
+ 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:
+``` + tar -xzvf cudnn-9.0-linux-x64-v7.1.tgz + sudo cp cuda/include/cudnn.h /usr/local/cuda/include + sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64 + sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn* +``` + +## Install OpenGaze with pre-compiled binary +You can easily install OpenGaze with our pre-compiled binary file. +1. Install other dependencies with `./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. +4. Compile the test example: +``` +cd exe/ +mkdir build +cd build +cmake .. +make +``` +4. Run the test [Run the test](https://github.molgen.mpg.de/perceptual/opengaze_old/wiki/Unix-Installation#test-opengaze)
+ +## 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.
+ +### Install OpenFace v2.0
+1. Install +``` +git clone https://github.com/TadasBaltrusaitis/OpenFace.git +cd OpenFace +``` +Open the file 'install.sh', and change the "BUILD_SHARED_LIBS=OFF" to "BUILD_SHARED_LIBS=ON" for OpenCV. Then run +``` +./install.sh +``` +**Warning:** It requires typing a "Y" in the middle of the installation. Do not leave it unattended.
+ +2. Download the necessary models: +Open the file "download_models.sh", set your OpenGaze root directory, which defualt value is "~/OpenGaze".
+``` +chmod +x download_models.sh +./download_models.sh +``` +3. Test it: +``` +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.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_1.00_of.dat ./bin/model/patch_experts/ +./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).
+ +### Install Caffe:
+Install general dependencies:
+ + `sudo apt-get install cmake libprotobuf-dev libleveldb-dev libsnappy-dev libhdf5-serial-dev protobuf-compiler libgflags-dev libgoogle-glog-dev liblmdb-dev`
+ Download Caffe:
+`git clone https://github.com/BVLC/caffe.git`
+ Download OpenGaze:
+`git clone https://github.molgen.mpg.de/perceptual/opengaze.git`
+ Copy the customized layers from OpenGaze to caffe:
+`cp -r opengaze/caffe-layers/include caffe/` +`cp -r opengaze/caffe-layers/src caffe/`
+ Compile:
+``` +cd caffe/ +mkdir build +cd build +cmake .. -DUSE_CUDNN=1 -DOPENCV_VERSION=3 -DBLAS=Open +make all +make install +``` + For details please visit the [Caffe website](http://caffe.berkeleyvision.org/installation.html). + +Now you should have successfully installed all the dependencies. + +## Compile OpenGaze + +Configure the build by modifying the **CMakeLists.txt** for your setup. + +1. **Caffe**
+Set the Caffe install path with "CAFFE_INSTALL_DIR"
+ +2. **OpenFace**
+Set the OpenFace root directory with "OPENFACE_ROOT_DIR" + +3. **OpenGaze root path**
+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**:
+``` +cd OpenGaze +mkdir build +cd build +cmake .. +make +sudo make install +``` + +## Test OpenGaze +Download the pre-trained gaze estimation models by running:
+`./download_models.sh`
+Note that all the configuration and model files will be located in the "~/OpenGaze" directory.
+Go to "exe" folder, open "CMakeLists.txt" file, modify "OPENGAZE_DIR" if necessary. Then compile the test examples: +``` +cd exe/ +mkdir build +cd build/ +cmake .. +make +``` +Make sure your camera is connected to your computer, and then test it with:
+`./bin/GazeVisualization -d -t camera -i 0`
+Or test it with an existing video file:
+`./bin/GazeVisualization -d -t video -i ../exe/test.mp4`
+ +### 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
+`sudo checkinstall --install=no` +to make a .deb file.
+Follow the instructions to edit the software description, version, and organization. At last, you will find the compressed .deb file.
+ +## 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.
+ +### Install Nvidia driver +Add the Nvidia ppa:
+``` +sudo apt update +sudo apt upgrade +sudo add-apt-repository ppa:graphics-drivers/ppa +sudo apt update +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.
+After that, go to the "Software & Update" in Ubuntu 18 system, go to "Additional Drivers", select `nvidia-driver-396`, and "Apply Changes".
+Reboot the computer, then test the driver installation with `nvidia-smi`.
+ +### Install CUDA +``` + 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 + sudo ./cuda_9.2.148_396.37_linux --override +``` + + Answer the following questions while installation begins: + - 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 the CUDA 9.0 Toolkit? y + - Do you want to install a symbolic link at /usr/local/cuda? y + - Install the CUDA 10.0 Samples? n + +and set up your paths:
+``` + echo 'export PATH=/usr/local/cuda/bin:$PATH' >> ~/.bashrc + echo 'export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH' >> ~/.bashrc + echo 'export CPATH=/usr/local/cuda/include:$CPATH' >> ~/.bashrc + source ~/.bashrc +``` + You can now test your CUDA installation with `nvcc --version`, which should show your nvcc version.
+ +### 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:
+``` + tar -xzvf cudnn-9.2-linux-x64-v7.1.tgz + sudo cp cuda/include/cudnn.h /usr/local/cuda/include + sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64 + 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. \ No newline at end of file diff --git a/test.md b/test.md deleted file mode 100644 index 30d74d2..0000000 --- a/test.md +++ /dev/null @@ -1 +0,0 @@ -test \ No newline at end of file