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

Update turing_inference to accommodate Turing's updated syntax. #46

Closed
Vaibhavdixit02 opened this issue Jun 12, 2018 · 13 comments
Closed
Assignees

Comments

@Vaibhavdixit02
Copy link
Member

Hi @xukai92 I saw that there have been quite a few changes in the last few months in Turing.jl and thus turing_inference needs to be updated too, could you help out with the required changes?

@xukai92
Copy link
Contributor

xukai92 commented Jun 15, 2018

Sure, I will update Turing-related codes.

@Vaibhavdixit02
Copy link
Member Author

That would be a great help 👍

@Vaibhavdixit02
Copy link
Member Author

@xukai92 Could you provide a loose timeframe in which you will be able to take a look. I will be presenting a talk at JuliaCon'18 on DiffEqBayes.jl so it would be helpful for me to plan out my work for the talk accordingly. Thanks!

@xukai92
Copy link
Contributor

xukai92 commented Jun 24, 2018

I will do it within two days.

@xukai92
Copy link
Contributor

xukai92 commented Jun 24, 2018

I was trying to upgrade related packages for this repo. but failed to build SymEngine.

=======================[ ERROR: SymEngine ]=======================

LoadError: failed process: Process(setenv(`/Users/kai/.julia/v0.6/Conda/deps/usr/bin/conda install -y symengine=0.3.0`,String["XPC_FLAGS=0x0", "LSCOLORS=Gxfxcxdxbxegedabagacad", "PATH=/Applications/Julia-0.6.app/Contents/Resources/julia/bin:/Applications/Julia-0.6.app/Contents/Resources/julia/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/kai/sbin:/Users/kai/bin:/Users/kai/.local/sbin:/Users/kai/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/opt/local/sbin:/opt/local/bin:/sbin:/bin:/opt/X11/bin:/Library/TeX/texbin:/Users/kai/cling/bin:/Users/kai/Library/Android/sdk:/Users/kai/miniconda2/bin", "PWD=/Users/kai", "DISPLAY=/private/tmp/com.apple.launchd.LyGpKQDTb9/org.macosforge.xquartz:0", "XPC_SERVICE_NAME=0", "TERM_PROGRAM=iTerm.app", "ARCHFLAGS=-arch x86_64", "SHELL=/bin/zsh", "__CF_USER_TEXT_ENCODING=0x1F5:0x0:0x2", "COLORFGBG=15;0", "LC_CTYPE=en_GB.UTF-8", "TMPDIR=/var/folders/xv/35q9th6x10b926ntt6cwgfjh0000gn/T/", "TK_LIBRARY=/System/Library/Frameworks/Tk.framework/Versions/8.5/Resources/Scripts", "CONDARC=/Users/kai/.julia/v0.6/Conda/deps/usr/condarc-julia.yml", "CPPFLAGS=-I/opt/X11/include", "FONTCONFIG_PATH=/Applications/Julia-0.6.app/Contents/Resources/julia/etc/fonts", "LANG=en_GB.UTF-8", "ITERM_PROFILE=Default", "SHLVL=2", "LOGNAME=kai", "CONDA_PREFIX=/Users/kai/.julia/v0.6/Conda/deps/usr", "TERM_SESSION_ID=w0t0p1:1CC0BEF1-AFAA-4FA6-8785-13D6D5780D0D", "SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.dMhY3eLd6k/Listeners", "OLDPWD=/Users/kai", "DEFAULT_USER=kai", "_=/Users/kai/bin/julia", "PAGER=less", "Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.NiLzn0XvJa/Render", "USER=kai", "ITERM_SESSION_ID=w0t0p1:1CC0BEF1-AFAA-4FA6-8785-13D6D5780D0D", "TERM=xterm-256color", "HOME=/Users/kai", "TERM_PROGRAM_VERSION=3.2.0beta3", "OPENBLAS_MAIN_FREE=1", "COLORTERM=truecolor", "LESS=-R", "ZSH=/Users/kai/.oh-my-zsh"]), ProcessExited(1)) [1]
while loading /Users/kai/.julia/v0.6/SymEngine/deps/build.jl, in expression starting on line 56

==================================================================

=========================[ BUILD ERRORS ]=========================

