Using mex with CUDA

조회 수: 20 (최근 30일)
Jack Lee
Jack Lee 2020년 7월 13일
댓글: Joss Knight 2021년 7월 20일
I've got CUDA and mex files running seperately in C, but when I use both in the same program it doesn't compile, I think because the associated cuda headers don't load properly when it's compiled by matlab rather than visual studio.
How do I get both of these to work together?
  댓글 수: 2
Prabhan Purwar
Prabhan Purwar 2020년 7월 16일
Could you please attach the code you are trying to compile for better assistance.
Jack Lee
Jack Lee 2020년 7월 16일
My current problem is that when I use mexCUDA, I get the error "nvcc fatal : Unsupported gpu architecture 'compute_30'".
I'm using 2020 matlab, and I've tried the 11.0 and 9.1 cuda toolkits. My Gpu's a GeForce MX130.
I'm compiling a simple program just by calling mexcuda on it, so I don't think that's the issue, and from researching it seems that a fix is to remove a line from "makefile.config" or something, but I can't find the file to change.
Any help would be appreciated.

댓글을 달려면 로그인하십시오.

답변 (2개)

Prabhan Purwar
Prabhan Purwar 2020년 7월 20일
Hi,
Check the GPU and CUDA version supported by MATLAB current release from NVIDIA's website.
Install CUDA
CUDA - Getting Started on Windows
  • Install CUDA driver
  • Install CUDA toolkit
  • Install CUDA SDK
  • restart computer
Verify CUDA Installation
  • To verify installation, from the Window's command prompt:
nvcc -V
  • Run the bandwidthTest program located in
%NVSDKCUDA_ROOT%\bin\win32\Release
Where, in my case, %NVSDKCUDA_ROOT% is C:\WINNT\Profiles\All Users\Application Data\NVIDIA Corporation\NVIDIA GPU Computing SDK\C
Compile CUDA Code
Compile your CUDA code using MEX in MATLAB.
MATLAB MEX
If you run into issues wherein some of the CUDA libraries are not found, you may either find the libraries and add them to your current directory, or add a few directories to the PATH:
C:\CUDA\bin; %NVSDKCUDA_ROOT%\common\lib; %NVSDKCUDA_ROOT%\common\inc;
  댓글 수: 1
Jack Lee
Jack Lee 2020년 7월 20일
Hi, thanks, I've tried this - nvcc works from command prompt, I'm using the compatable versions of matlab and the toolkit and bandwithTest passes my GPU, but I still get "nvcc fatal : Unsupported gpu architecture 'compute_30' " when I run mexcuda.
Would you mind explaining what this specific error means, and if there's anything I can change to deal with it?

댓글을 달려면 로그인하십시오.


Joss Knight
Joss Knight 2020년 8월 4일
편집: Joss Knight 2020년 8월 4일
Hi Jack. I expect the answer to this question is that you have installed a more recent version of the CUDA toolkit, specifically CUDA 11, and are attempting to compile with it. MATLAB R2020a is on CUDA 10.1 and by default will attempt to build compute_30 binaries, that CUDA 11 doesn't support. It's hard to know exactly what you're doing so you should show exactly what you are seeing, specifically what are you calling in MATLAB and what is the verbose output? (-v option to MEXCUDA). I ask this because if you were using MEXCUDA in a standard way it wouldn't allow you to compile with CUDA 11. I'm guessing you've compiled some binaries in MATLAB with its version of CUDA and are attempting to link them with a CUDA 11 version of nvcc. Or perhaps it's the other way round - you compiled some libraries using CUDA 11 and they are missing compute_30 binaries and then you attempted to link them when building using MEXCUDA.
  댓글 수: 2
aboharbf
aboharbf 2021년 7월 19일
Hi Joss,
Is this also the case with MATLAB 2021a and CUDA 11.0? I'm using 3080 and this seemed to be the way to go.
Joss Knight
Joss Knight 2021년 7월 20일
You'd have to give details on the errors you are seeing. MATLAB 2021a uses CUDA 11, so no compute_30 binaries will be coming from MATLAB in that case.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 GPU Computing에 대해 자세히 알아보기

태그

제품


릴리스

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by