Invalid MEX-file The specified procedure could not be found : Calling a CUDA MEX function

I want to use some mex function in MATLAB ( http://patternsonascreen.net/cuSVM.html) that is written with CUDA language for executing on Nvidia GPUs.

I start with building .mexw64 version of it using the Visual Studio, But I got the invalid mex file error when I tried to call it in MATLAB:

??? Invalid MEX-file 'I:\cusvm_vs2005.mexw64': The specified procedure could not

be found.

I already used the dependency walker. Initially the “IESHIMS.DLL” and “MSVCR80.DLL” are missing. I put the first in system32 and the second in current matlab folder.

The Dependency Walker still get error:

Error: At least one module has an unresolved import due to a missing export function in an implicitly dependent module.

Warning: At least one module has an unresolved import due to a missing export function in a delay-load dependent module.

The DLL-tree has a red "nvcuda.dll" block and a red "ieframe.dll" block in its sub-tree.

I currently use VS2005, Matlab 2010b, Window 7 (64 bit), cuda toolkit 3.2.

The original cuSVM code is implemented on window xp (32 bit) and VS2005, So It has .mexw32 version in its package.

DETAILS-------------------------------------------------------------------------------------------------------------------------------

(1)

I uploaded two files of the project:

-mex function and its MATLAB test code

-visual studio project that builds the .mexw64 file.

The shared links are:

http://www.4shared.com/zip/B4u7WTvk/cusvm_mex_test.html

http://www.4shared.com/zip/duBVHVIM/cusvm_mex_building.html

(2)Some details of the steps I followed, can be found in my question in the following websites:

http://www.parallelcoding.com/2012/02/09/cusvm-in-visual-studio-2010-with-cuda-4-0/comment-page-1/#comment-19233

http://stackoverflow.com/questions/9530553/invalid-mex-the-specified-procedure-could-not-be-found-building-a-cuda-mex-fu

http://forums.nvidia.com/index.php?showtopic=223329

I appreciate your help and comments.

Hi Superbot

I have successfully been using these two small guides on how to get CUDA functioning well on Matlab. I use a different setup from you (MSVC++ 8.0, Matlab R2011b x64) but otherwise it should work identically.

The first is: Using C/C++ under Matlab (Part 2) - COMISEF Wiki

which allows you to create a basic Matlab dll. Just remember to link to the 64-bit matlab library, name the output mexw64 instead of mexw32, and you should be fine. Remember to set the Visual C++ target machine to x64 and download the correct compiler libraries if you have not already done that. For help here, google is you friend.

After this, you can use: cuda - problem with nvmex in matlab - Stack Overflow

to include cuda functionality.

For basic functionality testing along with cuda include library and linking library check, you can use

#include <mex.h>

#include <cuda.h>

#include <driver_types.h>

#include <cuda_runtime_api.h>

void mexFunction( int nlhs, mxArray * plhs[], int nrhs, const mxArray *prhs[])

{

	cudaDeviceProp cudaDvcProp;

	cudaError_t cudaError;

	cudaError = cudaGetDeviceProperties( &cudaDvcProp, 0 );

	

	mexPrintf( "Name: %s\n", cudaDvcProp.name );

	mexPrintf( "Total memory: %d MB\n", cudaDvcProp.totalGlobalMem >> 20);

	mexPrintf( "Shared memory per block: %d B\n", cudaDvcProp.sharedMemPerBlock );

	mexPrintf( "Total constant memory: %d B\n", cudaDvcProp.totalConstMem );

	mexPrintf( "Memory pitch: %d B\n", cudaDvcProp.memPitch );

	mexPrintf( "Registers per block: %d\n", cudaDvcProp.regsPerBlock );

	mexPrintf( "Warp size: %d\n", cudaDvcProp.warpSize );

	mexPrintf( "Maximum # of threads per block: %d\n", cudaDvcProp.maxThreadsPerBlock );

	mexPrintf( "Maximum thread dimension: (%d,%d,%d)\n", cudaDvcProp.maxThreadsDim[0], cudaDvcProp.maxThreadsDim[1], cudaDvcProp.maxThreadsDim[2] );

	mexPrintf( "Maximum grid dimension: (%d,%d,%d)\n", cudaDvcProp.maxGridSize[0], cudaDvcProp.maxGridSize[1], cudaDvcProp.maxGridSize[2] );

	mexPrintf( "Compute capability: %d.%d\n", cudaDvcProp.major, cudaDvcProp.minor );

	mexPrintf( "Clock rate: %d MHz\n", cudaDvcProp.clockRate/1000 );

	mexPrintf( "Multiprocessor count: %d\n", cudaDvcProp.multiProcessorCount );

	return;

}

It does not do anything fancy, but you access the CUDA interface and checks that you are using the correct GPU.

Also, I know this is not an answer to your specific question, but sometimes it is easier to do something new from scratch that fix the old code. For me at least.

Hope this helps

Cheers