Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gpuDevice() toolkit version always 5.5

Tags:

cuda

matlab

gpu

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?

like image 601
Ono Avatar asked Aug 05 '14 14:08

Ono


1 Answers

I do not see why this question gets down vote. This is the first question that I had in mind when I try to use CUDA in MEX.

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,

  1. The installed cuda version is different from MATLAB cuda since they have their own library
  2. To trick it to load the new library, you might need to use install_name_tool to change the library link
  3. 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

  1. Go to /Applications/MATLAB_R2014a.app/bin/maci64(MAC) or MATLAB_ROOT/bin/glxna64(LINUX)
  2. 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?

  3. 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

like image 84
VforVitamin Avatar answered Nov 15 '22 07:11

VforVitamin