I have two computers with intel i9-9900 (new HP dekstop at work + Lenovo home computer), giving the same error on a simple problem – while my laptop (i7) and old work desktop (Dell, Xeon processor?) works fine. Here is the essence of the weird problem:
The incorrect computation of the rank (and SVD…) doesn’t show up for all matrix sizes – for smaller values of m, the problem may disappear.
On my old (Dell, Xeon?) and new (HP, i9-9900 high power) work desktops, I have installed exactly the same Julia packages and package versions with Julia v 1.4.2. The installation of other software may vary, though. The above code works with PyPlot on my old desktop but not on my new desktop.
The Julia packages on my home computer (Lenovo, i9-9900 low power) and my laptop (Microsoft, i7) are probably different, and I think I use Julia v. 1.4.0 on my laptop + Julia v. 1.4.2 on my (new) home computer. The above code works with PyPlot on my laptop (i7), but not with my new (i9) home computer.
The same error shows up if I run the code in VScode.
I understand that some other Julia user had a similar problem on an i9-9900 gaming computer running model fit in the Polynomials package (which is where I, too, came across the problem). To me, it seems like the problem relates to some interaction between LinearAlgebra and PyPlot on some processors…??
Is anyone with an i9-9900 (or other i9 processors) able to recreate this bug?
It is not 100% clear to me what I should put in a function. You mean to put rang in a function, or both plot and rang?
It sure won’t help to just put rand in a function – the whole problem showed up because of an error message in the fit function of Polynomials.jl (fit uses pinv, and hence crashes because of a problem with svd).
I mean put the entirety of your example in a function. Your screen shot makes it looks like your are doing this from the REPL.
I always use PyPlot directly. Since the Plots package is doing intermediate processing and is macro-heavy (I think) and then hands it off to the backend, i was wondering if the plots processing was having a side-effect.
That was the reason for also suggesting to put the whole example in a single function, since that will force all the variables to be local in scope and get everything out of the global environment.
also, it’s usually best to create a self-contained function and then insert it into the discussion in text as a code block using ``` so people can try it out easily instead of having to type it in from a screen shot, e.g.
using PyPlot
using LinearAlgebra
function test1()
m = 15
...
end
etc...
I’m not sure why 2 figures are plotted, or more precisely: I’m not sure why the first figure is plotted. If I skip the display(fig) statement, I get the following:
as i said i don’t know plots at all, so i’m not sure why you are seeing 2 plots.
this is a very odd problem, and if it’s reproducible, which it appears to be, it seems like a serious bug of some sort, and probably not a CPU related problem.
I know it is dangerous to generalize based on testing on 4 computers. But it appears like:
On all machines (? – have only tested on private i7 laptop + private i9 PC), it looks like the pyplot backend prints two plots, while only one is expected.
On both i9 processor machines I have tested, the rank() function computes the wrong result for certain matrices when I use the pyplot() backend prior to the rank() command. Non-i9 machines compute the correct value with the rank() function.
Using the gr() backend for Plots, only one plot is printed (as expected, but perhaps in an unexpected sequence). AND, issuing the plot command prior to calling the rank() function does not mess up the rank result.
OK – why don’t I switch to the gr() backend? After all, the gr() backend tends to give somewhat crisper plots, which is good. I’m still holding back to switch to gr() because:
The gr() backend has poorer support for LaTeX commands than pyplot(). I really look forward to when the JuliaCon 2020 announced extended support for LaTeX in GR is implemented in the backend.
The gr() backend supports fewer plot keywords. Hopefully this will also improve.
In any way, I hope someone can do a more thorough check on the problems with the pyplot() backend in relation to the LinearAlgebra package.
I’m using OpenBLAS. I have not installed MKL.jl; just using the standard installation of Julia.
I tried to install MKL.jl on my work desktop a couple of days ago in the hope that this might solve the problem. That lead to some “Terminal error” or something, and just stopped the Julia session, so I removed Julia completely with all packages, and reinstalled it.
Have you tried to set the threads number according to your actual cpu cores?
core i9-9900 has 8 physical cores. So, please check the following command:
I have now removed every trace of Julia 1.4.2 + Jupyter + conda/Python from my i9-9900 work desktop computer, downloaded and installed Julia 1.5.0 + added packages Plots and PyPlot. No other packages. Still does not work. In Jupyterlab:
using Plots; pyplot()
using LinearAlgebra
#
function test1()
m = 15
A = rand(m,5)
B = rand(m,5)
println("rank(A):", rank(A))
plot(sin,size=(100,100)) |> display
println("rank(B):", rank(B))
println("rank(B):",rank(B))
end
#
test1()
with REPL response:
julia> using Plots; pyplot()
Plots.PyPlotBackend()
julia> using LinearAlgebra
rank(A):5
rank(B):0
rank(B):5