# "The applicable method may be too new" - Inference by loading saved BSON Flux model

**URL:** <https://discourse.julialang.org/t/the-applicable-method-may-be-too-new-inference-by-loading-saved-bson-flux-model/33913>\
**Category:** Machine Learning\
**Tags:** question, flux, bson\
**Created:** [January 29, 2020, 2:28am UTC](https://discourse.julialang.org/t/the-applicable-method-may-be-too-new-inference-by-loading-saved-bson-flux-model/33913 "2020-01-29T02:28:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jchen975](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jchen975/32/8994_2.png) [@jchen975](https://discourse.julialang.org/u/jchen975)\
**Post date:** [January 29, 2020, 2:28am UTC](https://discourse.julialang.org/t/the-applicable-method-may-be-too-new-inference-by-loading-saved-bson-flux-model/33913/1 "2020-01-29T02:28:51Z")

</div>

Hi, I was trying to do inference with a previously trained Flux CNN that was saved with BSON with the following:

```julia
38 @load model_name model
39 model = model |> gpu
40 data = data |> gpu
41    
42 println(typeof(model))
43 t = time()
44 predict = model(data)

```

This is the error message I got:

```julia
Chain{Tuple{Conv{2,2,typeof(elu),CuArray{Float32,4,Nothing},CuArray{Float32,1,Nothing}},Conv{2,2,typeof(elu),CuArray{Float32,4,Nothing},CuArray{Float32,1,Nothing}},Conv{2,2,typeof(elu),CuArray{Float32,4,Nothing},CuArray{Float32,1,Nothing}},BSON. __deserialized_types__.var"##913",Dense{typeof(identity),CuArray{Float32,2,Nothing},CuArray{Float32,1,Nothing}}}}
ERROR: MethodError: no method matching (::BSON. __deserialized_types__.var"##913")(::CuArray{Float32,4,Nothing})
The applicable method may be too new: running in world age 27198, while current world is 27199.
Closest candidates are:
  #23(::Any) at D:\Work\Research\work\old\train_options.jl:78 (method too new to be called from this world context.)
Stacktrace:
 [1] applychain(::Tuple{BSON. __deserialized_types__.var"##913",Dense{typeof(identity),CuArray{Float32,2,Nothing},CuArray{Float32,1,Nothing}}}, ::CuArray{Float32,4,Nothing}) at C:\Users\me\.julia\packages\Flux\2i5P1\src\layers\basic.jl:30 (repeats 4 times)
 [2] (::Chain{Tuple{Conv{2,2,typeof(elu),CuArray{Float32,4,Nothing},CuArray{Float32,1,Nothing}},Conv{2,2,typeof(elu),CuArray{Float32,4,Nothing},CuArray{Float32,1,Nothing}},Conv{2,2,typeof(elu),CuArray{Float32,4,Nothing},CuArray{Float32,1,Nothing}},BSON. __deserialized_types__.var"##913",Dense{typeof(identity),CuArray{Float32,2,Nothing},CuArray{Float32,1,Nothing}}}})(::CuArray{Float32,4,Nothing}) at C:\Users\me\.julia\packages\Flux\2i5P1\src\layers\basic.jl:32
 [3] inference(::Array{Float32,4}, ::String, ::Bool) at D:\Work\Research\work\train\inference.jl:44
 [4] main(::Array{String,1}) at D:\Work\Research\work\train\inference.jl:96
 [5] top-level scope at none:0

```

The error is from line 44. The first line of the output is what the `println(typeof(model))` prints. What is “world age”? How do I solve this problem?

On another note, do I have to save Flux models with BSON? Or can I do it with other IO packages like JLD?

---

<div class="post-metadata">

**Author:** ![CarloLucibello](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/carlolucibello/32/3278_2.png) [@CarloLucibello](https://discourse.julialang.org/u/CarloLucibello)\
**Post date:** [March 4, 2020, 11:47am UTC](https://discourse.julialang.org/t/the-applicable-method-may-be-too-new-inference-by-loading-saved-bson-flux-model/33913/2 "2020-03-04T11:47:37Z")

</div>

Hi,  
I just bumped into the same issue. The problem is with loading closures, I reported it in [world age issue in loading closure · Issue #69 · JuliaIO/BSON.jl · GitHub](https://github.com/JuliaIO/BSON.jl/issues/69)

Unfortunately, for storing closures I see no alternatives to BSON.jl
