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

ERROR: LoadError: InexactError: trunc(Int32, 3381946202) #74

Closed
samuela opened this issue Oct 22, 2020 · 3 comments
Closed

ERROR: LoadError: InexactError: trunc(Int32, 3381946202) #74

samuela opened this issue Oct 22, 2020 · 3 comments

Comments

@samuela
Copy link

samuela commented Oct 22, 2020

What does this error mean? What's going on? There's very little clarity into what went wrong here. I'm assuming it's attempting to serialize an Int64 as Int32.

ERROR: LoadError: InexactError: trunc(Int32, 3381946202)
Stacktrace:
 [1] throw_inexacterror(::Symbol, ::Type{Int32}, ::Int64) at ./boot.jl:558
 [2] checked_trunc_sint at ./boot.jl:580 [inlined]
 [3] toInt32 at ./boot.jl:617 [inlined]
 [4] Int32 at ./boot.jl:707 [inlined]
 [5] bson_doc(::Base.GenericIOBuffer{Array{UInt8,1}}, ::Array{Pair{String,Array{UInt8,1}},1}) at /home/skainswo/.julia/packages/BSON/XAts7/src/write.jl:32
 [6] bson_primitive(::Base.GenericIOBuffer{Array{UInt8,1}}, ::Array{Any,1}) at /home/skainswo/.julia/packages/BSON/XAts7/src/write.jl:37
 [7] bson_pair(::Base.GenericIOBuffer{Array{UInt8,1}}, ::String, ::Array{Any,1}) at /home/skainswo/.julia/packages/BSON/XAts7/src/write.jl:22
 [8] bson_doc(::Base.GenericIOBuffer{Array{UInt8,1}}, ::Array{Pair{String,Array{Any,1}},1}) at /home/skainswo/.julia/packages/BSON/XAts7/src/write.jl:28
 [9] bson_primitive(::Base.GenericIOBuffer{Array{UInt8,1}}, ::Array{Any,1}) at /home/skainswo/.julia/packages/BSON/XAts7/src/write.jl:37
 [10] bson_pair(::Base.GenericIOBuffer{Array{UInt8,1}}, ::Symbol, ::Array{Any,1}) at /home/skainswo/.julia/packages/BSON/XAts7/src/write.jl:22
 [11] bson_doc(::Base.GenericIOBuffer{Array{UInt8,1}}, ::Dict{Symbol,Any}) at /home/skainswo/.julia/packages/BSON/XAts7/src/write.jl:28
 [12] bson_primitive at /home/skainswo/.julia/packages/BSON/XAts7/src/write.jl:36 [inlined]
 [13] bson_pair(::Base.GenericIOBuffer{Array{UInt8,1}}, ::String, ::Dict{Symbol,Any}) at /home/skainswo/.julia/packages/BSON/XAts7/src/write.jl:22
 [14] bson_doc(::Base.GenericIOBuffer{Array{UInt8,1}}, ::Array{Pair{String,Dict{Symbol,Any}},1}) at /home/skainswo/.julia/packages/BSON/XAts7/src/write.jl:28
 [15] bson_primitive(::Base.GenericIOBuffer{Array{UInt8,1}}, ::Array{Any,1}) at /home/skainswo/.julia/packages/BSON/XAts7/src/write.jl:37
 [16] bson_pair(::Base.GenericIOBuffer{Array{UInt8,1}}, ::String, ::Array{Any,1}) at /home/skainswo/.julia/packages/BSON/XAts7/src/write.jl:22
 [17] bson_doc(::Base.GenericIOBuffer{Array{UInt8,1}}, ::Array{Pair{String,Array{Any,1}},1}) at /home/skainswo/.julia/packages/BSON/XAts7/src/write.jl:28
 [18] bson_primitive(::Base.GenericIOBuffer{Array{UInt8,1}}, ::Array{Any,1}) at /home/skainswo/.julia/packages/BSON/XAts7/src/write.jl:37
 [19] bson_pair(::Base.GenericIOBuffer{Array{UInt8,1}}, ::Symbol, ::Array{Any,1}) at /home/skainswo/.julia/packages/BSON/XAts7/src/write.jl:22
 [20] bson_doc(::IOStream, ::Dict{Symbol,Any}) at /home/skainswo/.julia/packages/BSON/XAts7/src/write.jl:28
 [21] bson_primitive(::IOStream, ::Dict{Symbol,Any}) at /home/skainswo/.julia/packages/BSON/XAts7/src/write.jl:36
 [22] bson(::IOStream, ::Dict{String,Dict}) at /home/skainswo/.julia/packages/BSON/XAts7/src/write.jl:81
 [23] write(::IOStream, ::JLSO.JLSOFile) at /home/skainswo/.julia/packages/JLSO/wSVbM/src/file_io.jl:15
 [24] #save#26 at /home/skainswo/.julia/packages/JLSO/wSVbM/src/file_io.jl:75 [inlined]
 [25] save at /home/skainswo/.julia/packages/JLSO/wSVbM/src/file_io.jl:75 [inlined]
 [26] save(::IOStream, ::Pair{Symbol,NamedTuple{(:loss_per_iter, :elapsed_per_iter, :nf_per_iter, :n∇ₓf_per_iter, :n∇ᵤf_per_iter, :policy_params_per_iter, :g_per_iter),Tuple{Array{Float64,1},Array{Float64,1},Array{Float64,1},Array{Float64,1},Array{Float64,1},Array{Float64,2},Array{Float64,2}}}}, ::Vararg{Pair{Symbol,NamedTuple{(:loss_per_iter, :elapsed_per_iter, :nf_per_iter, :n∇ₓf_per_iter, :n∇ᵤf_per_iter, :policy_params_per_iter, :g_per_iter),Tuple{Array{Float64,1},Array{Float64,1},Array{Float64,1},Array{Float64,1},Array{Float64,1},Array{Float64,2},Array{Float64,2}}}},N} where N; kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at /home/skainswo/.julia/packages/JLSO/wSVbM/src/file_io.jl:76
 [27] save at /home/skainswo/.julia/packages/JLSO/wSVbM/src/file_io.jl:76 [inlined]
 [28] #29 at /home/skainswo/.julia/packages/JLSO/wSVbM/src/file_io.jl:78 [inlined]
 [29] open(::JLSO.var"#29#30"{Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},Tuple{Pair{Symbol,NamedTuple{(:loss_per_iter, :elapsed_per_iter, :nf_per_iter, :n∇ₓf_per_iter, :n∇ᵤf_per_iter, :policy_params_per_iter, :g_per_iter),Tuple{Array{Float64,1},Array{Float64,1},Array{Float64,1},Array{Float64,1},Array{Float64,1},Array{Float64,2},Array{Float64,2}}}},Pair{Symbol,NamedTuple{(:loss_per_iter, :elapsed_per_iter, :nf_per_iter, :n∇ₓf_per_iter, :n∇ᵤf_per_iter, :policy_params_per_iter, :g_per_iter),Tuple{Array{Float64,1},Array{Float64,1},Array{Float64,1},Array{Float64,1},Array{Float64,1},Array{Float64,2},Array{Float64,2}}}}}}, ::String, ::Vararg{String,N} where N; kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at ./io.jl:325
 [30] open at ./io.jl:323 [inlined]
 [31] #save#28 at /home/skainswo/.julia/packages/JLSO/wSVbM/src/file_io.jl:78 [inlined]
 [32] save(::String, ::Pair{Symbol,NamedTuple{(:loss_per_iter, :elapsed_per_iter, :nf_per_iter, :n∇ₓf_per_iter, :n∇ᵤf_per_iter, :policy_params_per_iter, :g_per_iter),Tuple{Array{Float64,1},Array{Float64,1},Array{Float64,1},Array{Float64,1},Array{Float64,1},Array{Float64,2},Array{Float64,2}}}}, ::Pair{Symbol,NamedTuple{(:loss_per_iter, :elapsed_per_iter, :nf_per_iter, :n∇ₓf_per_iter, :n∇ᵤf_per_iter, :policy_params_per_iter, :g_per_iter),Tuple{Array{Float64,1},Array{Float64,1},Array{Float64,1},Array{Float64,1},Array{Float64,1},Array{Float64,2},Array{Float64,2}}}}) at /home/skainswo/.julia/packages/JLSO/wSVbM/src/file_io.jl:78
 [33] top-level scope at /home/skainswo/dev/research/julia/odecontrol/difftaichi/electric/run.jl:366
 [34] include(::Function, ::Module, ::String) at ./Base.jl:380
 [35] include(::Module, ::String) at ./Base.jl:368
 [36] exec_options(::Base.JLOptions) at ./client.jl:296
 [37] _start() at ./client.jl:506
in expression starting at /home/skainswo/dev/research/julia/odecontrol/difftaichi/electric/run.jl:366
@samuela
Copy link
Author

samuela commented Oct 22, 2020

julia> trunc(Int32, 3381946202)
ERROR: InexactError: trunc(Int32, 3381946202)
Stacktrace:
 [1] throw_inexacterror(::Symbol, ::Type{Int32}, ::Int64) at ./boot.jl:558
 [2] checked_trunc_sint at ./boot.jl:580 [inlined]
 [3] toInt32 at ./boot.jl:617 [inlined]
 [4] Int32 at ./boot.jl:707 [inlined]
 [5] convert at ./number.jl:7 [inlined]
 [6] trunc(::Type{Int32}, ::Int64) at ./int.jl:594
 [7] top-level scope at REPL[9]:1

julia> trunc(Int64, 3381946202)
3381946202

@rofinn
Copy link
Member

rofinn commented Oct 22, 2020

It means that 3381946202 is too big of a number to fit into a 32-bit integer. The issue you're seeing when saving your object is that the BSON spec has a maximum array size limited by a 32 bit integer. If the serialized object is too large then it'll error. I believe there have been several discussions around adding a julia specific workaround to this problem that aren't supported by the BSON spec.

JuliaIO/BSON.jl#67

A temporary solution we could add to JLSO.jl is to partition the serialized objects before trying to write to the BSON format.

@rofinn
Copy link
Member

rofinn commented Oct 22, 2020

I'm gonna close this in favour of the existing thread on this at #21

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants