<p dir="auto">maybe related to <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="413474603" data-permission-text="Title is private" data-url="https://github.com/google/jax/issues/432" data-hovercard-type="issue" data-hovercard-url="/google/jax/issues/432/hovercard" href="https://github.com/google/jax/issues/432">#432</a>.</p>
<h1 dir="auto">example code</h1>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import jax.numpy as np

N = 80
np.linalg.inv(np.eye(N))"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">jax</span>.<span class="pl-s1">numpy</span> <span class="pl-k">as</span> <span class="pl-s1">np</span>

<span class="pl-v">N</span> <span class="pl-c1">=</span> <span class="pl-c1">80</span>
<span class="pl-s1">np</span>.<span class="pl-s1">linalg</span>.<span class="pl-en">inv</span>(<span class="pl-s1">np</span>.<span class="pl-en">eye</span>(<span class="pl-v">N</span>))</pre></div>
<p dir="auto">output:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="/path/to/project/.venv/lib/python3.7/site-packages/jax/lib/xla_bridge.py:120: UserWarning: No GPU/TPU found, falling back to CPU.
  warnings.warn('No GPU/TPU found, falling back to CPU.')
zsh: bus error  python -m misc.jax"><pre class="notranslate"><code class="notranslate">/path/to/project/.venv/lib/python3.7/site-packages/jax/lib/xla_bridge.py:120: UserWarning: No GPU/TPU found, falling back to CPU.
  warnings.warn('No GPU/TPU found, falling back to CPU.')
zsh: bus error  python -m misc.jax
</code></pre></div>
<p dir="auto">If N is smaller than 80, it works correctly on my machine.</p>
<h1 dir="auto">my environment</h1>
<p dir="auto">macOS 10.14.6<br>
Python 3.7.0 (pyenv)</p>
<p dir="auto">jax 0.1.55<br>
jaxlib 0.1.37<br>
numpy 1.17.4<br>
scipy 1.3.3</p>
<p dir="auto">I'm not exactly sure <em>why</em> this happens, being unfamiliar with the internal architecture, but on MacOS with Python 3.6.8, the following code segfaults if scipy 1.2.1 is installed (the version that comes by default when you <code class="notranslate">pip install jax jaxlib</code>):</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import jax.random as random
import jax.scipy.linalg as linalg

key = random.PRNGKey(42)
# For some reason, matrices smaller than (50, 50) or so do not trigger segfaults
X = random.normal(key, (500, 500))
A = X @ X.T  # Drawn from standard Wishart distribution
linalg.cholesky(A)
print(&quot;Success!&quot;)"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">jax</span>.<span class="pl-s1">random</span> <span class="pl-k">as</span> <span class="pl-s1">random</span>
<span class="pl-k">import</span> <span class="pl-s1">jax</span>.<span class="pl-s1">scipy</span>.<span class="pl-s1">linalg</span> <span class="pl-k">as</span> <span class="pl-s1">linalg</span>

<span class="pl-s1">key</span> <span class="pl-c1">=</span> <span class="pl-s1">random</span>.<span class="pl-v">PRNGKey</span>(<span class="pl-c1">42</span>)
<span class="pl-c"># For some reason, matrices smaller than (50, 50) or so do not trigger segfaults</span>
<span class="pl-v">X</span> <span class="pl-c1">=</span> <span class="pl-s1">random</span>.<span class="pl-en">normal</span>(<span class="pl-s1">key</span>, (<span class="pl-c1">500</span>, <span class="pl-c1">500</span>))
<span class="pl-v">A</span> <span class="pl-c1">=</span> <span class="pl-v">X</span> @ <span class="pl-v">X</span>.<span class="pl-v">T</span>  <span class="pl-c"># Drawn from standard Wishart distribution</span>
<span class="pl-s1">linalg</span>.<span class="pl-en">cholesky</span>(<span class="pl-v">A</span>)
<span class="pl-en">print</span>(<span class="pl-s">"Success!"</span>)</pre></div>
<p dir="auto">Output:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ python -W ignore test.py      
zsh: bus error  python -W ignore test.py"><pre class="notranslate"><code class="notranslate">$ python -W ignore test.py      
zsh: bus error  python -W ignore test.py
</code></pre></div>
<p dir="auto">If I roll back to Scipy 1.1.0, everything works:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ python -W ignore test.py 
Success!"><pre class="notranslate"><code class="notranslate">$ python -W ignore test.py 
Success!
</code></pre></div>
<p dir="auto">This is a great project by the way--thanks for working on it!</p>
<p dir="auto">Edit: after further digging, I found the following in the the Scipy 1.2 release notes:</p>
<blockquote>
<p dir="auto">scipy.linalg.lapack now exposes the LAPACK routines using the Rectangular Full Packed storage (RFP) for upper triangular, lower triangular, symmetric, or Hermitian matrices; the upper trapezoidal fat matrix RZ decomposition routines are now available as well.</p>
</blockquote>
<p dir="auto">Perhaps this has something to do with it?</p>
<p dir="auto">Even more edits: yet more digging has revealed <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="406164520" data-permission-text="Title is private" data-url="https://github.com/scipy/scipy/issues/9751" data-hovercard-type="issue" data-hovercard-url="/scipy/scipy/issues/9751/hovercard" href="https://github.com/scipy/scipy/issues/9751">scipy/scipy#9751</a>, which hints that this might be caused by a specific (old) version of XCode. I will report back once XCode is upgraded.</p>