【问题标题】:Mexcuda error on Windows 10 (Matlab 2016b)Windows 10 上的 Mexcuda 错误(Matlab 2016b)
【发布时间】:2017-08-11 12:38:27
【问题描述】:

我使用的是 Windows 10,这是 mex 使用的编译器(如您所见,我使用的是 Visual Studio C++ 2015):

 >> mex -setup c++
  MEX configured to use 'Microsoft Visual C++ 2015 Professional' for C++ language compilation.

  Warning: The MATLAB C and Fortran API has changed to support MATLAB
     variables with more than 2^32-1 elements. In the near future
     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 C++ compiler, select one from the following:
  MinGW64 Compiler (C++)  mex -setup:'C:\Program Files\MATLAB_R2016b\bin\win64\mexopts\mingw64_g++.xml' C++
  Microsoft Visual C++ 2015 Professional  mex -setup:C:\Users\LENOVO\AppData\Roaming\MathWorks\MATLAB\R2016b\mex_C++_win64.xml C++

这是使用 gpuDevice 的结果:

>> gpuDevice

  ans = 

    CUDADevice with properties:

                        Name: 'Quadro M1000M'
                       Index: 1
           ComputeCapability: '5.0'
              SupportsDouble: 1
               DriverVersion: 8
              ToolkitVersion: 7.5000
          MaxThreadsPerBlock: 1024
            MaxShmemPerBlock: 49152
          MaxThreadBlockSize: [1024 1024 64]
                 MaxGridSize: [2.1475e+09 65535 65535]
                   SIMDWidth: 32
                 TotalMemory: 2.1475e+09
             AvailableMemory: 1.6919e+09
         MultiprocessorCount: 4
                ClockRateKHz: 1071500
                 ComputeMode: 'Default'
        GPUOverlapsTransfers: 1
      KernelExecutionTimeout: 1
            CanMapHostMemory: 1
             DeviceSupported: 1
              DeviceSelected: 1

在 Windows 命令提示符下,我检查 nvcc 时的结果:

 C:\Users\LENOVO>nvcc --version
  nvcc: NVIDIA (R) Cuda compiler driver
  Copyright (c) 2005-2016 NVIDIA Corporation
  Built on Mon_Jan__9_17:32:33_CST_2017
  Cuda compilation tools, release 8.0, V8.0.60

但是似乎有一些警告:

C:\Users\LENOVO>nvcc
  nvcc warning : The 'compute_20', 'sm_20', and 'sm_21' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
  nvcc fatal   : No input files specified; use option --help for more information

无论如何,当我尝试使用 mexcuda 编译 mexGPUExample.cu 时,出现了错误:

 >> mexcuda -v mexGPUExample.cu
  Warning: The selected C++ compiler is not supported for CUDA compilation. Searching for a supported
  compiler. 
  > In mexcuda (line 89) 
  Trying MEX options 'C:\Program Files\MATLAB_R2016b\toolbox\distcomp\gpu\extern\src\mex\win64\nvcc_msvcpp2013.xml'...FAILED
  Trying MEX options 'C:\Program Files\MATLAB_R2016b\toolbox\distcomp\gpu\extern\src\mex\win64\nvcc_msvcpp2012.xml'...FAILED
  Warning: No supported host compiler found, or other problem with the environment.
  Continuing with selected compiler to provide detailed diagnosis. 
  > In mexcuda (line 130) 
  mex -largeArrayDims -f C:\Program Files\MATLAB_R2016b\toolbox\distcomp\gpu\extern\src\mex\win64\nvcc_msvcpp2013.xml NVCC_FLAGS="" -v mexGPUExample.cu 
  Verbose mode is on.
  ... Looking for compiler 'NVIDIA CUDA Compiler' ...
  ... Looking for registry setting 'HKLM\SOFTWARE\Microsoft\VisualStudio\SxS\VS7' 12.0 ...No.
  ... Looking for registry setting 'HKCU\SOFTWARE\Microsoft\VisualStudio\SxS\VS7' 12.0 ...No.
  ... Looking for registry setting 'HKLM\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\SxS\VS7' 12.0 ...No.
  ... Looking for registry setting 'HKCU\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\SxS\VS7' 12.0 ...No.
  Did not find installed compiler 'NVIDIA CUDA Compiler'.
  Error using mex
  No supported compiler or SDK was found. For options, visit
  http://www.mathworks.com/support/compilers/R2016b/win64.html.

  Error in mexcuda (line 157)
      [varargout{1:nargout}] = mex(mexArguments{:});

但我已经安装了 Visual C++ 2015 编译器,CUDA 编译器支持该编译器(根据:https://www.mathworks.com/matlabcentral/answers/270635-mexcuda-error-on-windows-10-matlab-2015-b)。我很困惑:( 请帮助我,非常感谢您

【问题讨论】:

  • 对于受支持的 CUDA 编译器,请信任 NVIDIA better。但是,应该支持您的。当我编译我的 .cu 文件时,而不是使用 mexcuda 我使用 mex 并有一个带有 nvcc 标志和其他东西的 .xml 文件。你试过吗?
  • @AnderBiguri 如何设置这个 .xml 文件,你能给我链接吗?
  • 在尝试之前,请尝试mex -setup:C:\Users\LENOVO\AppData\Roaming\MathWorks\MATLAB\R2016b\mex_C++_win64.xml C++。否则,请检查xml file here。您可能需要修改一些路径和编译器标志。 YMMV

标签: matlab visual-c++ cuda installation gpu


【解决方案1】:

MATLAB R2016b 需要 CUDA 7.5,它不支持 Visual Studio 2015。所以它要做的第一件事就是检查你没有的 Visual Studio 版本。

此 Matlab 答案提供了强制 MATLAB 使用 CUDA 8.0 和 Visual Studio 14 的解决方法:

https://www.mathworks.com/matlabcentral/answers/305391-compiling-cuda-files-with-mexcuda-why-wont-matlab-accept-my-compiler

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-04-18
    • 2018-11-21
    • 2018-03-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-21
    相关资源
    最近更新 更多