MatLab 错误:无法使用静态 TLS 打开 [英] MatLab error: cannot open with static TLS

查看:24
本文介绍了MatLab 错误:无法使用静态 TLS 打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

几天以来,我在使用 MATLAB 时不断收到相同的错误,该错误在某些时候使用 dlopen 发生.我对 MATLAB 很陌生,这就是为什么我不知道该怎么做.谷歌似乎也没有帮助我.当我尝试制作特征向量时,我得到了这个:

Since a couple of days, I constantly receive the same error while using MATLAB which happens at some point with dlopen. I am pretty new to MATLAB, and that is why I don't know what to do. Google doesn't seem to be helping me either. When I try to make an eigenvector, I get this:

Error using eig
LAPACK loading error:
dlopen: cannot load any more object with static TLS

我在做乘法时也得到了这个:

I also get this while making a multiplication:

Error using  * 
BLAS loading error:
dlopen: cannot load any more object with static TLS

我当然确实寻找过这个问题的解决方案,但我不太了解,不知道该怎么做.这些是我发现的线程:

I did of course look for the solutions to this problem, but I don't understand too much and don't know what to do. These are threads I found:

  1. 如何使用由MATLAB?
  2. http://www.mathworks.de/de/help/matlab/matlab_external/calling-lapack-and-blas-functions-from-mex-files.html

有人可以帮我吗?

>> randn(3,3)

ans =

 2.7694    0.7254   -0.2050             
-1.3499   -0.0631   -0.1241             
 3.0349    0.7147    1.4897            

>> eig(ans)

Error using eig
LAPACK loading error:
dlopen: cannot load any more object with static TLS

推荐答案

这是已知的 MATLAB 错误号 961964自 R2012b (8.0).MATLAB 使用静态 TLS(线程本地存储,例如参见 gcc 编译器标志 -ftls-model)动态加载一些库.加载太多这样的库 => 没有剩余空间.

That's bug no 961964 of MATLAB known since R2012b (8.0). MATLAB dynamically loads some libs with static TLS (thread local storage, e.g. see gcc compiler flag -ftls-model). Loading too many such libs => no space left.

