Macro @everywhere

I tried running some scripts that use @everywhere.
And I receive the following Alert:

LoadError: LoadError: UndefVarError: @everywhere not defined
in expression starting at D: \ Julia SoftWare \ Julia Scripts \ julia-and-julia-sets: 35
in expression starting at D: \ Julia SoftWare \ Julia Scripts \ julia-and-julia-sets: 35
top-level scope

When inquiring into the file exports.jl, of my Julia installation, this macro is not included!
Where do I look for or how to include this macro?

Gracias

1 Like
using Distributed
2 Likes

now, after including

using Distributed

I have the following alert:

LoadError: LoadError: UndefVarError: @parallel not defined

in expression starting at D:\Julia SoftWare\Julia Scripts\julia-and-julia-sets:41

in expression starting at D:\Julia SoftWare\Julia Scripts\julia-and-julia-sets:41

top-level scope

Did you try using 0.7 which has all the deprecation warnings? (PSA: use Julia 0.7 if you are upgrading)

julia> @everywhere 1+1
WARNING: Base.@everywhere is deprecated: it has been moved to the standard library package `Distributed`.
Add `using Distributed` to your imports.
 in module Main

julia> @parallel 1+1
┌ Warning: `@parallel` is deprecated, use `@distributed` instead.
│   caller = eval(::Module, ::Any) at boot.jl:319
└ @ Core ./boot.jl:319

I try to run the following lines of code:


@everywhere julia = julia
@everywhere julia_set = julia_set

# Re-write our code to generate the sets in parallel
nr_frames = 40

sets = @sync @parallel append! for n=0:nr_frames
    c = e ^ (2*π*n/nr_frames*im)
    set = julia_set(height, width, c)
    [set]
end

anim = @animate for set in sets
    heatmap(set, size=(width,height), color=:speed, leg=false)
end

file_name = "C:/Users/user/Pictures/julia_$(height)_$(width)_$(nr_frames).gif"
gif(anim, file_name, fps=4)

You can help me update them:
They were taken from:
https://hackernoon.com/julia-and-julia-sets-e5a6fa3de7a7

Did you try to use 0.7 and update the deprecation warnings? What happens after that?

I read:
PSA: use Julia 0.7 if you are upgrading()
Current stable release (v1.0.2)

I am using v1.0.2; means that I must install Julia v0.7.0 release.
Can I install it after having installed v1.0.2?

Yes, there is no problem having two julias installed at the same time,

I have already installed v0.7.0
I use Atom
How to use one or another version. My apologies I am new using Atom and Julia

           _

