matlab link interface

Support for issues specific to the Mac OS operating systems.

matlab link interface

Postby cstring » Thu Jun 09, 2011 11:14 am

Hi,
I having trouble using the link interface with matlab on my mac. I added the cula libraries to set the environment variables with the following script
Code: Select all
export DYLD_LIBRARY_PATH=/usr/local/cula/lib:$DYLD_LIBRARY_PATH
export LAPACK_VERSION= libcula_link.dylib
export BLAS_VERSION= libcula_link.dylib
export LAPACK_VERBOSITY=1
export CULA_ILP64=1
CULA_DEBUG_LOG=~/matlab_cula.log

But when I try to do a simple matrix multiply with matlab I receive the following error
    >> A = rand(1e4);tic, A*A; toc
    libmwblas: load error: basic_string::_S_construct NULL not valid
    Caught "std::exception" Exception message is:
    basic_string::_S_construct NULL not valid
Has anyone else been able to successfully link cula with matlab on mac os?
Thanks,
Craig
PS: I am running matlab 2011a x64 on a early 2008 mac pro with two gtx285 with cuda 4.0
cstring
 
Posts: 4
Joined: Fri Dec 03, 2010 2:38 pm

Re: matlab link interface

Postby kyle » Fri Jun 10, 2011 10:45 am

Not sure if this will solve the problem, but BASH will not ignore your spaces in the export commands. Try removing the spaces such that:

Code: Select all
export DYLD_LIBRARY_PATH=/usr/local/cula/lib:$DYLD_LIBRARY_PATH
export LAPACK_VERSION=libcula_link.dylib
export BLAS_VERSION=libcula_link.dylib
export LAPACK_VERBOSITY=1
export CULA_ILP64=1
CULA_DEBUG_LOG=~/matlab_cula.log

Let us know if this solves the problem!
kyle
Administrator
 
Posts: 301
Joined: Fri Jun 12, 2009 7:47 pm

Re: matlab link interface

Postby cstring » Fri Jun 10, 2011 11:57 am

Thanks for the reply Kyle, that changed the errror, but I still get the following:
    >> A = (randn(2048));tic, [tU,tS,tV] = svd(A); toc
    cpu_id: x86 Family 6 Model 7 Stepping 6, GenuineIntel
    libmwlapack: trying environment...
    libmwlapack: loading libcula_link.dylib

    libmwlapack: load error: dlopen(libcula_link.dylib
    , 1): image not found
    Caught "std::exception" Exception message is:
    dlopen(libcula_link.dylib
    , 1): image not found
    libmwlapack: unloading libraries
Any other Ideas? I have tried adding either
    export DYLD_LIBRARY_PATH=/usr/local/cula/lib64:$DYLD_LIBRARY_PATH
or
    export DYLD_LIBRARY_PATH=/usr/local/cula/lib:$DYLD_LIBRARY_PATH
but I still get the same error.
Thanks,
Craig
cstring
 
Posts: 4
Joined: Fri Dec 03, 2010 2:38 pm

Re: matlab link interface

Postby cstring » Fri Jun 10, 2011 12:22 pm

If I add a semi-colon after the library, matlab now crashes. It seems like it may be closer to working though... as it is crashing with the following in the error report
    Dyld Error Message:
    Symbol not found: _cudaDeviceSynchronize
    Referenced from: /usr/local/cula/lib64/libcula.dylib
    Expected in: /Applications/MATLAB_R2011a.app/bin/maci64/libcudart.dylib
Please see the attachment for the full error.
Thanks,
Craig
Attachments
matlabCrash.txt
(44.75 KiB) Downloaded 449 times
cstring
 
Posts: 4
Joined: Fri Dec 03, 2010 2:38 pm

Re: matlab link interface

Postby kyle » Mon Jun 13, 2011 12:25 pm

Make sure you are only using the 64-bit libraries. I see you still have a 32-bit folder listed in your example.
kyle
Administrator
 
Posts: 301
Joined: Fri Jun 12, 2009 7:47 pm

Re: matlab link interface

Postby cstring » Tue Jun 14, 2011 11:01 am

Thanks for the suggestion Kyle. I've tried double checking and I think I'm only including 64-bit libraries. Have you successfully used the matlab link interface on a mac?
Thanks,
Craig
cstring
 
