Unable to compile CUDA mex in Matlab R2010a 64bit CUDA

  • Follow


Hello guys and girls. I've looked through numerous topics on matlab cuda compilation problems but Im unable to find any sufficient info on this exact setup. That is, compiling CUDA extended mex c code files on Windows 7 64-bit, Matlab R2010a 64-bit. 

The nvmex plugin gives the following error:

>> nvmex
WARNING: $ARCH (UNKNOWN) not set correctly [win64] 
 
  C:\PROGRA~1\MATLAB\R2010A\BIN\NVMEX.PL:  
  Error: Using options file: 
         C:\Users\Kasper\AppData\Roaming\MathWorks\MATLAB\R2010a\mexopts.bat 
         You cannot use this file with the UNKNOWN architecture because it enables 
         a compiler for a different architecture. 
         Running mex -setup may resolve this problem. 
 
??? Error using ==> nvmex at 206
Unable to complete successfully.


Invoking "system(sprintf('nvcc -I"%s/extern/include" --cuda "mexfun.cu" --output-file "mexfun.cpp"', matlabroot));" gives the following error:

nvcc fatal   : Cannot find compiler 'cl.exe' in PATH 

Even though I've added "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin" where cl.exe is located to "Set Path..." under the files menu.

Do you know what I'm doing wrong? 
0
Reply Kasper 5/19/2010 4:40:24 PM

"Kasper Marstal" <lifesucksandthenyoudie@gmail.com> writes:

Hello Kasper,

> Hello guys and girls. I've looked through numerous topics on matlab
> cuda compilation problems but Im unable to find any sufficient info on
> this exact setup. That is, compiling CUDA extended mex c code files on
> Windows 7 64-bit, Matlab R2010a 64-bit. 
[...]
>  C:\PROGRA~1\MATLAB\R2010A\BIN\NVMEX.PL:  Error: Using options file:
> C:\Users\Kasper\AppData\Roaming\MathWorks\MATLAB\R2010a\mexopts.bat
> You cannot use this file with the UNKNOWN architecture because it
> enables a compiler for a different architecture. Running
> mex -setup may resolve this problem. 

Can you read error messages?

> Even though I've added "C:\Program Files (x86)\Microsoft Visual Studio
> 9.0\VC\bin" where cl.exe is located to "Set Path..." under the files
> menu.

This is the Matlab search path!  It has nothing to do with the program
search path utilized by the MEX script.

And programs installed in "C:\Program Files (x86)\..." are 32-bit
applications, not 64-bit.

> Do you know what I'm doing wrong? 

You have to use the Visual C++ x64 compiler.  Have you installed the x64
compiler and tools from the Windows SDK?  IIRC, the C++ x64 compiler is
installed in "C:\Program Files\Windows SDKs\Windows\v6.0\VC\bin\x64".
Have a look at your mexopts.bat and merge in something like this:

set SDK_DIR=C:\Program Files\Windows SDKs\Windows\v6.0
set PATH=%SDK_DIR%\VC\bin\x64;%SDK_DIR%\bin\x64;%PATH%
set LIB=%SDK_DIR%\VC\lib\x64;%SDK_DIR%\lib\x64;%LIB%
set INCLUDE=%SDK_DIR%\VC\include;%SDK_DIR%\include;%INCLUDE%

-- 
Ralph Schleicher  <http://ralph-schleicher.de>

Development * Consulting * Training
Mathematical Modeling and Simulation
Software Tools
0
Reply Ralph 5/19/2010 10:15:18 PM


Perhaps if I clarify my situation further it is easier for you to help me. I downloaded the following package from the file mathworks file exchange: http://www.mathworks.com/matlabcentral/fileexchange/27405-tutorials-on-creating-compiling-and-running-cuda-accelerated-programs-in-matlab. I ran setup_cuda_mex which generated cudamexopts.bat, cuda_nex.pl, cuda_mex.m and cuda_mex_helper.m correctly. However, when it tries to compile the provided "example.cu" I get the first error message in the post above.

