<div dir="ltr"><div>Thanks a lot for your help!<br></div><div><br></div><div>I think you are completely right about the cause of the problem, but I found another solution that also appears to work. I had CasADi load the IPOPT plugin with <span style="font-size:12.7272720336914px">RTLD_LAZY | </span><span style="font-size:12.7272720336914px">RTLD_LOCAL | RTLD_DEEPBIND passed to dlopen. That way, IPOPT's BLAS won't </span>interfere<span style="font-size:12.7272720336914px"> with MATLAB's BLAS (MATLAB won't see it thanks to </span><span style="font-size:12.7272720336914px">RTLD_LOCAL) and MATLAB's BLAS won't interfere with IPOPT's BLAS (</span><span style="font-size:12.7272720336914px">RTLD_DEEPBIND will ensure that IPOPT's BLAS has priority).</span></div><div><span style="font-size:12.7272720336914px"><br></span></div><div><span style="font-size:12.7272720336914px">Not sure if there are any disadvantages of this approach.</span></div><div><br></div><div>Best regards,</div><div>Joel</div><div><br></div><div><br></div><div><br></div><div class="gmail_extra"><br><div class="gmail_quote">2015-01-14 13:00 GMT+01:00 Tony Kelman <span dir="ltr"><<a href="mailto:kelman@berkeley.edu" target="_blank">kelman@berkeley.edu</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">
<div dir="ltr">
<div style="FONT-SIZE:12pt;FONT-FAMILY:'Calibri';COLOR:#000000">
<div>Matlab’s own copy of BLAS uses 64-bit integers. Ipopt and most other
libraries expect conventional 32-bit integers in BLAS. You need to link Ipopt to
a static-library BLAS to avoid this problem, otherwise there are two
shared-library copies of BLAS opened by the same process using the same function
names but binary-incompatible signatures and bad things happen. You can
alternately tell Matlab to use the same copy of BLAS that you built with Ipopt
by setting BLAS_VERSION environment variables, but this is not well-supported
and could easily slow unrelated linear algebra down if you’re not using an
optimized implementation.</div>
<div> </div>
<div>-Tony</div>
<div> </div>
<div style="FONT-SIZE:small;TEXT-DECORATION:none;FONT-FAMILY:"Calibri";FONT-WEIGHT:normal;COLOR:#000000;FONT-STYLE:normal;DISPLAY:inline">
<div style="FONT:10pt tahoma">
<div> </div>
<div style="BACKGROUND:#f5f5f5">
<div><b>From:</b> <a title="j.a.e.andersson@gmail.com" href="mailto:j.a.e.andersson@gmail.com" target="_blank">Joel Andersson</a> </div>
<div><b>Sent:</b> Wednesday, January 14, 2015 3:40 AM</div>
<div><b>To:</b> <a title="ipopt@list.coin-or.org" href="mailto:ipopt@list.coin-or.org" target="_blank">Ipopt - Mailing list</a> </div>
<div><b>Subject:</b> [Ipopt] IPOPT build causes crash inside
MATLAB</div></div></div>
<div> </div></div>
<div style="FONT-SIZE:small;TEXT-DECORATION:none;FONT-FAMILY:"Calibri";FONT-WEIGHT:normal;COLOR:#000000;FONT-STYLE:normal;DISPLAY:inline"><div><div class="h5">
<div dir="ltr">Hello all,
<div> </div>
<div>I am working on adding a MATLAB front-end to CasADi that will enable
formulating and solving large-scale NLPs with efficient automatic calculation of
Jacobians and Hessians.</div>
<div> </div>
<div>I am experiencing problems of getting our IPOPT plugin to work inside
MATLAB. While it appears to work fine in OS X, I get segfaults in Linux (Ubuntu
14.04, 64-bit, gcc 4.7) with the following stack trace:</div>
<div> </div>
<div>
<div>Stack Trace (from fault):</div>
<div>[ 0] 0x00007f607282eb0c
/usr/local/MATLAB/R2014b/bin/glnxa64/mkl.so+31877900
mkl_blas_cnr_def_xdcopy+00000252</div>
<div>[ 1] 0x00007f6070ca3778
/usr/local/MATLAB/R2014b/bin/glnxa64/mkl.so+02996088
mkl_blas_dcopy+00000200</div>
<div>[ 2] 0x00007f6070b1381c
/usr/local/MATLAB/R2014b/bin/glnxa64/mkl.so+01357852 dcopy+00000080</div>
<div>[ 3]
0x00007f6074f76565
/usr/local/lib/libipopt.so.0+01639781
_ZN5Ipopt11IpBlasDcopyEiPKdiPdi+00000085</div>
<div>[ 4]
0x00007f6074e65762
/usr/local/lib/libipopt.so.0+00522082
_ZN5Ipopt11TNLPAdapter16GetStartingPointENS_8SmartPtrINS_6VectorEEEbS3_bS3_bS3_bS3_b+00001106</div>
<div>[ 5]
0x00007f6074ebdc78
/usr/local/lib/libipopt.so.0+00883832
_ZN5Ipopt15GradientScaling30DetermineScalingParametersImplENS_8SmartPtrIKNS_11VectorSpaceEEES4_S4_NS1_IKNS_11MatrixSpaceEEES7_NS1_IKNS_14SymMatrixSpaceEEERKNS_6MatrixERKNS_6VectorESD_SG_RdRNS1_ISE_EESJ_SJ_+00000232</div></div>
<div>...</div>
<div> </div>
<div>Anyone has any idea of what could be the cause of this or how it can be
resolved? It appears to be related to BLAS which I find perplexing since IPOPT
is not linked to the MEX function, but to a plugin (shared library) which is
loaded dynamically using dlopen(..., RTLD_LAZY | RTLD_LOCAL). I thought that
would provide enough encapsulation to avoid problems like this.</div>
<div> </div>
<div>I tried building IPOPT explicitly avoid MKL blas by setting
"--with-build=BUILD --with-lapack=BUILD":</div>
<div> </div>
<div>../configure --prefix=/usr/local --with-build=BUILD --with-lapack=BUILD
ADD_FFLAGS=-fPIC ADD_CFLAGS=-fPIC ADD_CXXFLAGS=-fPIC<br></div>
<div> </div>
<div>But that doesn't appear to have any effect.<br></div>
<div> </div>
<div>Best regards and thanks in advance,</div>
<div>Joel</div>
<div> </div>
<div>
<div> </div></div></div>
</div></div><p>
</p><hr>
_______________________________________________<br>Ipopt mailing
list<br><a href="mailto:Ipopt@list.coin-or.org" target="_blank">Ipopt@list.coin-or.org</a><br><a href="http://list.coin-or.org/mailman/listinfo/ipopt" target="_blank">http://list.coin-or.org/mailman/listinfo/ipopt</a><br><p></p></div></div></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">-- <br>Joel Andersson, PhD<br>Ptge. Busquets 11-13, atico 3<br>E-08940 Cornella de Llobregat, Spain<br>Home: +34-93-6034011<br>Mobile: +32-486-672874 (Belgium) / +34-63-4408800 (Spain) / +46-707-360512 <br>(Sweden)<br><br></div>
</div></div>