【1】Matlab深度学习环境配置-入门

  1. 编译环境配置

软件需求:

  1. Matlab 2019b
  2. cudnn cudnn-10.1-windows10-x64-v7.6.4.38
  3. TensorRT-6.0.1.5.Windows10.x86_64.cuda-10.1.cudnn7.6
  4. Cuda 10.1 cuda_10.1.105_418.96_win10

下载路径。

Maltab  GPU 环境要求https://ww2.mathworks.cn/help/gpucoder/gs/install-prerequisites.html

CUDNN https://developer.nvidia.com/rdp/cudnn-archive

TenosRThttps://developer.nvidia.com/nvidia-tensorrt-5x-download

CUDA https://developer.nvidia.com/cuda-toolkit-archive

https://blog.csdn.net/charlotteYue/article/details/106146482

 

Matlab深度学习入门之树莓派与GPU应用。

 

打开cmd nvcc –version 或者 nvcc -V nvidia-smi nvidia-smi -q

NVIDIA-SMI 419.67       Driver Version: 442.19

  1. cudnnlibbininclude复制到cuda包含相同目录下。
  2. tensort 文件夹复制到cuda\v10.1 下面;同时将tensort 下的lib文件夹中的dll拷贝到cuda\v10.1\bin里边。

---------------------------------------------------------------------------------------------------------------

配置环境变量:

CUDA_PATH= C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1

CUDA_PATH_V10_1= C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1

NVIDIA_CUDNN= C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1

NVIDIA_TENSORRT= C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\TensorRT

在Path下添加:

【1】Matlab深度学习环境配置-入门_第1张图片

 

打开matlab 进行输入以下命令

mex -setup:' D:\ProgramFiles\MATLAB\R2019b\bin\win64\mexopts\msvc2017.xml' C -v

coder.checkGpuInstall('gpu','codegen','cudnn','quiet');

gpuDeviceCount

 

【1】Matlab深度学习环境配置-入门_第2张图片

CUDA_PATH

Path to the CUDA® toolkit installation.

For example:

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\

NVIDIA_CUDNN

Path to the root folder of cuDNN installation. The root folder contains the bin, include, and lib subfolders.

For example:

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\cuDNN\

NVIDIA_TENSORRT

Path to the root folder of TensorRT installation. The root folder contains the bin, data, include, and lib subfolders.

For example:

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\TensorRT\

OPENCV_DIR

Path to the build folder of OpenCV on the host. This variable is required for building and running deep learning examples.

For example:

C:\Program Files\opencv\build

PATH

Path to the CUDA executables. Generally, the CUDA toolkit installer sets this value automatically.

For example:

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\bin

Path to the cudnn.dll dynamic library. The name of this library may be different on your installation.

For example:

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\cuDNN\bin

Path to the nvinfer* dynamic libraries of TensorRT. The name of this library may be different on your installation.

For example:

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\TensorRT\lib

Path to the Dynamic-link libraries (DLL) of OpenCV. This variable is required for running deep learning examples.

For example:

C:\Program Files\opencv\build\x64\vc15\bin

 

 

Hi there, I was trapped in this error within the whole day. I'm using yolo to dectect objects, while I'm just using it but not trying to compile it. So when I used single or multiple CPUs to run the vehicle_Dataset, I found the training process was unable to be accomplished as matlab was out of memory.

So I turned to try to deploy the taining using my GPU, which is Geforce GTX 1060. I installed the new divers for this Graphic card(ver 430.64), CUDA toolkit 10.1, cuDNN v7.5.1 (April 22, 2019) for CUDA 10.1. Then I created

Variable name: CUDA_PATH

Variable value: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1

in the system variables. Also, I added

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\lib\x64

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\extras\CUPTI\lib64

in the Path.

All the add-on on this page was also installed:

https://ww2.mathworks.cn/help/vision/ug/code-generation-for-object-detection-using-yolo-v2.html?searchHighlight=yolo&s_tid=doc_srchtitle

including "GPU Coder Interface for Deep Learning Libraries support package", Microsoft Visual Studio 2017, "MATLAB Support for MinGW-w64 C/C++ Compiler".

Then, I ran the following code in matlab, which worked very good.

mex -setup:'C:\Program Files\MATLAB\R2018b\bin\win64\mexopts\msvc2017.xml' C -v

mex -setup:'C:\Program Files\MATLAB\R2019a\bin\win64\mexopts\msvc2017.xml' C -v

Then I ran

coder.checkGpuInstall('gpu','codegen','cudnn','quiet');

Matlab inform me as

Error using coder.checkGpuInstall (line 32)

One or more of the system checks did not pass, with the following errors ...

Basic Code Generation: (Test GPU code generation failed with the error 'emlc:compilationError'. View report for further information: View report)

So I click the View report, and it says:

Build error: C++ compiler produced errors. See the Build Log for further details.

While the build logs has 1659 lines... I have attached the ecported reports in tha attachment. So I detected the current setup with coder.checkGpuInstall();

Compatible GPU           : PASSED

CUDA Environment         : PASSED

   Runtime   : PASSED

   cuFFT     : PASSED

   cuSOLVER  : PASSED

   cuBLAS    : PASSED

cuDNN Environment        : PASSED

Basic Code Generation    : FAILED (Test GPU code generation failed with the error 'emlc:compilationError'. View report for further information: View report)

So could anyone help me out of this problem? Thanks a lot in advance!

    1. 错误处理

在命令行里,直接输入 nvidia-smi.exe如果不能识别命令,在确保正确安装相应cuda版本的情况下,在环境变量里加入该执行文件路径即可。
即设置Path变量,我的目录为: C:\Program Files\NVIDIA Corporation\NVSMI

 