"WARNING: $ARCH (UNKNOWN) not set correctly [win64] 
 
  C:\PROGRA~1\MATLAB\R2010A\BIN\CUDA_MEX.PL:  
  Error: Using options file: 
         C:\Users\Kasper\AppData\Roaming\MathWorks\MATLAB\R2010a\cudamexopts.bat 
         You cannot use this file with the UNKNOWN architecture because it enables 
         a compiler for a different architecture. 
         Running mex -setup may resolve this problem."

My cudamexopts.bat looks like this:

@echo off
rem MSVC90OPTS.BAT
rem
rem    Compile and link options used for building MEX-files
rem    using the Microsoft Visual C++ compiler version 9.0 SP1
rem
rem    $Revision: 1.1.6.6 $  $Date: 2009/05/18 19:49:43 $
rem    Copyright 2007-2009 The MathWorks, Inc.
rem
rem StorageVersion: 1.0
rem C++keyFileName: MSVC90OPTS.BAT
rem C++keyName: Microsoft Visual C++ 2008
rem C++keyManufacturer: Microsoft
rem C++keyVersion: 9.0
rem C++keyLanguage: C++
rem
rem ********************************************************************
rem General parameters
rem ********************************************************************

set MATLAB=%MATLAB%
set VSINSTALLDIR=
set VCINSTALLDIR=%VSINSTALLDIR%\VC
rem In this case, LINKERDIR is being used to specify the location of the SDK
set LINKERDIR=C:\Program Files\\Microsoft SDKs\Windows\v6.0A\
set PATH=%VCINSTALLDIR%\bin\amd64;%LINKERDIR%\bin\x64;%VCINSTALLDIR%\BIN;%VSINSTALLDIR%\Common7\Tools;%VSINSTALLDIR%\Common7\Tools\bin;%MATLAB_BIN%;%PATH%
set INCLUDE=%LINKERDIR%\include;%VCINSTALLDIR%\ATLMFC\INCLUDE;%VCINSTALLDIR%\INCLUDE;%VCINSTALLDIR%\VCPackages;%INCLUDE%;%CUDA_INC_PATH%;%NVSDKCUDA_ROOT%\common\inc
set LIB=%LINKERDIR%\LIB\x64;%VCINSTALLDIR%\LIB\amd64;%VCINSTALLDIR%\ATLMFC\LIB\amd64;%MATLAB%\extern\lib\win64;%LIB%;%CUDA_LIB_PATH%;%NVSDKCUDA_ROOT%\common\lib
set MW_TARGET_ARCH=win64

rem ********************************************************************
rem Compiler parameters
rem ********************************************************************
set COMPILER=nvcc
set COMPFLAGS=-c -Xcompiler "/c /Zp8 /GR /W3 /EHs /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE /nologo /MD"
set OPTIMFLAGS=-Xcompiler "/O2 /Oy- /DNDEBUG"
set DEBUGFLAGS=-Xcompiler "/Z7"
set NAME_OBJECT=-o ""

rem ********************************************************************
rem Linker parameters
rem ********************************************************************
set LIBLOC=%MATLAB%\extern\lib\win64\microsoft
set LINKER=link
set LINKFLAGS=/dll /export:%ENTRYPOINT% /LIBPATH:"%LIBLOC%" libmx.lib libmex.lib libmat.lib /MACHINE:X64 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /incremental:NO /implib:"%LIB_NAME%.x" /MAP:"%OUTDIR%%MEX_NAME%%MEX_EXT%.map"  cudart.lib
set LINKOPTIMFLAGS=
set LINKDEBUGFLAGS=/DEBUG /PDB:"%OUTDIR%%MEX_NAME%%MEX_EXT%.pdb"
set LINK_FILE=
set LINK_LIB=
set NAME_OUTPUT=/out:"%OUTDIR%%MEX_NAME%%MEX_EXT%"
set RSP_FILE_INDICATOR=@

rem ********************************************************************
rem Resource compiler parameters
rem ********************************************************************
set RC_COMPILER=rc /fo "%OUTDIR%mexversion.res"
set RC_LINKER=