WARNING: SymEngine had build errors.

 - packages with build errors remain installed in /Users/kai/.julia/v0.6
 - build the package(s) and all dependencies with `Pkg.build("SymEngine")`
 - build a single package by running its `deps/build.jl` script

==================================================================

which leads to

ERROR: LoadError: error compiling #ode_def_opts#1: error compiling symbols: error compiling _symbol: error compiling Type: could not load library "libsymengine"
dlopen(libsymengine.dylib, 1): image not found
Stacktrace:
 [1] include_from_node1(::String) at ./loading.jl:576
 [2] include(::String) at ./sysimg.jl:14
 [3] process_options(::Base.JLOptions) at ./client.jl:305
 [4] _start() at ./client.jl:371
while loading /Users/kai/projects/DiffEqBayes.jl/test/turing.jl, in expression starting on line 4

Tried to Pkg.update, Pkg.rm and Pkg.add for that package but didn't help. Any idea how to resolve this?

@Vaibhavdixit02
Copy link
Member Author

I can't recreate the error. What version of Julia and SymEngine are you using?
@ChrisRackauckas do you know something about this?

@xukai92
Copy link
Contributor

xukai92 commented Jun 25, 2018

I'm using Julia 0.6.2 and SymEngine 0.4.0.

@ChrisRackauckas
Copy link
Member

@isuruf

@isuruf
Copy link

isuruf commented Jun 25, 2018

Can you run /Users/kai/.julia/v0.6/Conda/deps/usr/bin/conda install -y symengine=0.3.0 in bash and post the error here?

@xukai92
Copy link
Contributor

xukai92 commented Jun 25, 2018

@isuruf Here is it

➜  DiffEqBayes.jl (update-turing) ✗ /Users/kai/.julia/v0.6/Conda/deps/usr/bin/conda install -y symengine=0.3.0
Solving environment: failed

PackagesNotFoundError: The following packages are not available from current channels:

  - symengine=0.3.0

Current channels:

  - https://repo.anaconda.com/pkgs/main/osx-64
  - https://repo.anaconda.com/pkgs/main/noarch
  - https://repo.anaconda.com/pkgs/free/osx-64
  - https://repo.anaconda.com/pkgs/free/noarch
  - https://repo.anaconda.com/pkgs/r/osx-64
  - https://repo.anaconda.com/pkgs/r/noarch
  - https://repo.anaconda.com/pkgs/pro/osx-64
  - https://repo.anaconda.com/pkgs/pro/noarch

To search for alternate channels that may provide the conda package you're
looking for, navigate to

    https://anaconda.org

and use the search bar at the top of the page.

@isuruf
Copy link

isuruf commented Jun 25, 2018

Run /Users/kai/.julia/v0.6/Conda/deps/usr/bin/conda config --add channels conda-forge and then the command from my previous comment.

@xukai92
Copy link
Contributor

xukai92 commented Jun 25, 2018

That works! Thanks!

@ChrisRackauckas
Copy link
Member

@mohamed82008 posted

function turing_inference(prob::DiffEqBase.DEProblem,alg,t,data,priors = nothing;
                          num_samples=1000, delta=0.65, kwargs...)

  N = length(priors)
  _theta = Vector{Real}(undef, N)
  @model bif(x) = begin
    for i in 1:length(priors)
      _theta[i] ~ priors[i]
    end
    σ ~ InverseGamma(2, 3)

    theta = convert(Array{typeof(first(_theta))}, _theta)
    p_tmp = remake(prob, u0 = convert.(eltype(theta), (prob.u0)), p = theta) 
    sol_tmp = solve(p_tmp, alg; saveat = t, kwargs...)
    fill_length = length(t) - length(sol_tmp.u)

    for i in 1:fill_length
      if eltype(sol_tmp.u) <: Number
        push!(sol_tmp.u, Inf)
      else
        push!(sol_tmp.u, fill(Inf, size(sol_tmp[1])))
      end
    end
    for i = 1:length(t)
      res = sol_tmp.u[i]
      x[:,i] ~ MvNormal(res, σ*ones(2))
    end
  end

  model = bif(data)
  chn = sample(model, Turing.NUTS(num_samples, delta))
end

Vaibhavdixit02 added a commit to Vaibhavdixit02/DiffEqBayes.jl that referenced this issue Feb 9, 2019
ChrisRackauckas added a commit that referenced this issue Feb 22, 2019
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

4 participants