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

running julia's CUDA through pyjulia #534

Open
ArturPrzybysz opened this issue Jun 27, 2023 · 1 comment
Open

running julia's CUDA through pyjulia #534

ArturPrzybysz opened this issue Jun 27, 2023 · 1 comment

Comments

@ArturPrzybysz
Copy link

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?

@ArturPrzybysz
Copy link
Author

ArturPrzybysz commented Jun 27, 2023

Pkg.status()
  [052768ef] CUDA v4.4.0
  [438e738f] PyCall v1.96.0
> pip show julia
Name: julia
Version: 0.6.1
Summary: Julia/Python bridge with IPython support.

nvidia-smi outputs that the driver version is 530.41.03, CUDA Version: 12.1 and I have GeForce RTX 4090.

Julia version is 1.9.1

The julia code using CUDA runs fine on the same julia binary as the one used by pyjulia.

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

1 participant