set POSTLINK_CMDS=del "%LIB_NAME%.x" "%LIB_NAME%.exp"
set POSTLINK_CMDS1=mt -outputresource:"%OUTDIR%%MEX_NAME%%MEX_EXT%;2" -manifest "%OUTDIR%%MEX_NAME%%MEX_EXT%.manifest"
set POSTLINK_CMDS2=del "%OUTDIR%%MEX_NAME%%MEX_EXT%.manifest"
set POSTLINK_CMDS3=del "%OUTDIR%%MEX_NAME%%MEX_EXT%.map"

As mentioned before, I'm running Windows 7 64-bit, Matlab R2010a 64-bit and Visual Studio 2008 Professional.
0
Reply Kasper 5/19/2010 11:05:21 PM

Thank you for your reply Ralph!

> You have to use the Visual C++ x64 compiler.  Have you installed the x64
> compiler and tools from the Windows SDK?

Yes. I've installed VS2008 Professional. 

> IIRC, the C++ x64 compiler is
> installed in "C:\Program Files\Windows SDKs\Windows\v6.0\VC\bin\x64".

In my case it is installed in "C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\x64".

> Have a look at your mexopts.bat and merge in something like this:
> 
> set SDK_DIR=C:\Program Files\Windows SDKs\Windows\v6.0
> set PATH=%SDK_DIR%\VC\bin\x64;%SDK_DIR%\bin\x64;%PATH%
> set LIB=%SDK_DIR%\VC\lib\x64;%SDK_DIR%\lib\x64;%LIB%
> set INCLUDE=%SDK_DIR%\VC\include;%SDK_DIR%\include;%INCLUDE%

I tried to put in

set SDK_DIR=C:\Program Files\Microsoft SDKs\Windows\v6.0A
set PATH=%SDK_DIR%\bin\x64;%SDK_DIR%\bin\x64;%PATH%
set LIB=%SDK_DIR%\lib\x64;%SDK_DIR%\lib\x64;%LIB%
set INCLUDE=%SDK_DIR%include;%SDK_DIR%\include;%INCLUDE%

(there is no VC directory in my case) at the end of the file in mexcudaopts.bat file but I get the same error message. It looks as if some default "UNKNOWN" parameter just need to be set dont you think? Tried "cuda_mex myfun.cu -win64" but it gave the same result. I think you are right though, it seems most probable that cudamexopts.bat just need a bit of tweaking ... 
0
Reply Kasper 5/20/2010 12:20:22 AM

"Kasper Marstal" <lifesucksandthenyoudie@gmail.com> writes:

> I think you are right though, it seems most probable that
> cudamexopts.bat just need a bit of tweaking ...

Unfortunately, this may last hours until you figure out what was wrong.
But you feel much better after you traced it down.  Good luck.

-- 
Ralph Schleicher  <http://ralph-schleicher.de>

Development * Consulting * Training
Mathematical Modeling and Simulation
Software Tools
0
Reply Ralph 5/20/2010 8:20:23 PM

Ralph Schleicher <rs+usenet@ralph-schleicher.de> wrote in message <87ocgaba0o.fsf@bravo.mueller-schleicher.i>...
> "Kasper Marstal" <lifesucksandthenyoudie@gmail.com> writes:
> 
> > I think you are right though, it seems most probable that
> > cudamexopts.bat just need a bit of tweaking ...
> 
> Unfortunately, this may last hours until you figure out what was wrong.
> But you feel much better after you traced it down.  Good luck.
> 
> -- 
> Ralph Schleicher  <http://ralph-schleicher.de>
> 
> Development * Consulting * Training
> Mathematical Modeling and Simulation
> Software Tools

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

Do you resolvee this problem? I did as you wrote, now I have this error:
">> mex fft2_cuda_sp_dp.c -IC:\CUDA\include -LC:\CUDA\lib -lcudart -lcufft
   
  Error: An options file for MEX was found, but the value for 'COMPILER' 
         was not set.  This could mean that the value is not specified 
         within the options file, or it could mean that there is a  
         syntax error within the file. 
 
 
  C:\PROGRA~1\MATLAB\R2010A\BIN\MEX.PL: Error: Options file is invalid. 
 
