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

Strange behaviour while spawning processes #161

Closed
ranjanan opened this issue Dec 24, 2018 · 1 comment · Fixed by #572
Closed

Strange behaviour while spawning processes #161

ranjanan opened this issue Dec 24, 2018 · 1 comment · Fixed by #572

Comments

@ranjanan
Copy link

ranjanan commented Dec 24, 2018

Consider the following file (example.jl) that I want to statically compile:

using Distributed
 using Distributions
 Base.@ccallable function julia_main(ARGS::Vector{String})::Cint
 
     @show isdefined(Main, :Distributed)
     @show isdefined(Main, :addprocs)
     function f(a)
         x = Normal(0,1)
         @show typeof(x)
     end
     myaddprocs(2)
     pmap(f, 1:2)
 
     return 0
 end
 function myaddprocs(n)
     println("In myaddprocs")
     @show isdefined(Main, :Distributed)
     @show isdefined(Main, :addprocs)
     @show isdefined(Distributed, :addprocs)
     Distributed.addprocs(n)
     @everywhere Core.eval(Main, :(using Distributions))
 end

Now suppose I do build_executable("example.jl"). When I do ./example, I'll get an error message about it not being able to spawn Julia processes (#84). I found a workaround to this here: #84 (comment). This basically copies over your julia binary file and then changes its rpath. So I followed this fix and got it to work.

However, when I do ]rm Distributions and try running the executable again, I get the following error:

isdefined(Main, :Distributed) = true
isdefined(Main, :addprocs) = true
In myaddprocs
isdefined(Main, :Distributed) = true
isdefined(Main, :addprocs) = false
isdefined(Distributed, :addprocs) = true
fatal: error thrown and no exception handler available.
Base.CompositeException(exceptions=Array{Any, (3,)}[
  Base.CapturedException(ex=Distributed.RemoteException(pid=2, captured=Base.CapturedException(ex=ArgumentError(msg="Package Distributions not found in current path:
- Run `import Pkg; Pkg.add("Distributions")` to install the Distributions package.

This kind of defeats the purpose of static compilation if the package isn't installed on my computer. I don't understand what changed between v0.6 and v1.0 to make this happen.

Here's my versioninfo():

julia> versioninfo()
Julia Version 1.0.2
Commit d789231e99 (2018-11-08 20:11 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin14.5.0)
  CPU: Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.0 (ORCJIT, broadwell)

P.S. Secondary issue: It's kind of strange that addprocs went out of scope in a function that wasn't julia_main

@ranjanan ranjanan changed the title Strange behaviour during spawning processes on MacOS Strange behaviour while spawning processes on MacOS Dec 24, 2018
@ranjanan
Copy link
Author

It turns out that I get this issue on Windows as well

@ranjanan ranjanan changed the title Strange behaviour while spawning processes on MacOS Strange behaviour while spawning processes Dec 25, 2018
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

Successfully merging a pull request may close this issue.

1 participant