Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Precompilation fails due to criptic "Matrixs contains NaN" bug #288

Closed
Datseris opened this issue Nov 21, 2023 · 11 comments
Closed

Precompilation fails due to criptic "Matrixs contains NaN" bug #288

Datseris opened this issue Nov 21, 2023 · 11 comments
Labels
bug Something isn't working

Comments

@Datseris
Copy link

I had this problem before, so I made sure that everything is in order.

  1. I did a full wipe of all .julia and started again.
  2. I have windows 10, with julia version 1.9.1
  3. I added part of the DiffEq stack, and I got the latest stable versions,
  [961ee093] ModelingToolkit v8.73.1
  [1dea7af3] OrdinaryDiffEq v6.59.2

and in my manifest

 [2b5f629d] DiffEqBase v6.140.1
  [8913a72c] NonlinearSolve v2.8.1
  [0bca4576] SciMLBase v2.8.2

However, precompilation of NonlinearSolve, and hence all of my DiffEq stack, fails with:

ERROR: LoadError: ArgumentError: matrix contains Infs or NaNs      
Stacktrace:
  [1] chkfinite
    @ C:\Users\gd419\.julia\juliaup\julia-1.9.1+0.x64.w64.mingw32\share\julia\stdlib\v1.9\LinearAlgebra\src\lapack.jl:86 [inlined]    
  [2] getrf!(A::Matrix{Float32})
    @ LinearAlgebra.LAPACK C:\Users\gd419\.julia\juliaup\julia-1.9.1+0.x64.w64.mingw32\share\julia\stdlib\v1.9\LinearAlgebra\src\lapack.jl:559
  [3] #lu!#170
    @ C:\Users\gd419\.julia\juliaup\julia-1.9.1+0.x64.w64.mingw32\share\julia\stdlib\v1.9\LinearAlgebra\src\lu.jl:81 [inlined]        
  [4] lu!
    @ C:\Users\gd419\.julia\juliaup\julia-1.9.1+0.x64.w64.mingw32\share\julia\stdlib\v1.9\LinearAlgebra\src\lu.jl:80 [inlined]        
  [5] lu!(A::LinearAlgebra.Symmetric{Float32, Matrix{Float32}}, pivot::LinearAlgebra.RowMaximum; check::Bool)
    @ LinearAlgebra C:\Users\gd419\.julia\juliaup\julia-1.9.1+0.x64.w64.mingw32\share\julia\stdlib\v1.9\LinearAlgebra\src\lu.jl:87    
  [6] lu!
    @ C:\Users\gd419\.julia\juliaup\julia-1.9.1+0.x64.w64.mingw32\share\julia\stdlib\v1.9\LinearAlgebra\src\lu.jl:85 [inlined]        
  [7] #lu#176
    @ C:\Users\gd419\.julia\juliaup\julia-1.9.1+0.x64.w64.mingw32\share\julia\stdlib\v1.9\LinearAlgebra\src\lu.jl:299 [inlined]       
  [8] lu (repeats 2 times)
    @ C:\Users\gd419\.julia\juliaup\julia-1.9.1+0.x64.w64.mingw32\share\julia\stdlib\v1.9\LinearAlgebra\src\lu.jl:298 [inlined]       
  [9] lu_instance
    @ C:\Users\gd419\.julia\packages\ArrayInterface\KwW6K\src\ArrayInterface.jl:617 [inlined]
 [10] init_cacheval
    @ C:\Users\gd419\.julia\packages\LinearSolve\binjx\src\factorization.jl:106 [inlined]
 [11] #init#3
    @ C:\Users\gd419\.julia\packages\LinearSolve\binjx\src\common.jl:165 [inlined]
 [12] __setup_linsolve(A::LinearAlgebra.Symmetric{Float32, Matrix{Float32}}, b::Vector{Float32}, u::Vector{Float32}, p::Float32, alg::NonlinearSolve.LevenbergMarquardt{nothing, ADTypes.AutoForwardDiff{nothing, ForwardDiff.Tag{NonlinearSolve.NonlinearSolveTag, Float32}}, Float64, LinearSolve.LUFactorization{LinearAlgebra.RowMaximum}, 
typeof(NonlinearSolve.DEFAULT_PRECS)})
    @ NonlinearSolve C:\Users\gd419\.julia\packages\NonlinearSolve\1iEv0\src\jacobian.jl:132
 [13] jacobian_caches(alg::NonlinearSolve.LevenbergMarquardt{nothing, ADTypes.AutoForwardDiff{nothing, ForwardDiff.Tag{NonlinearSolve.NonlinearSolveTag, Float32}}, Float64, LinearSolve.LUFactorization{LinearAlgebra.RowMaximum}, typeof(NonlinearSolve.DEFAULT_PRECS)}, f::SciMLBase.NonlinearFunction{false, SciMLBase.FullSpecialize, NonlinearSolve.var"#129#140", LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, 
Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED_NO_TIME), Nothing, Nothing, Nothing}, u::Vector{Float32}, p::Float32, ::Val{false}; linsolve_kwargs::NamedTuple{(), Tuple{}}, lininit::Val{true}, linsolve_with_JᵀJ::Val{true})
    @ NonlinearSolve C:\Users\gd419\.julia\packages\NonlinearSolve\1iEv0\src\jacobian.jl:115
 [14] jacobian_caches
    @ C:\Users\gd419\.julia\packages\NonlinearSolve\1iEv0\src\jacobian.jl:52 [inlined]
 [15] __init(::SciMLBase.NonlinearLeastSquaresProblem{Vector{Float32}, false, Float32, SciMLBase.NonlinearFunction{false, SciMLBase.FullSpecialize, NonlinearSolve.var"#129#140", LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, 
Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED_NO_TIME), Nothing, Nothing, Nothing}, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}}, ::NonlinearSolve.LevenbergMarquardt{nothing, Nothing, Float64, LinearSolve.LUFactorization{LinearAlgebra.RowMaximum}, typeof(NonlinearSolve.DEFAULT_PRECS)}; alias_u0::Bool, maxiters::Int64, abstol::Float64, reltol::Nothing, termination_condition::Nothing, internalnorm::typeof(DiffEqBase.NONLINEARSOLVE_DEFAULT_NORM), linsolve_kwargs::NamedTuple{(), Tuple{}}, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ NonlinearSolve C:\Users\gd419\.julia\packages\NonlinearSolve\1iEv0\src\levenberg.jl:177
 [16] __init
    @ C:\Users\gd419\.julia\packages\NonlinearSolve\1iEv0\src\levenberg.jl:164 [inlined]
 [17] #init_call#30
    @ C:\Users\gd419\.julia\packages\DiffEqBase\xlu8p\src\solve.jl:485 [inlined]
 [18] init_call
    @ C:\Users\gd419\.julia\packages\DiffEqBase\xlu8p\src\solve.jl:459 [inlined]
 [19] #init_up#33
    @ C:\Users\gd419\.julia\packages\DiffEqBase\xlu8p\src\solve.jl:510 [inlined]
 [20] init_up
    @ C:\Users\gd419\.julia\packages\DiffEqBase\xlu8p\src\solve.jl:505 [inlined]
 [21] #init#31
    @ C:\Users\gd419\.julia\packages\DiffEqBase\xlu8p\src\solve.jl:498 [inlined]
 [22] init
    @ C:\Users\gd419\.julia\packages\DiffEqBase\xlu8p\src\solve.jl:489 [inlined]
 [23] __solve(::SciMLBase.NonlinearLeastSquaresProblem{Vector{Float32}, false, Float32, SciMLBase.NonlinearFunction{false, SciMLBase.FullSpecialize, NonlinearSolve.var"#129#140", LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED_NO_TIME), Nothing, Nothing, Nothing}, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}}, ::NonlinearSolve.LevenbergMarquardt{nothing, Nothing, Float64, LinearSolve.LUFactorization{LinearAlgebra.RowMaximum}, typeof(NonlinearSolve.DEFAULT_PRECS)}; kwargs::Base.Pairs{Symbol, Float64, Tuple{Symbol}, NamedTuple{(:abstol,), Tuple{Float64}}})
    @ NonlinearSolve C:\Users\gd419\.julia\packages\NonlinearSolve\1iEv0\src\NonlinearSolve.jl:52
 [24] __solve
    @ C:\Users\gd419\.julia\packages\NonlinearSolve\1iEv0\src\NonlinearSolve.jl:50 [inlined]
 [25] #solve_call#34
    @ C:\Users\gd419\.julia\packages\DiffEqBase\xlu8p\src\solve.jl:557 [inlined]
 [26] solve_call
    @ C:\Users\gd419\.julia\packages\DiffEqBase\xlu8p\src\solve.jl:523 [inlined]
 [27] #solve_up#42
    @ C:\Users\gd419\.julia\packages\DiffEqBase\xlu8p\src\solve.jl:998 [inlined]
 [28] solve_up
    @ C:\Users\gd419\.julia\packages\DiffEqBase\xlu8p\src\solve.jl:992 [inlined]
 [29] #solve#40
    @ C:\Users\gd419\.julia\packages\DiffEqBase\xlu8p\src\solve.jl:929 [inlined]
 [30] macro expansion
    @ C:\Users\gd419\.julia\packages\NonlinearSolve\1iEv0\src\NonlinearSolve.jl:141 [inlined]
 [31] macro expansion
    @ C:\Users\gd419\.julia\packages\PrecompileTools\kmH5L\src\workloads.jl:78 [inlined]
 [32] macro expansion
    @ C:\Users\gd419\.julia\packages\NonlinearSolve\1iEv0\src\NonlinearSolve.jl:136 [inlined]
 [33] top-level scope
    @ C:\Users\gd419\.julia\packages\PrecompileTools\kmH5L\src\workloads.jl:140 [inlined]
 [34] top-level scope
    @ C:\Users\gd419\.julia\packages\NonlinearSolve\1iEv0\src\NonlinearSolve.jl:0
 [35] include
    @ .\Base.jl:457 [inlined]
 [36] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt128}}, source::String)
    @ Base .\loading.jl:2045
 [37] top-level scope
    @ stdin:3