??? Error using ==> mex at 222
Unable to complete successfully."

I have
win 7 ultimate x64
Matlab 2010a x64,
VS 2005 Prof x64,
Installed: toolkit 3.1,
SDK v6.0A,
and nev card driver.

I tried everything, and I can't compile mex
Please help.
0
Reply Pawel 7/15/2010 7:35:24 AM

"Kasper Marstal" wrote:
> Hello guys and girls. I've looked through numerous topics on matlab cuda compilation problems but Im unable to find any sufficient info on this exact setup. That is, compiling CUDA extended mex c code files on Windows 7 64-bit, Matlab R2010a 64-bit. 

I'm also suffering from this problem. I'm using:
MATLAB R2010b 64-bit
MSVC 8.0 (2005) with 64-bit compiler add-on
on
Windows 7 64-bit

The mex setup for normal c and c++ files works correctly, so I have faith in the current settings in my mexopts.bat file. However, when I try to compile cuda I get two different problems, depending on whether I've installed the 32-bit or 64-bit version of the CUDA toolkit. Note that I'm compiling the .cu files to .cpp files using nvcc as a first step, as described here:
http://www.mathworks.com/matlabcentral/newsreader/view_thread/261866#700375
(This approach also works on Windows)

With the 64-bit toolkit:

Command:
"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v3.2\bin\nvcc.exe" -D_MATLAB_ -I"C:\Program Files\MATLAB\R2010b\extern\include" -I"C:\ProgramData\NVIDIA Corporation\NVIDIA GPU Computing SDK 3.2\C\common\inc" -arch sm_11 --ptxas-options=-v -O3 -Iprivate/depth_sensor/ --cuda "private/depth_sensor/pmls.cu" --output-file "C:\Users\OWOODF~1\AppData\Local\ Temp\tpc44f628a_a571_4747_80c2_df38d2b8c177.cpp"
pmls.cu

Error:
c:\program files\nvidia gpu computing toolkit\cuda\v3.2\include\host_config.h(96) : fatal error C1083: Cannot open include file: 'crtdefs.h': No such file or directory

So the error happens at the .cu compilation stage.

With the 32-bit toolkit:

Command:
mex -D_MATLAB_ -O -I"C:\Users\owoodford\Documents\Projects\code_base\git-repository\internal\geometry" -I"C:\Program Files (x86)\NVIDIA GPU Computing Toolkit\CUDA\v3.2\include" -I"C:\ProgramData\NVIDIA Corporation\NVIDIA GPU Computing SDK 3.2\C\common\inc" -L"C:\Program Files (x86)\NVIDIA GPU Computing Toolkit\CUDA\v3.2\lib/Win64" -L"C:\ProgramData\NVIDIA Corporation\NVIDIA GPU Computing SDK 3.2\C\common\lib" -lcudart -Iprivate/depth_sensor/ "depth_sensor.cpp" "C:\Users\OWOODF~1\AppData\Local\Temp\tpad4c36d1_de71_4150_9d09_637d472d89cb.cpp" "C:\Users\OWOODF~1\AppData\Local\Temp\tp9ca7ea75_d10d_4031_bb30_6bea7dce84ea.cpp" "C:\Users\OWOODF~1\AppData\Local\Temp\tpb1bb5950_b381_478d_b0cd_cbb4055760ce.cpp" "private/depth_sensor/matrix3.cpp"    -output "depth_sensor"
tpad4c36d1_de71_4150_9d09_637d472d89cb.cpp

Error:
C:\Program Files (x86)\Microsoft Visual Studio 8\VC\INCLUDE\crtdefs.h(482) : error C2371: 'size_t' : redefinition; different basic types 
        C:\Users\OWOODF~1\AppData\Local\Temp\tpad4c36d1_de71_4150_9d09_637d472d89cb.cpp : see declaration of 'size_t' 
