Stack overflow when solving a large system using Julia

I am trying to solve a random linear system with a large square system matrix using Octave and Julia. Since the syntax of Octave and Julia is pretty similar, I run the following code in both the Octave shell and the Julia shell:

N = 5000; A = rand(N, N); b = rand(N, 1); x = A\b; r = norm(A*x - b)/norm(b) 

An octave returns r in the neighborhood of 1e-12. On the other hand, Julia returns an error:

 ERROR: stack overflow in getrf! at linalg/lapack.jl:342 in LU at linalg/factorization.jl:134 in \ at linalg/dense.jl:518 

The backslash operator works in Julia for small systems (e.g. 10 x 10), however a 50 x 50 system already gives an error. As far as I know, Octave and Julia use BLAS and LAPACK, so I'm pretty confused why Julia cannot complete this task. Can someone please tell me how can I fix this?

System Information

  • Linux Mint 13 KDE, 64bit
  • Installed LLVM 3.2 and Clang 3.2 from PPA: ppa: kxstudio-team / builds
  • Compiled Julia 0.2.0-2429.rb0a9ea79 from the source

EDIT

Now the problem is resolved, since OpenBLAS 0.2.7 is missing. When recompiling Julia, make sure that Julia either uses the system version of OpenBLAS> = 0.2.7, or that Julia internally compiles her own version of OpenBLAS> = 0.2.7.

+4
source share
2 answers

As I mentioned in the release ( https://github.com/JuliaLang/julia/issues/3630 ), this is most likely the same threadblas thread error, as discussed at https://github.com/xianyi/ OpenBLAS / issues / 221 .

There is a preliminary fix for the openblas development branch, which sets a larger stack size.

Currently do blas_set_num_threads(1) .

+4
source

Now that the new version of OpenBLAS: 0.2.7 is not available, I reassembled Julia. Unfortunately, that didn’t mean anything, since Julia still uses OpenBLAS 0.2.6. However, you can use the system version of OpenBLAS when compiling Julia, instead of letting Julia download the version and compile it yourself. So I did Julia 0.2.7 instead of 0.2.6, and now the problem I am facing is resolved. More stack overflows.

+1
source

Source: https://habr.com/ru/post/1489808/


All Articles