MouseLand / Kilosort

Fast spike sorting with drift correction
https://kilosort.readthedocs.io/en/latest/
GNU General Public License v3.0
488 stars 247 forks source link

Can't compile using mexcuda #87

Closed hpay closed 5 years ago

hpay commented 5 years ago

Hi!

I'm excited to start using Kilosort but I can't get the mex files compiled during installation. I'm using Windows 10, Matlab 2018a, CUDA 9.0.176, and Visual Studio Community 2013 with Update 5 (and I've used mex -setup c++ to set the compiler to Microsoft Visual C++ 2013). The GPU is NVIDIA quadro M4000. I get the following error when I try to run mexGPUall.m (more detailed output below):


Error using mex
nvcc fatal   : Could not set up the environment for Microsoft Visual Studio using
'C:/Program Files (x86)/Microsoft Visual Studio
12.0/VC/Bin/amd64/../../../VC/bin/amd64/vcvars64.bat'

Error in mexcuda (line 157)
    [varargout{1:nargout}] = mex(mexArguments{:});
Error in mexGPUall (line 5)
    mexcuda -largeArrayDims mexThSpkPC.cu 

The file vcvars64.bat does in fact exist where specified. I've additionally tried: using the compilers from VS2015 and VS2017; uninstalling all VS versions and uninstalling CUDA, then starting over with VS2013 followed by CUDA 9.0; and most recently following the instructions here to do a clean install of CUDA. No error messages during any installation steps. Any idea what is going on?

Verbose output from the mexcuda command:

>> mexcuda -v -largeArrayDims mexThSpkPC.cu
Trying MEX options 'C:\Program Files\MATLAB\R2018a\toolbox\distcomp\gpu\extern\src\mex\win64\nvcc_msvcpp2013.xml'...SUCCESS
mex -largeArrayDims -f C:\Program Files\MATLAB\R2018a\toolbox\distcomp\gpu\extern\src\mex\win64\nvcc_msvcpp2013.xml NVCC_FLAGS="" -v -largeArrayDims mexThSpkPC.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 ...Yes ('C:\Program Files (x86)\Microsoft Visual Studio 12.0\').
... Looking for file 'C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\amd64\cl.exe' ...Yes.
... Looking for folder 'C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC' ...Yes.
... Looking for registry setting 'HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v8.1' InstallationFolder ...No.
... Looking for registry setting 'HKCU\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v8.1' InstallationFolder ...No.
... Looking for registry setting 'HKLM\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v8.1' InstallationFolder ...Yes ('C:\Program Files (x86)\Windows Kits\8.1\').
... 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 ...Yes ('C:\Program Files (x86)\Microsoft Visual Studio 12.0\').
... Looking for registry setting 'HKLM\SOFTWARE\Microsoft\VisualStudio\SxS\VC7' 12.0 ...No.
... Looking for registry setting 'HKCU\SOFTWARE\Microsoft\VisualStudio\SxS\VC7' 12.0 ...No.
... Looking for registry setting 'HKLM\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\SxS\VC7' 12.0 ...Yes ('C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\').
... Looking for environment variable 'VS120COMNTOOLS' ...Yes ('C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\').
... Looking for file 'C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe' ...Yes.
... 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 ...Yes ('C:\Program Files (x86)\Microsoft Visual Studio 12.0\').
... Looking for file 'C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat' ...Yes.
... Looking for folder 'C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC' ...Yes.
... Looking for environment variable 'MW_NVCC_PATH' ...No.
... Looking for environment variable 'CUDA_LIB_PATH' ...No.
... Looking for environment variable 'CUDA_PATH' ...Yes ('C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0').
... Looking for file 'C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\lib\x64\cudart.lib' ...Yes.
... Looking for folder 'C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\lib\x64' ...Yes.
... Looking for environment variable 'MW_NVCC_PATH' ...No.
... Looking for environment variable 'CUDA_BIN_PATH' ...No.
... Looking for environment variable 'CUDA_PATH' ...Yes ('C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0').
... Looking for file 'C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\bin\nvcc.exe' ...Yes.
... Executing command 'C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\bin\nvcc --version | findstr /c:"release 9.0" > NUL && echo C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\bin' ...No.
... Looking for environment variable 'MW_NVCC_PATH' ...No.
... Looking for environment variable 'CUDA_BIN_PATH' ...No.
... Looking for environment variable 'CUDA_PATH' ...Yes ('C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0').
... Looking for file 'C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\bin\nvcc.exe' ...Yes.
... Executing command '"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\bin\nvcc" --version | findstr /c:"release 9.0" > NUL && echo C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\bin' ...Yes ('C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\bin').
Found installed compiler 'NVIDIA CUDA Compiler'.
Set PATH = \C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\bin;C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\Bin\amd64;C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\Bin\VCPackages;C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\..\Common7\IDE;C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\..\Common7\Tools;C:\Program Files (x86)\Windows Kits\8.1\\Bin\x64;C:\Program Files (x86)\Windows Kits\8.1\\Bin\x86;;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\libnvvp;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Common Files\Acronis\FileProtector\;C:\Program Files (x86)\Common Files\Acronis\FileProtector64\;C:\Program Files\MATLAB\R2018a\runtime\win64;C:\Program Files\MATLAB\R2018a\bin;C:\Program Files (x86)\gEDA\gEDA\bin;C:\Program Files (x86)\gEDA\UnxUtils\usr\local\wbin;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64;C:\Program Files\Git\cmd;C:\Program Files\dotnet\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\;C:\Users\Hannah Payne\AppData\Local\Microsoft\WindowsApps;C:\Program Files\MATLAB\R2018a\bin\win64;C:\Users\Hannah Payne\AppData\Local\Programs\Python\Python37-32;C:\nrn62\bin;C:\Users\Hannah Payne\AppData\Local\GitHubDesktop\bin
Set INCLUDE = C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE;C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\ATLMFC\INCLUDE;C:\Program Files (x86)\Windows Kits\8.1\\include\shared;C:\Program Files (x86)\Windows Kits\8.1\\include\um;C:\Program Files (x86)\Windows Kits\8.1\\include\winrt;C:\Program Files\MATLAB\R2018a\extern\include;C:\Program Files\MATLAB\R2018a\toolbox\distcomp\gpu\extern\include;C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE;C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\ATLMFC\INCLUDE;C:\Program Files (x86)\Windows Kits\8.1\\include\shared;C:\Program Files (x86)\Windows Kits\8.1\\include\um;C:\Program Files (x86)\Windows Kits\8.1\\include\winrt;C:\Program Files\MATLAB\R2018a\extern\include;C:\Program Files\MATLAB\R2018a\toolbox\distcomp\gpu\extern\include;
Set LIB = C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\Lib\amd64;C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\ATLMFC\Lib\amd64;C:\Program Files (x86)\Windows Kits\8.1\\lib\winv6.3\um\x64;C:\Program Files\MATLAB\R2018a\lib\win64;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\lib\x64;C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\Lib\amd64;C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\ATLMFC\Lib\amd64;C:\Program Files (x86)\Windows Kits\8.1\\lib\winv6.3\um\x64;C:\Program Files\MATLAB\R2018a\lib\win64;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\lib\x64;
Set LIBPATH = C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\Lib\amd64;C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\ATLMFC\Lib\amd64;C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\Lib\amd64;C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\ATLMFC\Lib\amd64;
Options file details
-------------------------------------------------------------------
    Compiler location: $NVCC
    Options file: C:\Program Files\MATLAB\R2018a\toolbox\distcomp\gpu\extern\src\mex\win64\nvcc_msvcpp2013.xml
    CMDLINE200 : link /nologo /manifest  /DLL  /EXPORT:mexFunction /EXPORT:mexfilerequiredapiversion "C:\Users\Hannah Payne\AppData\Local\Temp\mex_4291783878875_13956\mexThSpkPC.obj" "C:\Users\Hannah Payne\AppData\Local\Temp\mex_4291783878875_13956\c_mexapi_version.obj"  /LIBPATH:"C:\Program Files\MATLAB\R2018a\extern\lib\win64\microsoft" libmx.lib libmex.lib libmat.lib gpu.lib cudart.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib libMatlabDataArray.lib libMatlabEngine.lib /out:mexThSpkPC.mexw64
    CMDLINE250 : mt -outputresource:mexThSpkPC.mexw64;2 -manifest "mexThSpkPC.mexw64.manifest"
    CMDLINE300 : del "mexThSpkPC.exp" "mexThSpkPC.lib" "mexThSpkPC.mexw64.manifest" "mexThSpkPC.ilk"
    COMPILER : nvcc
    COMPFLAGS : --compiler-options=/Zp8,/GR,/W3,/EHs,/nologo,/MD -gencode=arch=compute_30,code=sm_30 -gencode=arch=compute_50,code=sm_50 -gencode=arch=compute_60,code=sm_60 -gencode=arch=compute_70,code=\"sm_70,compute_70\" 
    ARCHFLAGS : -gencode=arch=compute_30,code=sm_30 -gencode=arch=compute_50,code=sm_50 -gencode=arch=compute_60,code=sm_60 -gencode=arch=compute_70,code=\"sm_70,compute_70\" 
    COMPDEFINES : --compiler-options=/DMX_COMPAT_64  --compiler-options=/DMATLAB_DEFAULT_RELEASE=R2017b  --compiler-options=/DUSE_MEX_CMD   --compiler-options=/D_CRT_SECURE_NO_DEPRECATE,/D_SCL_SECURE_NO_DEPRECATE,/D_SECURE_SCL=0,/DMATLAB_MEX_FILE
    MATLABMEX : /DMATLAB_MEX_FILE
    OPTIMFLAGS : --compiler-options=/O2,/Oy-,/DNDEBUG
    INCLUDE : -I"C:\Program Files\MATLAB\R2018a\extern\include" -I"C:\Program Files\MATLAB\R2018a\simulink\include"
    DEBUGFLAGS : --compiler-options=/Z7
    LINKER : link
    LINKFLAGS : /nologo /manifest 
    LINKTYPE : /DLL
    LINKEXPORT : /EXPORT:mexFunction
    LINKEXPORTVER : /EXPORT:mexFunction /EXPORT:mexfilerequiredapiversion
    LINKLIBS : /LIBPATH:"C:\Program Files\MATLAB\R2018a\extern\lib\win64\microsoft" libmx.lib libmex.lib libmat.lib gpu.lib cudart.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib libMatlabDataArray.lib libMatlabEngine.lib
    LINKDEBUGFLAGS : /debug /PDB:"mexThSpkPC.mexw64.pdb"
    LINKOPTIMFLAGS : 
    OBJEXT : .obj
    LDEXT : .mexw64
    SETENV : set COMPILER=nvcc
                set COMPFLAGS=/c --compiler-options=/Zp8,/GR,/W3,/EHs,/nologo,/MD -gencode=arch=compute_30,code=sm_30 -gencode=arch=compute_50,code=sm_50 -gencode=arch=compute_60,code=sm_60 -gencode=arch=compute_70,code=\"sm_70,compute_70\"  --compiler-options=/DMX_COMPAT_64  --compiler-options=/DMATLAB_DEFAULT_RELEASE=R2017b  --compiler-options=/DUSE_MEX_CMD   --compiler-options=/D_CRT_SECURE_NO_DEPRECATE,/D_SCL_SECURE_NO_DEPRECATE,/D_SECURE_SCL=0,/DMATLAB_MEX_FILE /DMATLAB_MEX_FILE
                set OPTIMFLAGS=--compiler-options=/O2,/Oy-,/DNDEBUG
                set DEBUGFLAGS=--compiler-options=/Z7
                set LINKER=link
                set LINKFLAGS=/nologo /manifest  /export:%ENTRYPOINT% /DLL /LIBPATH:"C:\Program Files\MATLAB\R2018a\extern\lib\win64\microsoft" libmx.lib libmex.lib libmat.lib gpu.lib cudart.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib libMatlabDataArray.lib libMatlabEngine.lib /EXPORT:mexFunction
                set LINKDEBUGFLAGS=/debug /PDB:"%OUTDIR%%MEX_NAME%.mexw64.pdb"
                set NAME_OUTPUT=/out:"%OUTDIR%%MEX_NAME%%MEX_EXT%"
    VCROOT : C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC
    SDKROOT : C:\Program Files (x86)\Windows Kits\8.1\
    VSINSTALLDIR : C:\Program Files (x86)\Microsoft Visual Studio 12.0\
    VCINSTALLDIR : C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\
    PROF_ENV : C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe
    VCVARSALLDIR : C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC
    CUDA_LIB_PATH : C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\lib\x64
    CUDA_BIN_PATH : C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\bin
    MATLABROOT : C:\Program Files\MATLAB\R2018a
    ARCH : win64
    SRC : "D:\hannah\Dropbox\alab\code\Kilosort2\CUDA\mexThSpkPC.cu";"C:\Program Files\MATLAB\R2018a\extern\version\c_mexapi_version.c"
    OBJ : "C:\Users\Hannah Payne\AppData\Local\Temp\mex_4291783878875_13956\mexThSpkPC.obj";"C:\Users\Hannah Payne\AppData\Local\Temp\mex_4291783878875_13956\c_mexapi_version.obj"
    OBJS : "C:\Users\Hannah Payne\AppData\Local\Temp\mex_4291783878875_13956\mexThSpkPC.obj" "C:\Users\Hannah Payne\AppData\Local\Temp\mex_4291783878875_13956\c_mexapi_version.obj" 
    SRCROOT : D:\hannah\Dropbox\alab\code\Kilosort2\CUDA\mexThSpkPC
    DEF : "C:\Users\Hannah Payne\AppData\Local\Temp\mex_4291783878875_13956\mexThSpkPC.def"
    EXP : "mexThSpkPC.exp"
    LIB : "mexThSpkPC.lib"
    EXE : mexThSpkPC.mexw64
    ILK : "mexThSpkPC.ilk"
    MANIFEST : "mexThSpkPC.mexw64.manifest"
    TEMPNAME : mexThSpkPC
    EXEDIR : 
    EXENAME : mexThSpkPC
    NVCC_FLAGS : 
    OPTIM : --compiler-options=/O2,/Oy-,/DNDEBUG
    LINKOPTIM : 
    CMDLINE100_0 : nvcc -c --compiler-options=/Zp8,/GR,/W3,/EHs,/nologo,/MD -gencode=arch=compute_30,code=sm_30 -gencode=arch=compute_50,code=sm_50 -gencode=arch=compute_60,code=sm_60 -gencode=arch=compute_70,code=\"sm_70,compute_70\"  --compiler-options=/O2,/Oy-,/DNDEBUG --compiler-options=/DMX_COMPAT_64  --compiler-options=/DMATLAB_DEFAULT_RELEASE=R2017b  --compiler-options=/DUSE_MEX_CMD   --compiler-options=/D_CRT_SECURE_NO_DEPRECATE,/D_SCL_SECURE_NO_DEPRECATE,/D_SECURE_SCL=0,/DMATLAB_MEX_FILE -I"C:\Program Files\MATLAB\R2018a\extern\include" -I"C:\Program Files\MATLAB\R2018a\simulink\include" "D:\hannah\Dropbox\alab\code\Kilosort2\CUDA\mexThSpkPC.cu" -o "C:\Users\Hannah Payne\AppData\Local\Temp\mex_4291783878875_13956\mexThSpkPC.obj" && echo /Fo > NUL
    CMDLINE100_1 : nvcc -c --compiler-options=/Zp8,/GR,/W3,/EHs,/nologo,/MD -gencode=arch=compute_30,code=sm_30 -gencode=arch=compute_50,code=sm_50 -gencode=arch=compute_60,code=sm_60 -gencode=arch=compute_70,code=\"sm_70,compute_70\"  --compiler-options=/O2,/Oy-,/DNDEBUG --compiler-options=/DMX_COMPAT_64  --compiler-options=/DMATLAB_DEFAULT_RELEASE=R2017b  --compiler-options=/DUSE_MEX_CMD   --compiler-options=/D_CRT_SECURE_NO_DEPRECATE,/D_SCL_SECURE_NO_DEPRECATE,/D_SECURE_SCL=0,/DMATLAB_MEX_FILE -I"C:\Program Files\MATLAB\R2018a\extern\include" -I"C:\Program Files\MATLAB\R2018a\simulink\include" "C:\Program Files\MATLAB\R2018a\extern\version\c_mexapi_version.c" -o "C:\Users\Hannah Payne\AppData\Local\Temp\mex_4291783878875_13956\c_mexapi_version.obj" && echo /Fo > NUL
-------------------------------------------------------------------
Building with 'NVIDIA CUDA Compiler'.
nvcc -c --compiler-options=/Zp8,/GR,/W3,/EHs,/nologo,/MD -gencode=arch=compute_30,code=sm_30 -gencode=arch=compute_50,code=sm_50 -gencode=arch=compute_60,code=sm_60 -gencode=arch=compute_70,code=\"sm_70,compute_70\"  --compiler-options=/O2,/Oy-,/DNDEBUG --compiler-options=/DMX_COMPAT_64  --compiler-options=/DMATLAB_DEFAULT_RELEASE=R2017b  --compiler-options=/DUSE_MEX_CMD   --compiler-options=/D_CRT_SECURE_NO_DEPRECATE,/D_SCL_SECURE_NO_DEPRECATE,/D_SECURE_SCL=0,/DMATLAB_MEX_FILE -I"C:\Program Files\MATLAB\R2018a\extern\include" -I"C:\Program Files\MATLAB\R2018a\simulink\include" "D:\hannah\Dropbox\alab\code\Kilosort2\CUDA\mexThSpkPC.cu" -o "C:\Users\Hannah Payne\AppData\Local\Temp\mex_4291783878875_13956\mexThSpkPC.obj" && echo /Fo > NUL
Error using mex
nvcc fatal   : Could not set up the environment for Microsoft Visual Studio using 'C:/Program Files (x86)/Microsoft
Visual Studio 12.0/VC/Bin/amd64/../../../VC/bin/amd64/vcvars64.bat'

Error in mexcuda (line 157)
    [varargout{1:nargout}] = mex(mexArguments{:}); 
hpay commented 5 years ago

Finally got it working. Not sure what the problem was, but I ended up making a new local user account, and CUDA 9.0 + Visual studio 2013 (which I had already installed across the system) just worked. So I compiled the mex files there, and can now use them from my original account.