gpuDevice() toolkit version always 5.5 - matlab

No matter how I reinstall the CUDA driver and toolkit, when typing gpuDevice(), it always show s:
CUDADevice with properties:
Name: 'Quadro K2000M'
Index: 1
ComputeCapability: '3.0'
SupportsDouble: 1
DriverVersion: 6.5000
ToolkitVersion: 5.5000
MaxThreadsPerBlock: 1024
MaxShmemPerBlock: 49152
MaxThreadBlockSize: [1024 1024 64]
MaxGridSize: [2.1475e+09 65535 65535]
SIMDWidth: 32
TotalMemory: 2.1475e+09
FreeMemory: 2.0431e+09
MultiprocessorCount: 2
ClockRateKHz: 745000
ComputeMode: 'Default'
GPUOverlapsTransfers: 1
KernelExecutionTimeout: 0
CanMapHostMemory: 1
DeviceSupported: 1
DeviceSelected: 1
which I don't understand. Why the toolkit version is always 5.5? Can I upgrade it to 6.5?

As #Robert mentioned, you have to use the same cuda version but not necessarily if you use simple trick (I'm using CUDA 6.0 and MATLAB CUDA version is 5.0). To make it work, you do not need the complicated procedure, nor the mex for compiling all .cu files and copying the xml file ( as in Link) to the directory to compile. Type simply the following two lines in the matlab command,
!nvcc -O3 -DNDEBUG -c mexGPUExample.cu -Xcompiler -fPIC -I/MATLAB_ROOT/extern/include -I/MATLAB_ROOT/toolbox/distcomp/gpu/extern/include;
mex mexGPUExample.o -L/usr/local/cuda-6.0/lib64 -L/MATLAB_ROOT/bin/glnxa64 -lcudart -lcufft -lmwgpu
Then it will magically work even if your ToolkitVersion mismatches. (Change /MATLAB_ROOT to your matlab root path)
Why MATLAB CUDA Toolkit version is different from System CUDA version?
Regarding your question, the installed CUDA version is not the same CUDA that MATLAB use.
If you go to
/matlabroot/bin/maci64 (OS X)
/matlabroot/bin/glnxa64 (unix variant)
depending on your os,
you can see the [dynamic linking library, shared library]
libcudart.5.5.[dylib, so]
libcublas.5.5.[dylib, so]
libcufft.5.5.[dylib, so]
These are the libraries that MATLAB uses. To make matlab to use system libraries, follow the instructions below. (MAC only)
In sum,
The installed cuda version is different from MATLAB cuda since they have their own library
To trick it to load the new library, you might need to use install_name_tool to change the library link
Anyway you don't need it to have same version.
EDIT : How to make MATLAB to use System CUDA Library (OS X)
Make MATLAB to use System CUDA library, The default MATLAB CUDA library version is 5.5 and if you want to use the up-to-date library, read the following
Go to /Applications/MATLAB_R2014a.app/bin/maci64(MAC) or MATLAB_ROOT/bin/glxna64(LINUX)
See the library dependencies of libmwgpu.[dylib, so] this is the entry library that is loaded when you use CUDA
The result would look like
dnab404675:maci64 user$ otool -L libmwgpu.dylib
libmwgpu.dylib:
#rpath/libmwgpu.dylib (compatibility version 0.0.0, current version 0.0.0)
.... Some Libraries
#rpath/libcublas.5.5.dylib (compatibility version 5.5.0, current version 5.5.20)
#rpath/libcudart.5.5.dylib (compatibility version 5.5.0, current version 5.5.20)
#rpath/libcufft.5.5.dylib (compatibility version 5.5.0, current version 5.5.20)
... and more
Our goal is to modify the library dependency of `cublas`, `cudart`, `cufft` to
> /usr/local/cuda/lib/libcublas.dylib (compatibility version 5.5.0, current version 5.5.20)
/usr/local/cuda/lib/libcudart.dylib (compatibility version 5.5.0, current version 5.5.20)
/usr/local/cuda/lib/libcufft.dylib (compatibility version 5.5.0, current version 5.5.20)
Note that if you type gpuDevice, it will still show it as toolkit version 5. But it loads the new version. So how we do that?
Simply type
sudo install_name_tool -change #rpath/libcufft.5.5.dylib /usr/local/cuda/lib/libcufft.dylib libmwgpu.dylib
sudo install_name_tool -change #rpath/libcudart.5.5.dylib /usr/local/cuda/lib/libcudart.dylib libmwgpu.dylib
sudo install_name_tool -change #rpath/libcublas.5.5.dylib /usr/local/cuda/lib/libcublas.dylib libmwgpu.dylib
I still don't know how to change the shared library path in Linux. Probably have to use hexadecimal editor such as HT From Stackoverflow Answer