So I'm using the provided MATLAB function to check my gpu build but I always end up obtaining this extrange error which says that there is no class or variable "coder". I'm running this under Windows 10 x64, NVIDIA CUDA v10.1 and latest cuDNN libraries on MATLAB R2019a.

coder.checkGpuInstall()

Compatible GPU           : PASSED

CUDA Environment         : PASSED

   Runtime   : PASSED

   cuFFT     : PASSED

   cuSOLVER  : PASSED

   cuBLAS    : PASSED

cuDNN Environment        : PASSED

Error using coder.checkGpuInstall (line 32)

Undefined variable "coder" or class "coder.gpuConfig"

      1. Nvcc  —V错误

https://blog.csdn.net/jinshelj/article/details/80193021

    1. 配置环境

coder.checkGpuInstall('gpu','codegen','cudnn','quiet')

 

%   Example:

%       gpuEnvObj = coder.gpuEnvConfig;

%       gpuEnvObj.GpuId = 1;

%       gpuEnvObj.BasicCodegen = 1;

%       gpuEnvObj.BasicCodeexec = 1;

%       results = coder.checkGpuInstall(gpuEnvObj);

%

         Hardware: 'host'

            GpuId: 1

     BasicCodegen: 1

    BasicCodeexec: 0

      DeepCodegen: 0

     DeepCodeexec: 0

    DeepLibTarget: ''

         DataType: ''

        GenReport: 0

            Quiet: 0

        Profiling: 0

         CudaPath: 'C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1'

     TensorrtPath: ''

         NvtxPath: 'C:\Program Files\NVIDIA Corporation\NvToolsExt\'

        CudnnPath: '

  1. 网络资源链接

https://blog.csdn.net/lanluyug/article/details/89516520

https://www.bilibili.com/video/av78056483/  matlab深度学习

使Jupyter Lab( Jupyter Notebook)支持Matlab的方法 https://blog.csdn.net/weixin_38538305/article/details/84730078

https://blog.csdn.net/caokaifa?t=1

https://github.com/weiniuzhu/DeepLearning-Converter-for-Darknet-Matlab-Model-Format  各种模型的导入到matlab

https://ww2.mathworks.cn/videos/automated-lidar-point-cloud-annotation-for-sensor-verification-1527491006097.html

https://www.mathworks.com/academia/courseware/teaching-deep-learning-with-matlab.html

      1. MATLAB资源
  • MATLAB Onramp2小时入门教程)
  • 深度学习Onramp2小时入门教程)
  • 使用MATLAB进行深度学习16小时深入课程)
  • 深度学习工具箱(文档)
  • 深度学习应用程序库(代码示例)
  • MATLAB Online(在浏览器中使用MATLAB
  • MATLAB Grader(自动对MATLAB代码分配进行评分)
  • 数据科学深度学习  机器学习的最新功能和资源(最新发布的产品功能)
  • 深度学习(博客)

https://www.mathworks.com/academia/courseware/modelling-design-control-robotic-mechanisms.html  机器人机构的建模,设计和控制”课件

 

Maltab  GPU 环境要求https://ww2.mathworks.cn/help/gpucoder/gs/install-prerequisites.html

CUDNN https://developer.nvidia.com/rdp/cudnn-archive

TenosRThttps://developer.nvidia.com/nvidia-tensorrt-5x-download

CUDA https://developer.nvidia.com/cuda-toolkit-archive

上述是使用Deep Learning Toolbox建议的环境要求及工具包使用情况。翻译成中文是:

    1. 打开DL Toolbox

在matlab命令框输入:deepNetworkDesigner

如果需要使用alexnet,则需要下载deeplearning for alexnet工具箱

1)需要MATLAB

2)建议使用并行计算工具箱,这是GPU支持所需的图像处理工具箱

3)计算机视觉工具箱推荐

4)GPU编码器推荐

5)MATLAB编码器推荐

6)Simulink推荐

7)建议使用强化学习工具箱

另一方面,matlab还可以利用第三方已经实现好的一些模型处理一般场景。比如用训练好的googLeNet来识别图片,或识别摄像头里的动态场景。

 

    1. GPU coder cnncodegen工具

生产C++代码用于树莓派arm处理器;

cnncodegen(net,xx,xxx)

    1. Squeezenet

轻量级压缩网络

    1.  DeepNetwork Designer
    2. 1.5 ONNX开放式的神经网络交换
  • 【1】Matlab深度学习环境配置-入门_第3张图片

ImportONNXnetwork

  1. 调用其它现有网络
  1. 打开get more app输入Transfer Learning,进行下载迁移学习工具箱。

版本 2019.6.2 (1.17 MB) 作者: Kevin Chng

Transfer Learning of Pre-trained Neural Network or Imported ONNX Classification Model in GUI

  1. 例子搜索,Get Started with Transfer Learning
    1. matlab调用keras深度学习模型(环境搭建)
    2. MATLAB对Alexnet模型进行迁移学习  https://blog.csdn.net/qq_41569159/article/details/89048904
    3. 在matlab上使用自己的数据进行迁移学习  https://blog.csdn.net/weixin_38538305/article/details/84730078基于Matlab的AlexNet图像迁移学习
    4. 基于Matlab的AlexNet图像迁移学习 
    5. 手把手教你用matlab做深度学习 https://blog.csdn.net/caokaifa/article/details/81155584
    6. https://www.cnblogs.com/nwpuxuezha/p/7834344.html

    7. https://github.com/JiJingYu

你可能感兴趣的:(人工智能,tensorflow,matlab,深度学习)