in expression starting at C:\Users\gd419\.julia\packages\NonlinearSolve\1iEv0\src\NonlinearSolve.jl:1
in expression starting at stdin:3
ERROR: LoadError: Failed to precompile NonlinearSolve [8913a72c-1f9b-4ce2-8d82-65094dcecaec] to "C:\\Users\\gd419\\.julia\\compiled\\v1.9\\NonlinearSolve\\jl_83FF.tmp".
@Datseris Datseris added the bug Something isn't working label Nov 21, 2023
@ErikQQY
Copy link
Member

ErikQQY commented Nov 22, 2023

Same here, I was developing BoundaryValueDiffEq.jl in julia 1.9.0, precompiling throws matrix contains Infs or Nans error.

@ErikQQY
Copy link
Member

ErikQQY commented Nov 22, 2023

Precompilation in Julia 1.10 is working fine.

@Datseris
Copy link
Author

Julia 1.10 is not released yet so that's not a solution for me. I want to use these packages for my day work...

@ChrisRackauckas
Copy link
Member

What version of ArrayInterface.jl?

@Datseris
Copy link
Author

For me it is v7.5.1.

@ChrisRackauckas
Copy link
Member

If you patch in:

using LinearAlgebra

function NonlinearSolve.LinearSolve.ArrayInterface.lu_instance(A::Symmetric{T}) where {T}
    noUnitT = typeof(zero(T))
    luT = LinearAlgebra.lutype(noUnitT)
    ipiv = Vector{LinearAlgebra.BlasInt}(undef, 0)
    info = zero(LinearAlgebra.BlasInt)
    return LU{luT}(similar(A, 0, 0), ipiv, info)