C:\Program Files (x86)\Microsoft Visual Studio 8\VC\INCLUDE\math.h(389) : error C2169: 'acosf' : intrinsic function, cannot be defined 
C:\Program Files (x86)\Microsoft Visual Studio 8\VC\INCLUDE\math.h(391) : error C2169: 'asinf' : intrinsic function, cannot be defined 
C:\Program Files (x86)\Microsoft Visual Studio 8\VC\INCLUDE\math.h(393) : error C2169: 'atanf' : intrinsic function, cannot be defined 
C:\Program Files (x86)\Microsoft Visual Studio 8\VC\INCLUDE\math.h(395) : error C2169: 'atan2f' : intrinsic function, cannot be defined 
C:\Program Files (x86)\Microsoft Visual Studio 8\VC\INCLUDE\math.h(397) : error C2169: 'ceilf' : intrinsic function, cannot be defined 
C:\Program Files (x86)\Microsoft Visual Studio 8\VC\INCLUDE\math.h(399) : error C2169: 'cosf' : intrinsic function, cannot be defined 
C:\Program Files (x86)\Microsoft Visual Studio 8\VC\INCLUDE\math.h(401) : error C2169: 'coshf' : intrinsic function, cannot be defined 
C:\Program Files (x86)\Microsoft Visual Studio 8\VC\INCLUDE\math.h(403) : error C2169: 'expf' : intrinsic function, cannot be defined 
C:\Program Files (x86)\Microsoft Visual Studio 8\VC\INCLUDE\math.h(405) : error C2169: 'floorf' : intrinsic function, cannot be defined 
C:\Program Files (x86)\Microsoft Visual Studio 8\VC\INCLUDE\math.h(407) : error C2169: 'fmodf' : intrinsic function, cannot be defined 
C:\Program Files (x86)\Microsoft Visual Studio 8\VC\INCLUDE\math.h(409) : error C2169: 'logf' : intrinsic function, cannot be defined 
C:\Program Files (x86)\Microsoft Visual Studio 8\VC\INCLUDE\math.h(411) : error C2169: 'log10f' : intrinsic function, cannot be defined 
C:\Program Files (x86)\Microsoft Visual Studio 8\VC\INCLUDE\math.h(417) : error C2169: 'powf' : intrinsic function, cannot be defined 
C:\Program Files (x86)\Microsoft Visual Studio 8\VC\INCLUDE\math.h(419) : error C2169: 'sinf' : intrinsic function, cannot be defined 
C:\Program Files (x86)\Microsoft Visual Studio 8\VC\INCLUDE\math.h(421) : error C2169: 'sinhf' : intrinsic function, cannot be defined 
C:\Program Files (x86)\Microsoft Visual Studio 8\VC\INCLUDE\math.h(423) : error C2169: 'sqrtf' : intrinsic function, cannot be defined 
C:\Program Files (x86)\Microsoft Visual Studio 8\VC\INCLUDE\math.h(425) : error C2169: 'tanf' : intrinsic function, cannot be defined 
C:\Program Files (x86)\Microsoft Visual Studio 8\VC\INCLUDE\math.h(427) : error C2169: 'tanhf' : intrinsic function, cannot be defined 
C:\Program Files (x86)\Microsoft Visual Studio 8\VC\INCLUDE\math.h(494) : error C3861: 'acosf': identifier not found 
C:\Program Files (x86)\Microsoft Visual Studio 8\VC\INCLUDE\math.h(496) : error C3861: 'asinf': identifier not found 
C:\Program Files (x86)\Microsoft Visual Studio 8\VC\INCLUDE\math.h(498) : error C3861: 'atanf': identifier not found 
C:\Program Files (x86)\Microsoft Visual Studio 8\VC\INCLUDE\math.h(500) : error C3861: 'atan2f': identifier not found 
C:\Program Files (x86)\Microsoft Visual Studio 8\VC\INCLUDE\math.h(502) : error C3861: 'ceilf': identifier not found 
C:\Program Files (x86)\Microsoft Visual Studio 8\VC\INCLUDE\math.h(504) : error C3861: 'cosf': identifier not found 
C:\Program Files (x86)\Microsoft Visual Studio 8\VC\INCLUDE\math.h(506) : error C3861: 'coshf': identifier not found 
C:\Program Files (x86)\Microsoft Visual Studio 8\VC\INCLUDE\math.h(508) : error C3861: 'expf': identifier not found 
C:\Program Files (x86)\Microsoft Visual Studio 8\VC\INCLUDE\math.h(512) : error C3861: 'floorf': identifier not found 
C:\Program Files (x86)\Microsoft Visual Studio 8\VC\INCLUDE\math.h(514) : error C3861: 'fmodf': identifier not found 
C:\Program Files (x86)\Microsoft Visual Studio 8\VC\INCLUDE\math.h(520) : error C3861: 'logf': identifier not found 
C:\Program Files (x86)\Microsoft Visual Studio 8\VC\INCLUDE\math.h(522) : error C3861: 'log10f': identifier not found 
C:\Program Files (x86)\Microsoft Visual Studio 8\VC\INCLUDE\math.h(526) : error C3861: 'powf': identifier not found 
C:\Program Files (x86)\Microsoft Visual Studio 8\VC\INCLUDE\math.h(530) : error C3861: 'sinf': identifier not found 
C:\Program Files (x86)\Microsoft Visual Studio 8\VC\INCLUDE\math.h(532) : error C3861: 'sinhf': identifier not found 
C:\Program Files (x86)\Microsoft Visual Studio 8\VC\INCLUDE\math.h(534) : error C3861: 'sqrtf': identifier not found 
C:\Program Files (x86)\Microsoft Visual Studio 8\VC\INCLUDE\math.h(536) : error C3861: 'tanf': identifier not found 
C:\Program Files (x86)\Microsoft Visual Studio 8\VC\INCLUDE\math.h(538) : error C3861: 'tanhf': identifier not found 
C:\Program Files (x86)\Microsoft Visual Studio 8\VC\INCLUDE\xutility(3119) : warning C4244: 'initializing' : conversion from '__int64' to 'ptrdiff_t', possible loss of data 
C:\Program Files (x86)\Microsoft Visual Studio 8\VC\INCLUDE\xutility(3120) : warning C4244: 'initializing' : conversion from '__int64' to 'ptrdiff_t', possible loss of data 
C:/ProgramData/NVIDIA Corporation/NVIDIA GPU Computing SDK 3.2/C/common/inc\cutil_math.h(1164) : error C3861: 'sqrtf': identifier not found 
C:/ProgramData/NVIDIA Corporation/NVIDIA GPU Computing SDK 3.2/C/common/inc\cutil_math.h(1168) : error C3861: 'sqrtf': identifier not found 
C:/ProgramData/NVIDIA Corporation/NVIDIA GPU Computing SDK 3.2/C/common/inc\cutil_math.h(1172) : error C3861: 'sqrtf': identifier not found 
C:/ProgramData/NVIDIA Corporation/NVIDIA GPU Computing SDK 3.2/C/common/inc\cutil_math.h(1201) : error C2264: 'floorf' : error in function definition or declaration; function not called 
C:/ProgramData/NVIDIA Corporation/NVIDIA GPU Computing SDK 3.2/C/common/inc\cutil_math.h(1201) : error C2264: 'floorf' : error in function definition or declaration; function not called 
C:/ProgramData/NVIDIA Corporation/NVIDIA GPU Computing SDK 3.2/C/common/inc\cutil_math.h(1205) : error C2264: 'floorf' : error in function definition or declaration; function not called 
C:/ProgramData/NVIDIA Corporation/NVIDIA GPU Computing SDK 3.2/C/common/inc\cutil_math.h(1205) : error C2264: 'floorf' : error in function definition or declaration; function not called 
C:/ProgramData/NVIDIA Corporation/NVIDIA GPU Computing SDK 3.2/C/common/inc\cutil_math.h(1205) : error C2264: 'floorf' : error in function definition or declaration; function not called 
C:/ProgramData/NVIDIA Corporation/NVIDIA GPU Computing SDK 3.2/C/common/inc\cutil_math.h(1209) : error C2264: 'floorf' : error in function definition or declaration; function not called 
C:/ProgramData/NVIDIA Corporation/NVIDIA GPU Computing SDK 3.2/C/common/inc\cutil_math.h(1209) : error C2264: 'floorf' : error in function definition or declaration; function not called 
C:/ProgramData/NVIDIA Corporation/NVIDIA GPU Computing SDK 3.2/C/common/inc\cutil_math.h(1209) : error C2264: 'floorf' : error in function definition or declaration; function not called 
C:/ProgramData/NVIDIA Corporation/NVIDIA GPU Computing SDK 3.2/C/common/inc\cutil_math.h(1209) : error C2264: 'floorf' : error in function definition or declaration; function not called 
C:/ProgramData/NVIDIA Corporation/NVIDIA GPU Computing SDK 3.2/C/common/inc\cutil_math.h(1218) : error C2264: 'floorf' : error in function definition or declaration; function not called 
C:/ProgramData/NVIDIA Corporation/NVIDIA GPU Computing SDK 3.2/C/common/inc\cutil_math.h(1239) : error C2264: 'fmodf' : error in function definition or declaration; function not called 
C:/ProgramData/NVIDIA Corporation/NVIDIA GPU Computing SDK 3.2/C/common/inc\cutil_math.h(1239) : error C2264: 'fmodf' : error in function definition or declaration; function not called 
C:/ProgramData/NVIDIA Corporation/NVIDIA GPU Computing SDK 3.2/C/common/inc\cutil_math.h(1243) : error C2264: 'fmodf' : error in function definition or declaration; function not called 
C:/ProgramData/NVIDIA Corporation/NVIDIA GPU Computing SDK 3.2/C/common/inc\cutil_math.h(1243) : error C2264: 'fmodf' : error in function definition or declaration; function not called 
C:/ProgramData/NVIDIA Corporation/NVIDIA GPU Computing SDK 3.2/C/common/inc\cutil_math.h(1243) : error C2264: 'fmodf' : error in function definition or declaration; function not called 
C:/ProgramData/NVIDIA Corporation/NVIDIA GPU Computing SDK 3.2/C/common/inc\cutil_math.h(1247) : error C2264: 'fmodf' : error in function definition or declaration; function not called 
C:/ProgramData/NVIDIA Corporation/NVIDIA GPU Computing SDK 3.2/C/common/inc\cutil_math.h(1247) : error C2264: 'fmodf' : error in function definition or declaration; function not called 
C:/ProgramData/NVIDIA Corporation/NVIDIA GPU Computing SDK 3.2/C/common/inc\cutil_math.h(1247) : error C2264: 'fmodf' : error in function definition or declaration; function not called 
C:/ProgramData/NVIDIA Corporation/NVIDIA GPU Computing SDK 3.2/C/common/inc\cutil_math.h(1247) : error C2264: 'fmodf' : error in function definition or declaration; function not called 
private/depth_sensor/pmls.cu(83) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data 
 
  C:\PROGRA~1\MATLAB\R2010B\BIN\MEX.PL: Error: Compile of 'C:\Users\OWOODF~1\AppData\Local\Temp\tpad4c36d1_de71_4150_9d09_637d472d89cb.cpp' failed.

