RuntimeError: /usr/lib/libopenblas.so: undefined symbol: LAPACKE_dgesvd
mrkn opened this issue · 11 comments
When I use Ubuntu Xenial, Numo::Linalg.svd raises RuntimeError because it cannot resolve the symbol LAPACKE_dgesvd
.
As I investigated libopenblas.so
, I found that the library has dgesvd_
but not LAPACKE_dgesvd
.
$ objdump -T /usr/lib/libopenblas.so | grep svd
0000000001aacb90 g DF .text 0000000000008b48 Base sgesvd_
000000000198ad60 g DF .text 00000000000008e8 Base dggsvd3_
0000000001ad0f50 g DF .text 00000000000008e4 Base sggsvd3_
000000000181fa30 g DF .text 0000000000001e62 Base cgesvdx_
0000000001939190 g DF .text 0000000000001fe3 Base dbdsvdx_
0000000001a7f960 g DF .text 0000000000001f82 Base sbdsvdx_
0000000001c11780 g DF .text 00000000000007a5 Base zggsvd_
0000000001beddd0 g DF .text 00000000000088a4 Base zgesvd_
000000000183a240 g DF .text 0000000000000794 Base cggsvd_
0000000001816f90 g DF .text 0000000000008a94 Base cgesvd_
0000000001bf6680 g DF .text 0000000000001ee2 Base zgesvdx_
000000000196f1d0 g DF .text 0000000000001da5 Base dgesvdx_
0000000001ab56e0 g DF .text 0000000000001da5 Base sgesvdx_
000000000198a5e0 g DF .text 0000000000000775 Base dggsvd_
000000000183a9e0 g DF .text 0000000000000947 Base cggsvd3_
00000000019667f0 g DF .text 00000000000089dd Base dgesvd_
0000000001c11f30 g DF .text 0000000000000953 Base zggsvd3_
0000000001ad07d0 g DF .text 0000000000000774 Base sggsvd_
If libopenblas.so does not include LAPACKE API, it needs to load liblapacke.so.
The following is not tested on Ubuntu but probably works.
Fiddle.dlopen("/usr/lib/libopenblas.so")
Numo::Linalg::Lapack.dlopen("/usr/lib/liblapacke.so")
Can confirm it works on Ubuntu 16.04, though the second file has an extra '.3' in the name:
Fiddle.dlopen("/usr/lib/libopenblas.so")
Numo::Linalg::Lapack.dlopen("/usr/lib/liblapacke.so.3")
Any chance to make this the default when using OpenBLAS?
Does this short name cause an error on Ubuntu?
Numo::Linalg::Lapack.dlopen("liblapacke.so")
I confirm the short name causes an error on Ubuntu. Full trace:
giuse@free:~$ rvm gemset create test_numo_linalg
ruby-2.4.2 - #gemset created /home/giuse/.rvm/gems/ruby-2.4.2@test_numo_linalg
ruby-2.4.2 - #generating test_numo_linalg wrappers.......
giuse@free:~$ rvm gemset use test_numo_linalg
Using ruby-2.4.2 with gemset test_numo_linalg
giuse@free:~$ gem install numo-linalg
Fetching: numo-narray-0.9.1.1.gem (100%)
Building native extensions. This could take a while...
Successfully installed numo-narray-0.9.1.1
Fetching: numo-linalg-0.1.1.gem (100%)
Building native extensions. This could take a while...
Successfully installed numo-linalg-0.1.1
2 gems installed
giuse@free:~$ irb
2.4.2 :001 > require 'numo/narray'
=> true
2.4.2 :002 > require 'numo/linalg'
=> true
2.4.2 :003 > Fiddle.dlopen("/usr/lib/libopenblas.so")
=> #<Fiddle::Handle:0x00000000024c95d0>
2.4.2 :004 > Numo::Linalg::Lapack.dlopen("liblapacke.so")
RuntimeError: liblapacke.so: cannot open shared object file: No such file or directory
from (irb):4:in `dlopen'
from (irb):4
from /home/giuse/.rvm/rubies/ruby-2.4.2/bin/irb:11:in `<main>'
2.4.2 :005 > Numo::Linalg::Lapack.dlopen("liblapacke.so.3")
=> nil
Should I try with your commit 3c94713 ?
numo-linalg 0.1.2 will work with version suffix.
I have also checked loading openblas without configuration on MSYS2.
I have not checked it on Mac.
I am currently working to get Travis CI to pass. I noticed this line when it installs libopenblas-base
which may be pertinent to this issue:
update-alternatives: using /usr/lib/openblas-base/libblas.so.3 to provide /usr/lib/libblas.so.3 (libblas.so.3) in auto mode
I confirm numo-linalg 0.1.2
fixes this for me.
([...]
stands for matrix content truncated. Notice no explicit call to Fiddle::dlopen
nor Numo::Linalg::Lapack::dlopen
)
2.4.2 :001 > require 'numo/narray'
=> true
2.4.2 :002 > require 'numo/linalg'
=> true
2.4.2 :003 > a = Numo::DFloat.new(3,3).seq
=> Numo::DFloat#shape=[3,3] [[0, 1, 2], [3, 4, 5], [6, 7, 8]]
2.4.2 :004 > Numo::Linalg::Lapack.call(:geev, a, jobvl: false, jobvr: true)
=> [Numo::DFloat#shape=[3] [...], Numo::DFloat#shape=[3] [...], nil, Numo::DFloat#shape=[3,3] [...], 0]
2.4.2 :005 > Numo::Linalg.eig a
=> [Numo::DComplex#shape=[3] [...], nil, Numo::DComplex#shape=[3,3] [...]]
2.4.2 :006 > Numo::Linalg.svd a
=> [Numo::DFloat#shape=[3] [...], Numo::DFloat#shape=[3,3] [...], Numo::DFloat#shape=[3,3] [...]]
Does that work for you @mrkn -san? Can we close this issue?
UPDATE: it seems Travis CI is having the same issue as @mrkn -san.
You can see the full log on my Travis, errors 5 through 11. To see the complete config used, click on "view config" (here for convenience).
The error is because "liblapacke" package is not installed. Please add it to config file.
Great! It works! Thank you so much Tanaka-san! Installation on Travis is now working. I need to find out why some of my tests are red although they are all green on my machine, but oh well, I will fix that.
For me the issue can be closed. Thanks for your time and support!