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编译(路径名需要根据实际情况设置):
vl_compilenn('enableGpu', true, ...
               'cudaMethod', 'nvcc', ...
               'cudaRoot', '/usr/local/cuda/', ...
               'enableCudnn', true, ...
               '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. 参考文献




评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值