So the error happens at the .cpp compilation stage.

Any help on this would be much appreciated.

Thanks,
Oliver
0
Reply Oliver 1/11/2011 10:58:05 AM

"Oliver Woodford" wrote:
> I'm also suffering from this problem. I'm using:
> MATLAB R2010b 64-bit
> MSVC 8.0 (2005) with 64-bit compiler add-on
> on
> Windows 7 64-bit
> 
> The mex setup for normal c and c++ files works correctly, so I have faith in the current settings in my mexopts.bat file. However, when I try to compile cuda I get two different problems, depending on whether I've installed the 32-bit or 64-bit version of the CUDA toolkit. Note that I'm compiling the .cu files to .cpp files using nvcc as a first step, as described here:
> http://www.mathworks.com/matlabcentral/newsreader/view_thread/261866#700375
> (This approach also works on Windows)

Fixed. I use the 64-bit version of the toolkit, and use this command to compile the .cu files to .cpp:
"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v3.2\bin\nvcc.exe" -D_MATLAB_ -I"C:\Program Files\MATLAB\R2010b\extern\include" -I"C:\ProgramData\NVIDIA Corporation\NVIDIA GPU Computing SDK 3.2\C\common\inc" -m64 -arch sm_12 --ptxas-options=-v -O3 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 8\VC\bin" -I"C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include" -Iprivate/depth_sensor/ --cuda "private/depth_sensor/pmls.cu" --output-file "C:\Users\OWOODF~1\AppData\Local\Temp\tp0311ad12_7e6b_43e4_bb41_a2004044258a.cpp" 

