Prev: GUI: Pushbutton to save an image in a directory
Next: Training of neural network using genetic algorithm
From: Kasper Marstal on 19 May 2010 12:40 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?
From: Kasper Marstal on 19 May 2010 19:05 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.
From: Ralph Schleicher on 19 May 2010 18:15 "Kasper Marstal" <lifesucksandthenyoudie(a)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
From: Kasper Marstal on 19 May 2010 20:20 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 ...
From: Ralph Schleicher on 20 May 2010 16:20
"Kasper Marstal" <lifesucksandthenyoudie(a)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 |