Add SciPy and ATLAS post.
[blog.git] / posts / SciPy_and_ATLAS.mdwn
diff --git a/posts/SciPy_and_ATLAS.mdwn b/posts/SciPy_and_ATLAS.mdwn
new file mode 100644 (file)
index 0000000..1ecbecb
--- /dev/null
@@ -0,0 +1,56 @@
+I was suprised the the other day by a [SciPy][]-linking issue:
+
+    $ python -c 'import scipy.linalg'
+    Traceback (most recent call last):
+      File "<string>", line 1, in <module>
+      File "/usr/lib/python2.7/site-packages/scipy/linalg/__init__.py", line 9, in <module>
+        from basic import *
+      File "/usr/lib/python2.7/site-packages/scipy/linalg/basic.py", line 14, in <module>
+        from lapack import get_lapack_funcs
+      File "/usr/lib/python2.7/site-packages/scipy/linalg/lapack.py", line 15, in <module>
+        from scipy.linalg import clapack
+    ImportError: /usr/lib/python2.7/site-packages/scipy/linalg/clapack.so: undefined symbol: clapack_sgesv
+
+Searching around, it turns out there have been [problems like
+this][129524] for a while, and it's flared up [again][vinyals]
+recently.  There's a [new Gentoo bug][371099] tracking the most recent
+issues.  In general, [NumPy][]/[SciPy][] seems to be picky about the
+particular [BLAS][] implementation you're using, and you'll get
+problems like the above if you're using the reference implementations
+of BLAS and [LAPACK][].
+
+    $ for x in blas cblas lapack; do eselect $x list; done                          
+    Installed BLAS for library directory lib
+      [1]   reference *
+    Installed CBLAS for library directory lib
+      [1]   gsl
+      [2]   reference *
+    Installed LAPACK for library directory lib
+      [1]   reference *
+
+You can fix the problem by installing and selecting the [ATLAS][]
+libraries
+
+    $ sudo emerge -av blas-atlas lapack-atlas
+    $ for x in blas cblas lapack; do sudo eselect $x atlas; done
+
+after which you should re-install any packages that may need to be relinked.
+
+    $ sudo emerge -av numpy scipy
+
+Now you can import the linear algebra module without crashing:
+
+    $ python -c 'import scipy.linalg'
+
+
+[SciPy]: http://www.scipy.org/
+[129524]: https://bugs.gentoo.org/show_bug.cgi?id=129524
+[vinyals]: http://archives.gentoo.org/gentoo-science/msg_83c0a72f758099201944bdccd401603a.xml
+[371099]: https://bugs.gentoo.org/show_bug.cgi?id=371099
+[NumPy]: http://numpy.scipy.org/
+[BLAS]: http://www.netlib.org/blas/
+[LAPACK]: http://www.netlib.org/lapack/
+[ATLAS]: http://math-atlas.sourceforge.net/
+
+
+[[!tag tags/linux]]