Then I just compile as usual using mex.
0
Reply Oliver 1/17/2011 11:58:04 AM

"Kasper Marstal" wrote in message <ht149o$ok2$1@fred.mathworks.com>...
> Hello guys and girls. I've looked through numerous topics on matlab cuda compilation problems but Im unable to find any sufficient info on this exact setup. That is, compiling CUDA extended mex c code files on Windows 7 64-bit, Matlab R2010a 64-bit. 
> 
> The nvmex plugin gives the following error:
> 
> >> nvmex
> WARNING: $ARCH (UNKNOWN) not set correctly [win64] 
>  
>   C:\PROGRA~1\MATLAB\R2010A\BIN\NVMEX.PL:  
>   Error: Using options file: 
>          C:\Users\Kasper\AppData\Roaming\MathWorks\MATLAB\R2010a\mexopts.bat 
>          You cannot use this file with the UNKNOWN architecture because it enables 
>          a compiler for a different architecture. 
>          Running mex -setup may resolve this problem. 
>  
> ??? Error using ==> nvmex at 206
> Unable to complete successfully.
> 
> 
> Invoking "system(sprintf('nvcc -I"%s/extern/include" --cuda "mexfun.cu" --output-file "mexfun.cpp"', matlabroot));" gives the following error:
> 
> nvcc fatal   : Cannot find compiler 'cl.exe' in PATH 
> 
> Even though I've added "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin" where cl.exe is located to "Set Path..." under the files menu.
> 
> Do you know what I'm doing wrong? 