Posts: 4
Joined: Fri Dec 03, 2010 2:38 pm

Re: matlab link interface

Postby kyle » Tue Jun 21, 2011 4:45 pm

We've successfully tested the link interface with OSX but we don't currently have access to a copy of MATLAB for Mac. I'll see if we find a trial copy to test further.
kyle
Administrator
 
Posts: 301
Joined: Fri Jun 12, 2009 7:47 pm

Re: matlab link interface

Postby chester1248 » Mon Aug 22, 2011 9:49 pm

cstring -- are you still having problems with cula link in matlab 2011a in OSX? It works for me, but on a Snow Leopard MBP using it's 330M GPU (no PCIe cards). If you are having problems still, what is your latest bash exports, according to "env"?
chester1248
 
Posts: 5
Joined: Tue Oct 06, 2009 6:38 pm

Re: matlab link interface

Postby rmgarnett » Fri Sep 02, 2011 9:54 pm

chester1248 wrote:cstring -- are you still having problems with cula link in matlab 2011a in OSX? It works for me, but on a Snow Leopard MBP using it's 330M GPU (no PCIe cards). If you are having problems still, what is your latest bash exports, according to "env"?


Hello,

Well I can unfortunately report that I am having the same problem that cstring was. With OS X 10.7.1 / MATLAB R2011a (64bit) / CULA Premium R12 / CUDA 4.0.13 / NVIDIA drivers 7.4.10 270.05.05f01, and the following environment:

Code: Select all
DYLD_LIBRARY_PATH=/usr/local/cula/lib64:/usr/local/cuda/lib:$DYLD_LIBRARY_PATH
LAPACK_VERSION=libcula_link.dylib
BLAS_VERSION=libcula_link.dylib
LAPACK_VERBOSITY=1
CULA_ILP64=1
CULA_DEBUG_LOG=/Users/roman/matlab_cula.log

I see:

>> a = rand(5e3); a = a * a;
dyld: lazy symbol binding failed: Symbol not found: _cudaDeviceSynchronize
Referenced from: /usr/local/cula/lib64/libcula.dylib
Expected in: /Applications/MATLAB_R2011a.app/bin/maci64/libcudart.dylib

dyld: Symbol not found: _cudaDeviceSynchronize
Referenced from: /usr/local/cula/lib64/libcula.dylib
Expected in: /Applications/MATLAB_R2011a.app/bin/maci64/libcudart.dylib

after which MATLAB crashes. I added /usr/local/cuda/lib/ to DYLD_LIBRARY_PATH on a lark, but it does not affect the behavior. If anyone has any ideas I'd be grateful!

Cheers
Roman
rmgarnett
 
Posts: 2
Joined: Sat Aug 27, 2011 2:40 pm

Re: matlab link interface

Postby chester1248 » Fri Sep 02, 2011 11:05 pm

Roman, just to double check, maybe you should have your wrapper script (which sets the env vars and then starts matlab) to print out all the variable values (i.e. run "env" before "matlab ..." in your script). The problem you see could, for example, happen if you set the environ variables as you show, but those were not the var settings when matlab is started up.

Alternatively, double check within matlab by calling the matlab getenv() function, for those variables.

If they all report as you showed in your posting, then I would next suspect that CULA isn't actually (fully) installed in the default directories as you might think. So you might want to verify that the CULA library files are in the paths you expected?

Anyway, just in case you didn't already check these things ... good to eliminate the obvious stuff before something more complex that might be going on ...
chester1248
 
Posts: 5
Joined: Tue Oct 06, 2009 6:38 pm

Re: matlab link interface

Postby rmgarnett » Fri Sep 02, 2011 11:32 pm

chester1248 wrote:Roman, just to double check, maybe you should have your wrapper script (which sets the env vars and then starts matlab) to print out all the variable values (i.e. run "env" before "matlab ..." in your script). The problem you see could, for example, happen if you set the environ variables as you show, but those were not the var settings when matlab is started up.

Alternatively, double check within matlab by calling the matlab getenv() function, for those variables.

If they all report as you showed in your posting, then I would next suspect that CULA isn't actually (fully) installed in the default directories as you might think. So you might want to verify that the CULA library files are in the paths you expected?

