Skip to content

running julia's CUDA through pyjulia #534

@ArturPrzybysz

Description

@ArturPrzybysz

Hello! I am trying to use julia's CUDA package in Python, however I run into troubles.

The code that I run is following:

from julia.api import Julia
import juliapkg as pkg

executable = pkg.executable()
jl = Julia(runtime=executable)  # , compiled_modules=False)

jl.eval('''
import Pkg
Pkg.add("CUDA")
using CUDA

function gpu_compute()
    return CUDA.rand(Float16, 2, 2) * CUDA.rand(Float16, 2, 2)
end
''')

result = jl.eval('gpu_compute()')
print(result)

and I run it using python-jl.

The output that I get is a SEGFAULT:

signal (11): Segmentation fault
in expression starting at none:4
unknown function (ip: (nil))
Allocations: 2904 (Pool: 2894; Big: 10); GC: 0
Segmentation fault (core dumped)

When I replace line 5: jl = Julia(runtime=executable) # , compiled_modules=False) with jl = Julia(runtime=executable , compiled_modules=False) and run it simply with Python I get:

Reason: unsupported dynamic function invocation (call to pointerset(ptr::Core.LLVMPtr{T, A}, x::T, i::I, ::Val{align}) where {T, A, I, align} @ LLVM.Interop ~/.julia/packages/LLVM/RFlwq/src/interop/pointer.jl:46)
Stacktrace:
 [1] unsafe_store!
   @ ~/.julia/packages/LLVM/RFlwq/src/interop/pointer.jl:88
 [2] arrayset_bits
   @ ~/.julia/packages/CUDA/tVtYo/src/device/array.jl:134
 [3] #arrayset
   @ ~/.julia/packages/CUDA/tVtYo/src/device/array.jl:127
 [4] setindex!
   @ ~/.julia/packages/CUDA/tVtYo/src/device/array.jl:166
 [5] kernel
   @ ~/.julia/packages/CUDA/tVtYo/src/random.jl:58
Hint: catch this exception as `err` and call `code_typed(err; interactive = true)` to introspect the erronous code with Cthulhu.jl' occurred while calling julia code:
gpu_compute()

How can I get CUDA to work here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions