question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

jax.scipy.linalg routines segfault on Mac OS X on scipy 1.2.1 or later but not scipy 1.1.0

See original GitHub issue

I’m not exactly sure why 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 pip install jax jaxlib):

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("Success!")

Output:

$ python -W ignore test.py      
zsh: bus error  python -W ignore test.py

If I roll back to Scipy 1.1.0, everything works:

$ python -W ignore test.py 
Success!

This is a great project by the way–thanks for working on it!

Edit: after further digging, I found the following in the the Scipy 1.2 release notes:

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.

Perhaps this has something to do with it?

Even more edits: yet more digging has revealed scipy/scipy#9751, which hints that this might be caused by a specific (old) version of XCode. I will report back once XCode is upgraded.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
hawkinspcommented, May 2, 2020

#2927 should fix this bug; it requires a new jaxlib, so you can either build from source or we will most likely make a release next week.

1reaction
hawkinspcommented, Apr 30, 2020

I think I’ve figured out what’s going wrong here, and why it’s Mac OS specific.

The problem is that we run out of stack space and crash due to a stack overflow. Mac OS thread stacks default to 512KiB, whereas Linux defaults to 8MiB stacks. (Since these threads are part of a thread pool, you cannot work around this by changing ulimit, it requires code changes.)

I’m not quite sure what the best way to fix this is at the moment but I’ll figure something out.

Read more comments on GitHub >

github_iconTop Results From Across the Web

scipy.linalg.svd — SciPy v1.9.3 Manual
Factorizes the matrix a into two unitary matrices U and Vh , and a 1-D array s of singular values (real, non-negative) such...
Read more >
What I'm doing wrong while installing scipy using pip3 on Mac
Part of the error message is "package 'wheel' is not installed," so trying to directly install a .whl file may not work. –...
Read more >
latest PDF - EasyBuild Documentation
EasyBuild is a software build and installation framework that allows you to manage (scientific) software on High.
Read more >
Untitled
... abrt-java-connector-1.1.0-230b726.tar.gz abrt-java-connector.spec ... platform-python.patch python2.patch python3.patch reboot-in-phase.patch ...
Read more >
Release 2.11.0 - Google Git
Some files in tensorflow/python/training have been moved to tensorflow/python/tracking ... When running on CPU and GPU, a non-optimized XLA kernel is used.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found