_ _ ()_ | A fresh approach to technical computing
() | () () | Documentation: https://docs.julialang.org
_ _ | | __ _ | Type “?” for help, “]?” for Pkg help.
| | | | | | |/ ` | |
| | |
| | | | (
| | | Version 0.7.0 (2018-08-08 06:46 UTC)
/ |_|||_’_| | Official http://julialang.org/ release
|__/ | x86_64-w64-mingw32

julia> @everywhere 1+1
WARNING: Base.@everywhere is deprecated: it has been moved to the standard library package Distributed.
Add using Distributed to your imports.
in module Main
WARNING: Base.@everywhere is deprecated: it has been moved to the standard library package Distributed.
Add using Distributed to your imports.
in module Main

julia>

julia> using Distributed

julia> @distributed 1+1
ERROR: LoadError: malformed @distributed loop
Stacktrace:
[1] error(::String) at .\error.jl:33
[2] @distributed(::LineNumberNode, ::Module, ::Vararg{Any,N} where N) at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v0.7\Distributed\src\macros.jl:329
in expression starting at REPL[7]:1

julia> @everywhere 1+1
WARNING: Base.@everywhere is deprecated: it has been moved to the standard library package Distributed.
Add using Distributed to your imports.
in module Main
WARNING: Base.@everywhere is deprecated: it has been moved to the standard library package Distributed.
Add using Distributed to your imports.
in module Main

julia>

Yeah, @distributed needs a loop like in your example. I just but something stupid like 1+1 to show the deprecation message.

#https://hackernoon.com/julia-and-julia-sets-e5a6fa3de7a7
function julia(x, y, width, height, c)
    # Scale size the fractal within our frame
    z = ((y/width)*2.7 - 1.3) + ((x/height)*4.5 - 2.5)im
    for i = 1:255
        z = z^2 + c
        if abs(z) >= 4
            return i
        end
    end
    return -255
end


function julia_set(height, width, c)
    [julia(x, y, width, height, c) for x = 1:height, y = 1:width]
end
# Install the packages we need
#Pkg.add("Plots")
#Pkg.add("GR")
# Import the Plots library in the current runtime
using Plots, Distributed
# Initialize the gr backend
gr()
# Set the size of our images
height = 800
width = 800
c = 1.2*exp(1.1π*im)
# Generate the set
data = julia_set(height, width, c)
# Generate the heatmap and save it as a PNG
file_name = "C:/Users/user/Pictures/julia_$(height)_$(width)_$(c.re)_$(c.im)"
png(heatmap(data, size=(width,height), color=:ice), file_name)

@everywhere julia = julia
@everywhere julia_set = julia_set

# Re-write our code to generate the sets in parallel
nr_frames = 40

sets = @sync @distributed append! for n=0:nr_frames
    c = e ^ (2*π*n/nr_frames*im)
    set = julia_set(height, width, c)
    [set]
end

anim = @animate for set in sets
    heatmap(set, size=(width,height), color=:speed, leg=false)
end

file_name = "C:/Users/user/Pictures/julia_$(height)_$(width)_$(nr_frames).gif"
gif(anim, file_name, fps=4)

Error evaluating julia-and-julia-sets.jl

LoadError: IOError: could not spawn ffmpeg -v 0 -i 'C:\Users\user\AppData\Local\Temp\jl_1409.tmp/%06d.png' -vf palettegen=stats_mode=diff -y 'C:\Users\user\AppData\Local\Temp\jl_1409.tmp/palette.bmp': no such file or directory (ENOENT)

in expression starting at D:\Julia SoftWare\Julia Scripts\julia-and-julia-sets.jl:52

_jl_spawn(::String, ::Array{String,1}, ::Cmd, ::Tuple{RawFD,RawFD,RawFD}) at process.jl:370

(::getfield(Base, Symbol(“##499#500”)){Cmd})(::Tuple{RawFD,RawFD,RawFD}) at process.jl:512

setup_stdio(::getfield(Base, Symbol(“##499#500”)){Cmd}, ::Tuple{RawFD,RawFD,RawFD}) at process.jl:493

#_spawn#498(::Nothing, ::Function, ::Cmd, ::Tuple{RawFD,RawFD,RawFD}) at process.jl:511

_spawn at process.jl:507 [inlined]

run#509(::Bool, ::Function, ::Cmd) at process.jl:669

run at process.jl:668 [inlined]

#buildanimation#232(::Int64, ::Int64, ::Bool, ::Bool, ::Function, ::String, ::String, ::Bool) at animation.jl:82

#gif#229 at none:0 [inlined]

(::getfield(Plots, Symbol(“#kw##gif”)))(::NamedTuple{(:fps,),Tuple{Int64}}, ::typeof(gif), ::Animation, ::String) at none:0

top-level scope at none:0

And do you have ffmpeg installed and it can be found in your PATH ?

This happened to me today on a recent build of the master branch.

I think I solved it in the end by doing pkg> resolve.

I do not have ffmpeg installed!
What to do? Should I install it?
This is not a package for video use?

I have been installing the following packages to the extent that the systems with their alerts were asking for it:

VideoIO
Images
ImageView

And as a last warning I receive the following:

LoadError: IOError: write: broken pipe (EPIPE)

in expression starting at D:\Julia SoftWare\Julia Scripts\julia-and-julia-sets.jl:24

Hi, This is rather late to the stage, but I found this issue that might help. Changing ‘@parallel’ to ‘@distributed’ in your code should do the job.