You can also use CUDA 6.5 with matlab under Windows. The tricky part is, you need to compile the mex files under Visual Studio rather than inside matlab. There are numerous tutorials introducing how to compile mex under VS so there is no need to repeat here. You need only to create a NVIDIA cuda project with .cu as the source, and follow the standard procedures to compile mex.

Related

MATLAB codegen: /lib64/libstdc++.so.6: version: 'GLIBCXX_3.4_20' not found

Trying to run codegen with MATLAB 2019a on a linux box and got the error:
... /lib64/libstdc++.so.6: version: 'GLIBCXX_3.4_20' not found ...
I have /lib64/libstdc++.so.6, just (apparently) not the right version. How can I resolve this?
Here is a list of supported compilers for your version of MATLAB.
Apparently MATLAB R2019a on Linux requires GCC 6.3.x. Make sure you have that version installed.

CMake Error at HW1_generated_student_func.cu [duplicate]

I'm currently trying to compile Darknet on the latest CUDA toolkit which is version 11.1. I have a GPU capable of running CUDA version 5 which is a GeForce 940M. However, while rebuilding darknet using the latest CUDA toolkit, it said
nvcc fatal : Unsupported GPU architecture 'compute_30'
compute_30 is for version 3, how can it fail while my GPU can run version 5
Is it possible that my code detected my intel graphics card instead of my Nvidia GPU? if that's the case, is it possible to change its detection?
Support for compute_30 has been removed for versions after CUDA 10.2. So if you are using nvcc make sure to use this flag to target the correct architecture in the build system for darknet
-gencode=arch=compute_50,code=sm_50
You may also need to use this one to avoid a warning of architectures are deprecated.
-Wno-deprecated-gpu-targets
I added the following:
makefiletemp = open('Makefile','r+')
list_of_lines = makefiletemp.readlines()
list_of_lines[15] = list_of_lines[14]
list_of_lines[16] = "ARCH= -gencode arch=compute_35,code=sm_35 \\\n"
makefiletemp = open('Makefile','w')
makefiletemp.writelines(list_of_lines)
makefiletemp.close()
right before the
#Compile Darknet
!make
command. That seemed to work!

Failed to find 'Power Electronics/Full-Bridge Converter' in library 'powerlib'?

Im trying to run a simulation (done in matlab 2020a I guess) but when running it , it gives the next error
Failed to find 'Power Electronics/Full-Bridge Converter' in library 'powerlib' referenced by Full-Bridge Converter'
But in my install it already has the toolboxes installed
SimElectronics Version 2.5 (R2014a)
SimMechanics Version 4.4 (R2014a)
SimPowerSystems Version 6.1 (R2014a)
Simscape Version 3.11 (R2014a)
I have been told these are necessary,but then what? the needed toolboxes are supposed to be installed. What more is needed?
PD
Some friend told me the simpowersystems were merged alongside the simelectronics, into SimscapePowerSystems, so guessing the model is writen in that, whats the lower version with comes with these toolbox?, 2017?, 2016?

CUDA driver too old for Matlab GPU?

