Ubuntu18.04+CUDA9.0+cuDNN7.1.3+openface安装总结

 

目录

 

前言

编译工具CMake

C++标准库安装

下载OpenFace代码

OpenCV安装

luarocks—Lua 包管理器,提供一个命令行的方式来管理 Lua 包依赖、安装第三方 Lua 包等功能

安装 TORCH—科学计算框架,支持机器学习算法 

安装依赖的 LUA库 

编译OpenFace代码

下载预训练后的数据

调用Demo测试


前言

Ubuntu18.04+CUDA9.0+cuDNN7.1.3 详细安装教程请参照:https://blog.csdn.net/ctwy291314/article/details/80951148,本文介绍安装opeface相关安装。

编译工具CMake

sudo apt-get install cmake

C++标准库安装

sudo apt-get install libboost-dev
sudo apt-get install libboost-python-dev

下载OpenFace代码

git clone https://github.com/cmusatyalab/openface.git

OpenCV安装

sudo apt-get install libopencv-dev
sudo apt-get install python-opencv

luarocks—Lua 包管理器,提供一个命令行的方式来管理 Lua 包依赖、安装第三方 Lua 包等功能

sudo apt-get install luarocks

安装 TORCH—科学计算框架,支持机器学习算法 

git clone https://github.com/torch/distro.git ~/torch --recursive
cd torch
bash install-deps
./install.sh

安装过程中可能出现以下异常:

cuda 9.0 "error: more than one operator "==" matches these operands"

完整异常信息:

/home/hylink/torch/extra/cutorch/lib/THC/generic/THCTensorMath.cu(393): error: more than one operator "==" matches these operands:
            function "operator==(const __half &, const __half &)"
            function "operator==(half, half)"
            operand types are: half == half

/home/hylink/torch/extra/cutorch/lib/THC/generic/THCTensorMath.cu(414): error: more than one operator "==" matches these operands:
            function "operator==(const __half &, const __half &)"
            function "operator==(half, half)"
            operand types are: half == half

2 errors detected in the compilation of "/tmp/tmpxft_00006aee_00000000-6_THCTensorMath.cpp1.ii".
CMake Error at THC_generated_THCTensorMath.cu.o.cmake:267 (message):
  Error generating file
  /home/hylink/torch/extra/cutorch/build/lib/THC/CMakeFiles/THC.dir//./THC_generated_THCTensorMath.cu.o


lib/THC/CMakeFiles/THC.dir/build.make:2939: recipe for target 'lib/THC/CMakeFiles/THC.dir/THC_generated_THCTensorMath.cu.o' failed
make[2]: *** [lib/THC/CMakeFiles/THC.dir/THC_generated_THCTensorMath.cu.o] Error 1
CMakeFiles/Makefile2:172: recipe for target 'lib/THC/CMakeFiles/THC.dir/all' failed
make[1]: *** [lib/THC/CMakeFiles/THC.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2

Error: Build error: Failed building.

原因是cuda和torch的头文件都提供了相同的重载运算符,编译器不知道用哪一个。输入下面shell命令禁止使用cuda的头文件编译torch即可:

export TORCH_NVCC_FLAGS="-D__CUDA_NO_HALF_OPERATORS__"

重新运行

./install.sh

重新开始编译就OK了,安装过程中它会提示是否把torch加入bashrc中,有”….(yes|no)”提示,输入yes,即可。

编译成功过后,输入命令

source ~/.bashrc

使torch立即生效

输入th进行验证是否安装成功

安装依赖的 LUA库 

luarocks install dpnn

注:cunn使用了cuda,如果不使用GPU来跑的话,不需要安装这个;fblualib和torchx都是用来训练DNN的,建议安装。

luarocks install dpnn  
luarocks install nn  
luarocks install optim  
luarocks install csvigo  
luarocks install cunn
luarocks install fblualib  
luarocks install torchx  

编译OpenFace代码

python setup.py build
sudo python setup.py install

下载预训练后的数据

sh models/get-models.sh

调用Demo测试

cd openface
python demos/compare.py images/examples/{lennon-1.jpg,lennon-2.jpg}

官方文档:

http://cmusatyalab.github.io/openface/demo-1-web/

http://cmusatyalab.github.io/openface/setup/

猜你喜欢

转载自blog.csdn.net/ctwy291314/article/details/81661287
今日推荐