centos 安装 MatConvNet gpu

1. 安装准备

  • matlab2017a ,参考:centos 安装matlab2017a(无root权限)
  • GCC 4.8(支持c++11) 键入:sudo yum install gcc gcc-c++ (建议sudo装)
  • 至少CUDA 7.5,(本人选择cuda8.0)
  • CuDNN v4 (与cuda8对应,选择cudnn v5.0)
  • LibJPEG 键入:sudo yum install libjpeg-turbo-devel (建议sudo装)
注意:直接使用以上命令安装Libjpeg可能会出现找不到"jpeglib.h"的错误,这时需要运行:
sudo yum -y install libjpeg*
这时可以检查如下目录,确认文件存在即可。


首先需要下载matconvenet,然后打开matlab进入到matconvnet-1.0-beta25/matlab
目录下,即vl_compilenn的目录下。

2. 开始安装

1). 先设置mex ,即:
 mex -setup 
 mex -setup C++
结果:
>> mex -setup
MEX configured to use 'gcc' for C language compilation.
Warning: The MATLAB C and Fortran API has changed to support MATLAB
	 variables with more than 2^32-1 elements. You will be required
	 to update your code to utilize the new API.
	 You can find more information about this at:
	 http://www.mathworks.com/help/matlab/matlab_external/upgrading-mex-files-to-use-64-bit-api.html.

To choose a different language,select one from the following:
 mex -setup C++ 
 mex -setup FORTRAN
MEX configured to use 'g++' for C++ language compilation.
Warning: The MATLAB C and Fortran API has changed to support MATLAB
	 variables with more than 2^32-1 elements. You will be required
	 to update your code to utilize the new API.
	 You can find more information about this at:
	 http://www.mathworks.com/help/matlab/matlab_external/upgrading-mex-files-to-use-64-bit-api.html.
>> 
2).设置gpu支持
为了增加gpu加速,你需要NVIDIA GPU,且运算能力在2.0以上
你也可以使用gpuDevice在matlab中查找合适的cuda版本

显然我的是cuda8.0.
3).如果只装了一个cuda,且匹配matlab的版本,此时可以运行如下命令编译:
 vl_compilenn('enableGpu',true)
但如果装了好几个cuda,此时需要指定cuda的位置,即:

vl_compilenn('enableGpu',true,'cudaRoot','/Developer/NVIDIA/CUDA-8.0')


4).编译cuDNN支持

  • 一般编译:
> vl_compilenn
  • 使用CUDA编译:
vl_compilenn('enableGpu',true) 
  • 使用cudnn编译(路径名需要根据实际情况设置):
damethod','nvcc',... 'cudaRoot','/usr/local/cuda/',... 'enableCudnn',... 'cudnnRoot','/usr/local/cuda') 注意:以上命令进入matlab中执行。需要先进入matlab目录下,然后执行vl_compilenn。

3. 测试

进入到xtest目录下,执行
vl_testnn
如果测试gpu支持的话,执行:
vl_testnn('gpu',true)

运行结束,会有一个总结,如果没有错误实例,则表明安装成功。



补充说明:

如果要在matlab指定使用gpu的话,可以提前使用gpuDevice,参考:https://cn.mathworks.com/help/distcomp/gpudevice.html


4. 参考文献

相关文章

Centos下搭建性能监控Spotlight
CentOS 6.3下Strongswan搭建IPSec VPN
在CentOS6.5上安装Skype与QQ
阿里云基于centos6.5主机VPN配置
CentOS 6.3下配置multipah
CentOS安装、配置APR和tomcat-native