到目前为止,mathwork 唯一的解决方法是通过尽早使用它们来首先加载重要的(!)库(他们建议将ones(10)*ones(10);"放在 startup.m 中).我最好不要评论这个解决方案策略".

Until now mathwork's only workaround is to load the important(!) libs first by using them early (they suggest to put "ones(10)*ones(10);" in startup.m). I better don't comment on this "solution strategy".

自从使用 Linux x86_64 的 R2013b (8.2.0.701) 以来,我的经验是:不要使用doc"(图形帮助系统)!我认为这个文档实用程序(libxul 等)使用了大量静态 TLS 内存.

Since R2013b (8.2.0.701) with Linux x86_64 my experience is: Don't use "doc" (the graphical help system)! I think this doc-utility (libxul, etc.) is using a lot of static TLS memory.

以下所有测试均使用 Fedora 20(使用 glibc-2.18-11.fc20)和 Matlab 8.3.0.73043(R2014a 预发行版)完成.

All the following tests were done with Fedora 20 (with glibc-2.18-11.fc20) and Matlab 8.3.0.73043 (R2014a Prerelease).

有关 TLS 的更多信息,请参阅Ulrich Drepper,用于线程本地存储的 ELF 处理,版本 0.21,2013,目前可在 Akkadia红帽.

For more information on TLS, see Ulrich Drepper, ELF handling For Thread-Local Storage, Version 0.21, 2013, currently available at Akkadia and Redhat.

究竟发生了什么?

MATLAB 动态(使用 dlopen)加载几个需要 tls 初始化的库.所有这些库都需要在 dtv(动态线程向量)中有一个插槽.因为 MATLAB 在编译/链接时在运行时动态加载这些库中的几个,所以链接器(在 mathworks 中)没有机会计算所需的插槽(这是重要的部分).现在,动态库加载器的任务是在运行时处理这种情况.但这并不容易.引用 dl-open.c:

MATLAB dynamically (with dlopen) loads several libraries that need tls initialization. All those libs need a slot in the dtv (dynamic thread vector). Because MATLAB loads several of these libs dynamically at runtime at compile/link time the linker (at mathworks) had no chance to count the slots needed (that's the important part). Now it's the task of the dynamic lib loader to handle such a case at runtime. But this is not easy. To cite dl-open.c:

对于静态 TLS,我们必须在这里分配内存,然后现在.这包括在 DTV 中分配内存.但我们不能更改我们自己以外的任何 DTV.所以,如果我们不能保证我们没有的 DTV 中有空间甚至尝试它并失败加载.

For static TLS we have to allocate the memory here and now. This includes allocating memory in the DTV. But we cannot change any DTV other than our own. So, if we cannot guarantee that there is room in the DTV we don't even try it and fail the load.

glibc 的动态库加载器中有一个编译时间常数(称为 DTV_SURPLUS,参见 glibc-source/sysdeps/generic/ldsodefs.h),用于为这种混乱保留一些额外的插槽(使用静态 TLS 动态加载库)在多线程程序中).在 Fedora 20 的 glibc 版本中,此值为 14.

There is a compile time constant (called DTV_SURPLUS, see glibc-source/sysdeps/generic/ldsodefs.h) in the glibc's dynamic lib loader for reserving a number of additional slots for such a mess (dynamically loading libs with static TLS in a multithreading program). In the glibc-Version of Fedora 20 this value is 14.

以下是在我的案例中需要 dtv 插槽的第一个库(运行 MATLAB):

Here are the first libs (running MATLAB) that needed dtv slots in my case:

matlabroot/bin/glnxa64/libut.so
/lib64/libstdc++.so.6
/lib64/libpthread.so.0
matlabroot/bin/glnxa64/libunwind.so.8
/lib64/libuuid.so.1
matlabroot/sys/java/jre/glnxa64/jre/lib/amd64/server/libjvm.so
matlabroot/sys/java/jre/glnxa64/jre/lib/amd64/libfontmanager.so
matlabroot/sys/java/jre/glnxa64/jre/lib/amd64/libt2k.so
matlabroot/bin/glnxa64/mkl.so
matlabroot/sys/os/glnxa64/libiomp5.so
/lib64/libasound.so.2
matlabroot/sys/jxbrowser/glnxa64/xulrunner/xulrunner-linux-64/libxul.so
/lib64/libselinux.so.1
/lib64/libpixman-1.so.0
/lib64/libEGL.so.1
/lib64/libGL.so.1
/lib64/libglapi.so.0

是的超过 14 => 太多 => dtv 中没有剩余插槽.这就是错误消息试图告诉我们的,尤其是 mathworks.

Yes more than 14 => too many => no slot left in the dtv. That's what the error message tries to tell us and especially mathworks.

声明:为了不违反 MATLAB 的许可,我没有调试、反编译或反汇编 MATLAB 附带的二进制文件的任何部分.我只调试了 MATLAB 用来动态加载库的 Fedora 20 的免费和开放的 glibc 二进制文件.

For the record: In order not to violate MATLAB's license I didn't debug, decompile or disassemble any part of the binaries shipped with MATLAB. I only debugged the free and open glibc-binaries of Fedora 20 that MATLAB were using to dynamically load the libs.

可以做些什么来解决这个问题?

有 3 个选项:

(一)重建 MATLAB 并且不动态加载这些库(使用 initial-exec tls 模型)改为链接它们(然后链接器可以计算所需的插槽!)

(a) Rebuild MATLAB and do not dynamically load those libs (with initial-exec tls model) instead link against them (then the linker can count the required slots!)

(b)重建这些库并确保它们没有使用 initial-exec tls 模型.

(b) Rebuild those libs and ensure they are NOT using the initial-exec tls model.

(c)重建 glibc 并增加 DTV_SURPLUSglibc/sysdeps/generic/ldsodefs.h

(c) Rebuild glibc and increase DTV_SURPLUS in glibc/sysdeps/generic/ldsodefs.h

显然选项 (a) 和 (b) 只能由 mathworks 完成.

Obviously options (a) and (b) can only be done by mathworks.

对于选项 (c),不需要 MATLAB 源,因此可以在没有 mathworks 的情况下完成.

For option (c) no source of MATLAB is needed and thus can be done without mathworks.

ma​​thworks 的状态如何?

我真的试图向MathWorks 技术支持部门"解释这一点.但我的印象是:他们不了解我.他们关闭了我的支持票,并建议在 2014 年 1 月与技术支持经理进行电话(!)交谈.

I really tried to explain this to the "MathWorks Technical Support Department". But my impression is: they don't understand me. They closed my support ticket and suggested a telephone(!) conversation in January 2014 with a technical support manager.

我会尽力解释这一点,但说实话:我不是很自信.

I'll do my very best to explain this, but to be honest: I'm not very confident.

更新 (2014/01/10):目前 mathworks 正在尝试选项 (b).

Update (2014/01/10): Currently mathworks is trying option (b).

更新 (2014/03/19):对于文件 libiomp5.so,您可以在 mathworks 下载新编译的版本(没有静态 TLS),错误报告 961964.和其他库?那里没有改善.因此,不要对使用doc"获得dlopen:无法加载更多带有静态 TLS 的对象"感到惊讶,例如请参阅错误报告 1003952.

Update (2014/03/19): For the file libiomp5.so you can download a newly compiled version (without static TLS) at mathworks, bug report 961964. And the other libs? No improvement there. So don't be suprised to get "dlopen: cannot load any more object with static TLS" with "doc", e.g. see bug report 1003952.

这篇关于MatLab 错误:无法使用静态 TLS 打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