Anyway, just in case you didn't already check these things ... good to eliminate the obvious stuff before something more complex that might be going on ...


Okay sure, here we go:

[edit: this response gets a bit stream of conscious]

Checking MATLAB environment after starting:
Code: Select all
>> getenv('DYLD_LIBRARY_PATH')
ans =
/Applications/MATLAB_R2011a.app/sys/os/maci64:/Applications/MATLAB_R2011a.app/bin/maci64:/Applications/MATLAB_R2011a.app/extern/lib/maci64:/Applications/MATLAB_R2011a.app/runtime/maci64:/usr/local/cula/lib64:/usr/local/cuda/lib
>> getenv('LAPACK_VERSION')   
ans =
libcula_link.dylib
>> getenv('BLAS_VERSION') 
ans =
libcula_link.dylib
>> getenv('CULA_ILP64')     
ans =
1


Checking CULA library presence:
Code: Select all
$ find /usr/local/cula/lib64
/usr/local/cula/lib64
/usr/local/cula/lib64/lapackcpu.dylib
/usr/local/cula/lib64/libcublas.dylib
/usr/local/cula/lib64/libcudart.dylib
/usr/local/cula/lib64/libcula.dylib
/usr/local/cula/lib64/libcula_fortran.dylib
/usr/local/cula/lib64/libcula_link.dylib
/usr/local/cula/lib64/libcula_pgfortran.dylib


Additionally, I can compile and run the linkInferface example without any problems:
Code: Select all
$ DYLD_LIBRARY_PATH=/usr/local/cula/lib64/ ./linkInterface
Solving a 8192x4096 system
Allocating Matrices
Querying Workspace
Calling sgels
Computation succeeded


So something MATLAB-specific seems to be going on here. In fact...using the DYLD_LIBRARY_PATH that MATLAB has in its environment:
Code: Select all
$ DYLD_LIBRARY_PATH=/Applications/MATLAB_R2011a.app/sys/os/maci64:/Applications/MATLAB_R2011a.app/bin/maci64:/Applications/MATLAB_R2011a.app/extern/lib/maci64:/Applications/MATLAB_R2011a.app/runtime/maci64:/usr/local/cula/lib64:/usr/local/cuda/lib ./linkInterface
Solving a 8192x4096 system
Allocating Matrices
Querying Workspace
dyld: lazy symbol binding failed: Symbol not found: _cudaDeviceSynchronize
  Referenced from: /usr/local/cula/lib64/libcula.dylib
  Expected in: /Applications/MATLAB_R2011a.app/bin/maci64/libcudart.dylib

dyld: Symbol not found: _cudaDeviceSynchronize
  Referenced from: /usr/local/cula/lib64/libcula.dylib
  Expected in: /Applications/MATLAB_R2011a.app/bin/maci64/libcudart.dylib

Trace/BPT trap: 5


And I guess that's the problem. The libcudart.dylib in /Applications/MATLAB_R2011a.app/bin/maci64 is loaded rather than /usr/local/cula/lib64/libcudart.dylib; the former is missing symbols that CULA is looking for.

So I tried a hacky solution. I moved the libcudart from the MATLAB directory (and libcublas as well), and things work now. I don't think this is really optimal, however. Can you think of anything more elegant?

Thank you!
Roman
rmgarnett
 
Posts: 2
Joined: Sat Aug 27, 2011 2:40 pm

Re: matlab link interface

Postby john » Tue Sep 06, 2011 6:20 am

You could deactivate or uninstall the Matlab parallel computing toolkit (PCT). CULA's link interface is completely incompatible with PCT, for the reasons you are seeing here - their CUDA version is far behind. Since Matlab can't load both CUDA toolkits, then you need to choose which you prefer.

On Windows, we've seen that you can work around this by ensuring your first CULA call comes before your first PCT call. In that case, the CUDA runtime in your DYLD_LIBRARY_PATH will be loaded rather than the one in PCT. On OSX, your mileage may vary.
john
Administrator
 
Posts: 587
Joined: Thu Jul 23, 2009 2:31 pm


Return to Mac OS X Support

Who is online

Users browsing this forum: No registered users and 1 guest

cron