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

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

问题描述

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

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. 如何使用由以下人员提供的BLAS库MATLAB吗?
  2. http://www.mathworks.de/de/help/matlab/matlab_external/calling-lapack-and-blas-functions-from-mex-files.html
  1. How do I use the BLAS library provided by 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.

直到现在,数学工作的唯一解决方法是先通过尽早使用它们来加载重要的(!)库(他们建议在启动文件中放入"ones(10)* ones(10);").我最好不要对这种解决方案策略"发表评论.

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

自从R2013b(8.2.0.701)和Linux x86_64起,我的经验是:不要使用"doc"(图形帮助系统)!我认为此doc-utility(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年, 目前可在阿卡迪亚

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的动态lib加载程序中有一个编译时间常数(称为DTV_SURPLUS,请参见glibc-source/sysdeps/generic/ldsodefs.h),用于为此类混乱情况保留许多其他插槽(使用静态TLS动态加载libs)在多线程程序中).在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个选项:

(a) 重建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_SURPLUS glibc/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.

mathworks的状态是什么?

我真的试图向"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 错误报告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天全站免登陆