svd under Matlab with cula link

General CULA Dense (LAPACK & BLAS) support and troubleshooting. Use this forum if you are having a general problem or have encountered a bug.

svd under Matlab with cula link

Postby glaurent » Sat Jun 06, 2015 4:29 am

Hi,
Thank you for your amazing job developing cula.

I am using Matlab R2015a under two quad cores computer, one with Linux Fedora 21 64 bits, and the other one with Windows 7 64 bits. Both are equipped with a Nvidia GTX 260, with driver 340.76 and 341.44 respectively. Cula R18 dense free edition has been installed following this procedure http://www.culatools.com/blog/2011/05/3 ... interface/ . While quite old, this graphic card has already been used successfully to speed up singular value decomposition under java with cula http://pascal-man.com/navigation/faq-ja ... -GPU.shtml.

First, a Matlab script under linux would have been appreciated, as it was under windows.

Second, there is a library issue with the free edition: there is an hidden call to cula_lapack.dll and cula_lapack.so. The easiest way is to rename cula_lapack_basic and cula_lapack_basic_link by removing basic from their names. Thus we even don't need to modify Matlab script.

Third, and this is my main problem, there is a difference between commands S=svd(A) which uses GPU and [U,S,V]=svd(A) which doesn't. This has already been noted in 2011 viewtopic.php?f=15&t=908 .

Here is the code I used for svd diagonal elements:
>> A = rand([4096 4096],'single');
>> tic ; S = svd(A) ; toc
cpu_id: x86 Family 6 Model 60 Stepping 3, GenuineIntel
LAPACK: trying environment...
LAPACK: loading cula_lapack_link.dll
LAPACK: loaded cula_lapack_link.dll@00000000262A0000
LAPACK: cula_lapack_link.dll is not a compatibility layer.
Elapsed time is 8.450830 seconds.


Here is the output in matlab_cula.log:
cula info: sgesvd (N, N, 4096, 4096, 0000000022290060, 4096, 00000000742AC4E0, 0000000000000000, 4096, 0000000000000000, 4096)
cula info: issuing to CPU (work query)
cula info: CPU library is lapackcpu.dll
cula info: work query returned 143360
cula info: done
cula info: sgesvd (N, N, 4096, 4096, 0000000022290060, 4096, 00000000742AC4E0, 0000000000000000, 4096, 0000000000000000, 4096)
cula info: issuing to GPU (over threshold)
cula info: done


When calculating the full matrices:
>> tic ; [U,S,V] = svd(A) ; toc
Elapsed time is 20.063854 seconds.


Here is the output in matlab_cula.log:
cula info: sgesdd ()
cula info: issuing to CPU (no GPU function available)
cula info: work query returned 50360320
cula info: work query returned 0
cula info: done
cula info: sgesdd ()
cula info: issuing to CPU (no GPU function available)
cula info: done


Thus, there is a major treatment difference between sgesvd or cgesvd, which are using gpu, and sgesdd or cgesdd which are not. Unfortunately, I am interested in the 2 last commands.

Is there an easy way to obtain the full svd matrices with cula ? Do I need to install Matlab R2010b ?

Many thanks
glaurent
 
Posts: 2
Joined: Mon Jan 28, 2013 10:34 am

Re: svd under Matlab with cula link

Postby glaurent » Wed Jun 24, 2015 3:55 am

I am going to answer myself to my questions, hoping it will help somebody else.

1) Here is the code I used to start matlab with cula link under linux :
Code: Select all
#!/bin/bash

export CULA_ROOT="/usr/local/cula"
export CULA_INC_PATH="$CULA_ROOT/include"
export CULA_BIN_PATH_32="$CULA_ROOT/bin"
export CULA_BIN_PATH_64="$CULA_ROOT/bin64"
export CULA_LIB_PATH_32="$CULA_ROOT/lib"
export CULA_LIB_PATH_64="$CULA_ROOT/lib64"

export LD_LIBRARY_PATH=$CULA_LIB_PATH_32:$CULA_LIB_PATH_64

export LAPACK_VERSION=libcula_lapack_link.so
export BLAS_VERSION=libcula_lapack_link.so

# For x86_64
export CULA_ILP64=1

# Uncomment this line if you want debugging messages from MATLAB
export LAPACK_VERBOSITY=1

# Uncomment this line to create a debug log
export CULA_DEBUG_LOG=~/Documents/MATLAB/matlab_R2010a_cula.log

/opt/MATLAB/R2010a/bin/matlab

exit 0


2) sgesdd and cgesdd are a divide and conquer method. They have been implemented in matlab R2010b http://fr.mathworks.com/help/matlab/release-notes-older.html#R2010b. These functions are implemented in cula non-free edition http://www.culatools.com/forums/viewtopic.php?f=9&t=1085#p2115.

Furthermore, cula changed with R15 to feet matlab 2012 http://www.culatools.com/forums/viewtopic.php?f=9&t=1085#p2109.

Thus, using matlab R2010a and Cula R14 free, I succeeded to use full svd on graphic cards, both under linux and windows.

Another possibility is to use gpuArray functions under recent matlab parallel computing toolbox to do svd on the gpu. It should be noted that gtx 260 is only supported up to R2014a, as they have 1.3 compute capability (http://fr.mathworks.com/help/distcomp/release-notes.html#R2014b). A further performance gain is obtained from R2014a to R2015a using a GTX 660 graphic card with compute capability 3.0.

One more thing : under windows, it is necessary to remove the gpu timeout protection: http://www.mathworks.com/matlabcentral/answers/22047-cuda_error_launch_timeout#answer_29885 . The easiest way is to add the registry key HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\GraphicsDrivers\TdrLevel with a value of 0 (https://msdn.microsoft.com/en-us/Library/Windows/Hardware/ff569918%28v=vs.85%29.aspx)
glaurent
 
Posts: 2
Joined: Mon Jan 28, 2013 10:34 am


Return to CULA Dense Support

Who is online

Users browsing this forum: No registered users and 2 guests

cron