theogf / ParticleFlow_Exp

3 stars 1 forks source link

LoadError: MethodError: no method matching randn #13

Closed fela closed 4 years ago

fela commented 4 years ago

Currently running avi/run_gaussians.jl causes

[ Info: Running ADVI
ERROR: LoadError: MethodError: no method matching randn(::Random._GLOBAL_RNG, ::Type{ReverseDiff.TrackedReal{Float64,Float64,ReverseDiff.TrackedArray{Float64,Float64,1,Array{Float64,1},Array{Float64,1}}}})
Closest candidates are:
  randn(::AbstractRNG, ::Type{T}, ::Tuple{Vararg{Int64,N}} where N) where T at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.5/Random/src/normal.jl:201
  randn(::AbstractRNG, ::Type{T}, ::Integer, ::Integer...) where T at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.5/Random/src/normal.jl:204
  randn(::AbstractRNG) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.5/Random/src/normal.jl:38
  ...
Stacktrace:
 [1] randn!(::Random._GLOBAL_RNG, ::Array{ReverseDiff.TrackedReal{Float64,Float64,ReverseDiff.TrackedArray{Float64,Float64,1,Array{Float64,1},Array{Float64,1}}},1}) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.5/Random/src/normal.jl:178
 [2] randn at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.5/Random/src/normal.jl:204 [inlined]
 [3] adapt_randn at /home/fela/.julia/packages/DistributionsAD/S8e71/src/common.jl:52 [inlined]
 [4] rand(::Random._GLOBAL_RNG, ::TuringDenseMvNormal{ReverseDiff.TrackedArray{Float64,Float64,1,Array{Float64,1},Array{Float64,1}},Cholesky{ReverseDiff.TrackedReal{Float64,Float64,Nothing},Array{ReverseDiff.TrackedReal{Float64,Float64,Nothing},2}}}) at /home/fela/.julia/packages/DistributionsAD/S8e71/src/multivariate.jl:103
 [5] forward at /home/fela/.julia/packages/Bijectors/98OWP/src/transformed_distribution.jl:241 [inlined]
 [6] (::ELBO)(::Random._GLOBAL_RNG, ::ADVI{ReverseDiffAD{false}}, ::TransformedDistribution{TuringDenseMvNormal{ReverseDiff.TrackedArray{Float64,Float64,1,Array{Float64,1},Array{Float64,1}},Cholesky{ReverseDiff.TrackedReal{Float64,Float64,Nothing},Array{ReverseDiff.TrackedReal{Float64,Float64,Nothing},2}}},Identity{1},Multivariate}, ::var"#logπ_gauss#6"{MvNormal{Float64,PDMats.PDiagMat{Float64,Array{Float64,1}},Array{Float64,1}}}, ::Int64) at /home/fela/tmp/ParticleFlow_Exp/julia/dev/AdvancedVI/src/advi.jl:87
 [7] #_#27 at /home/fela/tmp/ParticleFlow_Exp/julia/dev/AdvancedVI/src/objectives.jl:6 [inlined]
 [8] ELBO at /home/fela/tmp/ParticleFlow_Exp/julia/dev/AdvancedVI/src/objectives.jl:6 [inlined]
 [9] (::AdvancedVI.var"#f#75"{ELBO,ADVI{ReverseDiffAD{false}},TransformedDistribution{TuringDenseMvNormal{Array{Float64,1},Cholesky{Float64,Array{Float64,2}}},Identity{1},Multivariate},var"#logπ_gauss#6"{MvNormal{Float64,PDMats.PDiagMat{Float64,Array{Float64,1}},Array{Float64,1}}},Tuple{Int64}})(::ReverseDiff.TrackedArray{Float64,Float64,1,Array{Float64,1},Array{Float64,1}}) at /home/fela/tmp/ParticleFlow_Exp/julia/dev/AdvancedVI/src/AdvancedVI.jl:73
 [10] ReverseDiff.GradientTape(::AdvancedVI.var"#f#75"{ELBO,ADVI{ReverseDiffAD{false}},TransformedDistribution{TuringDenseMvNormal{Array{Float64,1},Cholesky{Float64,Array{Float64,2}}},Identity{1},Multivariate},var"#logπ_gauss#6"{MvNormal{Float64,PDMats.PDiagMat{Float64,Array{Float64,1}},Array{Float64,1}}},Tuple{Int64}}, ::Array{Float64,1}, ::ReverseDiff.GradientConfig{ReverseDiff.TrackedArray{Float64,Float64,1,Array{Float64,1},Array{Float64,1}}}) at /home/fela/.julia/packages/ReverseDiff/Thhqg/src/api/tape.jl:199
 [11] ReverseDiff.GradientTape(::Function, ::Array{Float64,1}) at /home/fela/.julia/packages/ReverseDiff/Thhqg/src/api/tape.jl:198
 [12] tape at /home/fela/tmp/ParticleFlow_Exp/julia/dev/AdvancedVI/src/compat/reversediff.jl:13 [inlined]
 [13] grad!(::ELBO, ::ADVI{ReverseDiffAD{false}}, ::TransformedDistribution{TuringDenseMvNormal{Array{Float64,1},Cholesky{Float64,Array{Float64,2}}},Identity{1},Multivariate}, ::Function, ::Array{Float64,1}, ::DiffResults.MutableDiffResult{1,Float64,Tuple{Array{Float64,1}}}, ::Int64) at /home/fela/tmp/ParticleFlow_Exp/julia/dev/AdvancedVI/src/AdvancedVI.jl:77
 [14] optimize!(::ELBO, ::ADVI{ReverseDiffAD{false}}, ::TransformedDistribution{TuringDenseMvNormal{Array{Float64,1},Cholesky{Float64,Array{Float64,2}}},Identity{1},Multivariate}, ::var"#logπ_gauss#6"{MvNormal{Float64,PDMats.PDiagMat{Float64,Array{Float64,1}},Array{Float64,1}}}, ::Array{Float64,1}; optimizer::ADAGrad, callback::var"#2#3"{typeof(cb_hp_gp),Nothing,MVHistory{History}}, hyperparams::Nothing, hp_optimizer::ADAGrad) at /home/fela/tmp/ParticleFlow_Exp/julia/dev/AdvancedVI/src/AdvancedVI.jl:257
 [15] #vi#31 at /home/fela/tmp/ParticleFlow_Exp/julia/dev/AdvancedVI/src/advi.jl:35 [inlined]
 [16] train_model(::Function, ::Dict{Symbol,Any}, ::Dict{Symbol,Any}, ::Dict{Symbol,Any}, ::Dict{Symbol,Any}) at /home/fela/tmp/ParticleFlow_Exp/julia/avi/train_model.jl:90
 [17] run_gaussian_target(::Dict{Symbol,Any}) at /home/fela/tmp/ParticleFlow_Exp/julia/avi/gaussian_target.jl:69
 [18] top-level scope at /home/fela/tmp/ParticleFlow_Exp/julia/avi/run_gaussians.jl:22
 [19] include(::Function, ::Module, ::String) at ./Base.jl:380
 [20] include(::Module, ::String) at ./Base.jl:368
 [21] exec_options(::Base.JLOptions) at ./client.jl:296
 [22] _start() at ./client.jl:506
in expression starting at /home/fela/tmp/ParticleFlow_Exp/julia/avi/run_gaussians.jl:22
theogf commented 4 years ago

Ok I just tried on 1.5.1 and it runs without problem on my machine.

theogf commented 4 years ago

Could you give put the results of [ status ?

fela commented 4 years ago

I had the same issue on a clean EC2 instance as well as locally cloning the repo in a different place, downloading new julia binaries and deleting ~/.julia

(@v1.5) pkg> activate .
 Activating environment at `~/tmp/ParticleFlow_Exp/julia/Project.toml`

(ParticleFlow) pkg> st
Status `~/tmp/ParticleFlow_Exp/julia/Project.toml`
  [b5ca4192] AdvancedVI v0.1.0 `dev/AdvancedVI`
  [fbb218c0] BSON v0.2.6
  [76274a88] Bijectors v0.8.3
  [35d6a980] ColorSchemes v3.9.0
  [5ae59095] Colors v0.12.4
  [a93c6f00] DataFrames v0.21.7
  [31c24e10] Distributions v0.23.8
  [ced4e74d] DistributionsAD v0.6.8
  [634d3b9d] DrWatson v1.15.1
  [587475ba] Flux v0.11.1
  [f6369f11] ForwardDiff v0.10.12
  [e1397348] GradDescent v0.3.1
  [5ab0869b] KernelDensity v0.5.1
  [ec8451be] KernelFunctions v0.7.2
  [ee78f7c6] Makie v0.11.0
  [5a521ce4] MakieLayout v0.9.9
  [429524aa] Optim v0.22.0
  [90014a1f] PDMats v0.10.0
  [d96e819e] Parameters v0.12.1
  [91a5bcdd] Plots v1.6.3
  [d330b81b] PyPlot v2.9.0
  [37e2e3b7] ReverseDiff v1.4.2
  [4c63d2b9] StatsFuns v0.9.5
  [65254759] StatsMakie v0.2.3
  [fce5fe82] Turing v0.14.1
  [98cad3c8] ValueHistories v0.5.3
  [e88e6eb3] Zygote v0.5.6
  [37e2e46d] LinearAlgebra

julia> versioninfo()
Julia Version 1.5.1
Commit 697e782ab8 (2020-08-25 20:08 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-9.0.1 (ORCJIT, skylake)
theogf commented 4 years ago

It's crazy that it does not work, I even have the same configuration.

Can you try uncommenting https://github.com/theogf/ParticleFlow_Exp/blob/ed7ea6c00e77b6b0a1980a4ab1c41bba5007af81/julia/avi/gaussian_target.jl#L6 and see if it works?

theogf commented 4 years ago

Ok try to update your packages, there was a new release on DistributionsAD (0.6.9) which might help, let me see if using the older version lead to errors for me

theogf commented 4 years ago

Ok I can confirm that there is a fix for this issue in 0.6.9 :D

theogf commented 4 years ago

It got literally fixed this morning! Solved by https://github.com/TuringLang/DistributionsAD.jl/pull/115

fela commented 4 years ago

I can confirm, maybe we should commit the Manifest after all, to avoid these kind of problems?

theogf commented 4 years ago

We just need to add the version in the Project.toml in a [compat] section. I will take care of it