Segmentation fault using ArrayFire and @spawn


#1

Hello beautiful people,

I have some process that can fit at my GPU memory, so to speed up, I was wondering if I could run parallel process (using Distributed). My hope was that Julia would do its magic, but I just got a segmentation fault. Here a dummy code:

using ArrayFire
function foo(N)  # Just to be sure that something is working
    A = rand(N,N)
    b = rand(N)

    Af = AFArray(A)
    bf = AFArray(b)

    C = A*b
    Cf = Af*bf
    return Cf, C
end

foo(5) # OK

# --------------

using Distributed
addprocs(3)

@everywhere begin

    using ArrayFire
    function foo(N)
        A = rand(N,N)
        b = rand(N)

        Af = AFArray(A)
        bf = AFArray(b)

        C = A*b
        Cf = Af*bf
        return Cf, C
    end

end

# works as expected
r = @spawn rand(2,2)
fetch(r)

# does not works
s = @spawn foo(3)
fetch(s)

# also does not works
s = pmap(x->foo(x), 2:5)

The message that I get is:

signal (11): Segmentation fault
in expression starting at no file:0
unknown function (ip: 0x7f2fcb90fc2f)
Allocations: 70383902 (Pool: 70368264; Big: 15638); GC: 156

Is there clever/not clever way to do my code to run without use Julia’s parallel functions ?

Thank you

For reference:
Julia version 1.0.1 (MKL), GPU Vega RX 64, ArrayFire 6.3.1