Ok,this is something am having problems with. I recently installed Matlab R2013a on a x86_64 Linux system running RHEL 5, attached to a Tesla S2050. I have never used the GPU functionality in Matlab itself (but have tried some of it using Jacket that lets one
program GPUs in Matlab).
The Tesla is working fine with all the drivers ,CUDA installed (Jacket v1.8.2 is running fine without complaints).
** Driver Version: 270.41.34 (the last version from 2011, supporting S2050) **
CUDA: v5.0.35
nvcc -V : Cuda compilation tools, release 5.0, V0.2.1221
But the Matlab r2013a complains:
gpuDevice errors:
Caused by:
The CUDA driver was found, but it is too old. The CUDA driver on your system supports CUDA version 4. The required CUDA version is 5 or greater.
Now, I understand the error that Matlab has problems with the Driver version. But, I have installed the latest CUDA toolkit and the latest driver that nVidia has to offer for the Tesla S2050 that I have.
Is there a later driver version available for this Tesla (i downloaded the latest driver & when trying to install, it simply complains that I don't have the compatible nVidia hardware).
How do I tell Matlab to consider the relevant CUDA ? (where to set PATH, CUDA_PATH etc., if any ? )
Are there any other checks i need to perform the evaluate the working of the attached Tesla ?
Thanks in advance for help.
You cannot use CUDA 5.0 with driver 270.41.34. CUDA 5 requires 304.54 or newer. This is not a MATLAB issue.
Newer drivers that support CUDA 5 will also support Tesla S2050.
For example this recent 319.17 driver lists Tesla S2050 on the supported products tab. Or use the 304.54 that comes with cuda 5.0.

which configuration option is used by Mex to compile using matlab?

say, if choose mexopts.sh as the configuration files for mex,
then how does mex decide which option listed in the mexopts.sh is used for compiling?
for example, using 32bit matlab on 64bit mac os x:
mexopts.sh looks like:
,,maci
........
,,maci64
......
Then, maci or maci64 is used when compiling?
What commands or way can I do in order to compile 32bit lib instead of 64bit lib?
Further explanation of my process and the error message I got :
I am using mac os x 10.8 (64bit) with matlab R2010a (32bit) to produce a binary mex-file.
The Xcode is 4.6 version, I installed Command Line Tools on my machine. Then I downloaded the patch from matlab for 2011 and 2012 version anyway. (if I don't install the patch, I got a lot of link errors saying some header files are missing).
After I installed the patch ( I believe it changes my mexopts.sh file), when I run mex a.cpp, I got error message saying that /Applications/MATLAB_R2010a.app/bin/maci64 cannot be found. Of course, it cannot find the maci64 folder, it is 32bit, there is only maci folder.
So Anyone knows what I should do in order to make matlab look for maci folder instead of maci64 folder? Thanks a lot!
MATLAB does not support cross compilation of MEX files. So your 32-bit MATLAB installation should be producing 32-bit MEX files even though the OS is 64-bit.
Also, from the article I've linked
Further, beginning with R2010b, a 32-bit version of MATLAB is no longer produced for the Mac.
If you're running R2010b or later, your MATLAB is not 32-bit anyway.
To see what switches the MEX script is invoking the compiler with, use the -v option.
You can also use the file tool to check whether the generated binary is 32 or 64-bit.
As its been explained, MATLAB produces MEX files of the same bit-ness as itself, not that of the OS. This is true at least on Windows with recent MATLAB versions, where you can have either 32-bit or 64-bit MATLAB running on 64-bit Windows. Other platforms are moving towards 64-bit versions only.
Here is another way to get the configured mex switches:
>> cc = mex.getCompilerConfigurations
>> cc.Details
In my case I get:
>> cc = mex.getCompilerConfigurations
cc =
CompilerConfiguration with properties:
Name: 'Microsoft Visual C++ 2010'
Manufacturer: 'Microsoft'
Language: 'C++'
Version: '10.0'
Location: 'C:\Program Files\Microsoft Visual Studio 10.0'
Details: [1x1 mex.CompilerConfigurationDetails]
LinkerName: 'Microsoft Visual C++ 2010'
LinkerVersion: '10.0'
>> cc.Details
ans =
CompilerConfigurationDetails with properties:
CompilerExecutable: 'cl'
CompilerFlags: [1x115 char]
OptimizationFlags: '/O2 /Oy- /DNDEBUG'
DebugFlags: '/Z7'
LinkerExecutable: 'link'
LinkerFlags: [1x327 char]
LinkerOptimizationFlags: ''
LinkerDebugFlags: '/debug /PDB:"%OUTDIR%%MEX_NAME%%MEX_EXT%.pdb"'
To answer my own question, just for those who may be interested in it,
I checked the contents of mexopts.sh and modified the part for maci (specifically set ARCH=i386) , then compile. The error message is gone.