I am getting this error as well. So far, I have tracked it down to a problem with nvmex.pl.

What is happening in nvmex.pl is that it checks the environment variable FOO to see if it is AMD64 (which is Windows 64-bit, except for Itaniums). If it is, then it looks to see if you have the win64 matlab.exe, and if you do, it sets the variable $ARCH to 'win64'. If not, it checks to see if you have the win32 matalb.exe, and if you do, it sets $ARCH to 'win32'. If you have neither, it sets $ARCH to 'UNKNOWN', and it is this else case that it is falling into.

Why? Well, to look for the matlab.exe files, it constructs their pathname with:

mexCatfile($main::matlabroot, "bin", "win64", "matlab.exe")

This is similar to MATLAB's 'fullfile' function. $main::matlabroot returns the path to nvmex.pl, and this function looks like it's supposed to chop off the "bin\nvmex.pl" and append the other strings separated by slashes. However, for me, this gives:

C:\PROGRA~1\MATLAB\R2012a\bin\nvmex.pl\bin\win64\matlab.exe

Which is clearly wrong, and leads to the $ARCH='UNKNOWN' branch since it can't find that file or the 32 bit one.

The error is on line 157 of nvmex.pl where it sets the value of $main::matlabroot :

($main::matlabroot = $main::cmd_name) =~ s%\\bin\\mex.pl$%%;

Well, the problem is that this script is named 'nvmex.pl' and so this regex to chop off the end of this pathanme isn't working. Whomever wrote nvmex.pl copied it from mex.pl and failed to change this, and all the expressions in the script using $main::matlabroot will not work properly.

So, change it to:

($main::matlabroot = $main::cmd_name) =~ s%\\bin\\nvmex.pl$%%;

You may need to change permissions on nvmex.pl to save it.

Now I'm on to the next error of "unrecognized source file type". Sheesh.
0
Reply rgrayREMOVE.THIS (1) 6/22/2012 11:00:07 PM

8 Replies
576 Views

(page loaded in 0.14 seconds)

Similiar Articles:













7/21/2012 7:24:10 PM


Reply: