ubuntu14.04安装matconvnet

前端之家收集整理的这篇文章主要介绍了ubuntu14.04安装matconvnet前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

ubuntu14.04安装matconvnet:

1.首先你的显卡得是INVIDA的,并且需要compute compability>2.0.

可以通过MATLAB输入:gpuDevice来确定你的显卡:

>> gpuDevice

ans =

CUDADevice with properties:

Name: 'GeForce 920M'
Index: 1
ComputeCapability: '3.5'
SupportsDouble: 1
DriverVersion: 8
ToolkitVersion: 5.5000
MaxThreadsPerBlock: 1024
MaxShmemPerBlock: 49152
MaxThreadBlockSize: [1024 1024 64]
MaxGridSize: [2.1475e+09 65535 65535]
SIMDWidth: 32
TotalMemory: 2.1010e+09
FreeMemory: 2.0546e+09
MultiprocessorCount: 2
ClockRateKHz: 954000
ComputeMode: 'Default'
GPUOverlapsTransfers: 1
KernelExecutionTimeout: 0
CanMapHostMemory: 1
DeviceSupported: 1
DeviceSelected: 1

cuda的话,可以去下载最高版本的。

下载地址:https://developer.nvidia.com/cuda-downloads 。(我的已安装好,没安装的可以百度其他的网址安装)

2.下载matconvnet:http://www.vlfeat.org/matconvnet/

解压tar -xzvf matconvnet-1.0-beta24.tar.gz

3.

本机配置

Ubuntu 14.04 + MATLAB 2014a + Cuda8.0

4.安装libjpeg:

sudo apt-get install libjpeg-dev

5.修改MatConvNet工具包下的makefile:

ENABLE_GPU ?= y
ENABLE_IMREADJPEG ?= y
ARCH ?= glnxa64
CUDAROOT ?= /usr/local/cuda-6.5
MATLABROOT ?= /usr/local/MATLAB/R2014a

CUDAMETHOD ?= nvcc

6.编译库

打开matlab:

一般编译:

vl_compilenn

使用CUDA编译:

vl_compilenn('enableGpu',true)

使用cudnn编译(路径名需要根据实际情况设置):

  1. vl_compilenn('enableGpu',true,...
  2. 'cudaMethod','nvcc',...
  3. 'cudaRoot','/usr/local/cuda/',...
  4. 'enableCudnn',...
  5. 'cudnnRoot','/usr/local/cuda')
7. 测试安装成功

vl_testnn
8.测试GPU可以用

vl_testnn('gpu',true)


  1. %setupMtConvNetinMATLAB
  2. runmatlab/vl_setupnn
  3. %downloadapre-trainedCNNfromtheweb
  4. urlwrite('http://www.vlfeat.org/sandBox-matconvnet/models/imagenet-vgg-f.mat',...
  5. 'imagenet-vgg-f.mat');
  6. net=load('imagenet-vgg-f.mat');
  7. %obtainandpreprocessanimage
  8. im=imread('peppers.png');
  9. im_=single(im);%note:255range
  10. im_=imresize(im_,net.normalization.imageSize(1:2));%resize为224*224大小的矩阵
  11. im_=im_-net.normalization.averageImage;%averageImage代表ImageNet统计到的图像均值信息,为224*224*3的矩阵<pre
  12. %runtheCNN
  13. res=vl_simplenn(net,im_);
  14. %showtheclassificationresult
  15. scores=squeeze(gather(res(end).x));
  16. [bestscore,best]=max(scores);
  17. figure(1);clf;imagesc(im);
  18. title(sprintf('%s(%d),score%.3f',...
  19. net.classes.description{best},best,bestscore));
( 其他的需要的自己下载) 原文链接:https://www.f2er.com/ubuntu/352932.html

猜你在找的Ubuntu相关文章