end

it goes away?

@ChrisRackauckas
Copy link
Member

Should be solved by the latest ArrayInterface JuliaArrays/ArrayInterface.jl#424

@Datseris
Copy link
Author

I've updated to Julia 1.10. Then compilation worked with ArrayInterface 7.5. Then, I updated to 7.6. Now precompilation does not work anymore again :( Error is:

ERROR: LoadError: Failed to precompile NonlinearSolve [8913a72c-1f9b-4ce2-8d82-65094dcecaec] to "C:\\Users\\gd419\\.julia\\compiled\\v1.10\\NonlinearSolve\\jl_4A22.tmp".
Stacktrace:
  [1] error(s::String)
    @ Base .\error.jl:35
  [2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IO, internal_stdout::IO, keep_loaded_modules::Bool)
    @ Base .\loading.jl:2462
  [3] compilecache
    @ Base .\loading.jl:2334 [inlined]
  [4] (::Base.var"#968#969"{Base.PkgId})()
    @ Base .\loading.jl:1968
  [5] mkpidlock(f::Base.var"#968#969"{Base.PkgId}, at::String, pid::Int32; kwopts::@Kwargs{stale_age::Int64, wait::Bool})
    @ FileWatching.Pidfile C:\Users\gd419\.julia\juliaup\julia-1.10.0-rc1+0.x64.w64.mingw32\share\julia\stdlib\v1.10\FileWatching\src\pidfile.jl:93
  [6] #mkpidlock#6
    @ FileWatching.Pidfile C:\Users\gd419\.julia\juliaup\julia-1.10.0-rc1+0.x64.w64.mingw32\share\julia\stdlib\v1.10\FileWatching\src\pidfile.jl:88 [inlined]
  [7] trymkpidlock(::Function, ::Vararg{Any}; kwargs::@Kwargs{stale_age::Int64})
    @ FileWatching.Pidfile C:\Users\gd419\.julia\juliaup\julia-1.10.0-rc1+0.x64.w64.mingw32\share\julia\stdlib\v1.10\FileWatching\src\pidfile.jl:111
  [8] #invokelatest#2
    @ Base .\essentials.jl:889 [inlined]
  [9] invokelatest
    @ Base .\essentials.jl:884 [inlined]
 [10] maybe_cachefile_lock(f::Base.var"#968#969"{Base.PkgId}, pkg::Base.PkgId, srcpath::String; stale_age::Int64)
    @ Base .\loading.jl:2977
 [11] maybe_cachefile_lock
    @ Base .\loading.jl:2974 [inlined]
 [12] _require(pkg::Base.PkgId, env::String)
    @ Base .\loading.jl:1964
 [13] __require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base .\loading.jl:1806
 [14] #invoke_in_world#3
    @ Base .\essentials.jl:921 [inlined]
 [15] invoke_in_world
    @ Base .\essentials.jl:918 [inlined]
 [16] _require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base .\loading.jl:1797
 [17] macro expansion
    @ Base .\loading.jl:1784 [inlined]
 [18] macro expansion
    @ Base .\lock.jl:267 [inlined]
 [19] __require(into::Module, mod::Symbol)
    @ Base .\loading.jl:1747
 [20] #invoke_in_world#3
    @ Base .\essentials.jl:921 [inlined]
 [21] invoke_in_world
    @ Base .\essentials.jl:918 [inlined]
 [22] require(into::Module, mod::Symbol)
    @ Base .\loading.jl:1740
 [23] include
    @ Base .\Base.jl:489 [inlined]
 [24] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt128}}, source::String)
    @ Base .\loading.jl:2216
 [25] top-level scope
    @ stdin:3
in expression starting at C:\Users\gd419\.julia\packages\OrdinaryDiffEq\wz2EI\src\OrdinaryDiffEq.jl:1
in expression starting at stdin:3

@Datseris
Copy link
Author

Julia1.9 and ArrayInterface 7.6 also do not precompile... :(

@ChrisRackauckas
Copy link
Member

7.6.1?

@Datseris
Copy link
Author

Yeeees!!! It works now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants