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

Unexpected error: ccall requires compiler when using QR #461

Closed
mfherbst opened this issue Aug 6, 2023 · 5 comments · Fixed by #462
Closed

Unexpected error: ccall requires compiler when using QR #461

mfherbst opened this issue Aug 6, 2023 · 5 comments · Fixed by #462
Labels
blas bug Something isn't working

Comments

@mfherbst
Copy link
Contributor

mfherbst commented Aug 6, 2023

I wanted to use the qr routines added in #456 and here is what I get:

using AMDGPU
using LinearAlgebra

A = ROCArray(rand(ComplexF64, 8, 4))
qr(A)

Stacktrace:

Internal error: encountered unexpected error during compilation of geqrf!:
TypeError(func=:ccall, context="", expected=Symbol, got=nothing)

[... long stacktrace ...]

unknown function (ip: 0x401098)
ERROR: `ccall` requires the compiler
Stacktrace:
  [1] rocblas_create_handle(handle::Base.RefValue{Ptr{Nothing}})
    @ AMDGPU.rocBLAS ~/.julia/packages/AMDGPU/1A9UJ/src/blas/librocblas.jl:188
  [2] macro expansion
    @ ~/.julia/packages/AMDGPU/1A9UJ/src/utils.jl:182 [inlined]
  [3] create_handle()
    @ AMDGPU.rocBLAS ~/.julia/packages/AMDGPU/1A9UJ/src/blas/rocBLAS.jl:28
  [4] (::AMDGPU.var"#28#35")()
    @ AMDGPU ~/.julia/packages/AMDGPU/1A9UJ/src/cache.jl:103
  [5] (::AMDGPU.var"#19#22")()
    @ AMDGPU ~/.julia/packages/AMDGPU/1A9UJ/src/cache.jl:29
  [6] lock(f::AMDGPU.var"#19#22"{AMDGPU.var"#28#35"{typeof(AMDGPU.rocBLAS.create_handle)}, HandleCache{HIPContext, Ptr{Nothing}}, HIPContext}, l::ReentrantLock)
    @ Base ./lock.jl:229
  [7] check_cache
    @ ~/.julia/packages/AMDGPU/1A9UJ/src/cache.jl:27 [inlined]
  [8] pop!
    @ ~/.julia/packages/AMDGPU/1A9UJ/src/cache.jl:48 [inlined]
  [9] (::AMDGPU.var"#new_state#34"{Ptr{Nothing}, HandleCache{HIPContext, Ptr{Nothing}}, typeof(AMDGPU.rocBLAS.create_handle), AMDGPU.rocBLAS.var"#15#16"})(tls::AMDGPU.TaskLocalState)
    @ AMDGPU ~/.julia/packages/AMDGPU/1A9UJ/src/cache.jl:102
 [10] #32
    @ ~/.julia/packages/AMDGPU/1A9UJ/src/cache.jl:115 [inlined]
 [11] get!(default::AMDGPU.var"#32#39"{AMDGPU.var"#new_state#34"{Ptr{Nothing}, HandleCache{HIPContext, Ptr{Nothing}}, typeof(AMDGPU.rocBLAS.create_handle), AMDGPU.rocBLAS.var"#15#16"}, AMDGPU.TaskLocalState}, h::Dict{HIPContext, NamedTuple{(:handle, :stream), Tuple{Ptr{Nothing}, HIPStream}}}, key::HIPContext)
    @ Base ./dict.jl:468
 [12] library_state(library_key::Symbol, #unused#::Type{Ptr{Nothing}}, idle_handles::HandleCache{HIPContext, Ptr{Nothing}}, create_handle::typeof(AMDGPU.rocBLAS.create_handle), destroy_handle::Function, set_stream::AMDGPU.rocBLAS.var"#15#16")
    @ AMDGPU ~/.julia/packages/AMDGPU/1A9UJ/src/cache.jl:115
 [13] lib_state
    @ ~/.julia/packages/AMDGPU/1A9UJ/src/blas/rocBLAS.jl:39 [inlined]
 [14] handle()
    @ AMDGPU.rocBLAS ~/.julia/packages/AMDGPU/1A9UJ/src/blas/rocBLAS.jl:44
 [15] geqrf!(A::ROCMatrix{ComplexF64})
    @ AMDGPU.rocSOLVER ~/.julia/packages/AMDGPU/1A9UJ/src/solver/highlevel.jl:13
 [16] qr!
    @ ~/.julia/packages/AMDGPU/1A9UJ/src/solver/highlevel.jl:206 [inlined]
 [17] #qr#85
    @ ~/julia-1.9.2/share/julia/stdlib/v1.9/LinearAlgebra/src/qr.jl:428 [inlined]
 [18] qr(::ROCMatrix{ComplexF64, AMDGPU.Runtime.Mem.HIPBuffer})
    @ LinearAlgebra ~/julia-1.9.2/share/julia/stdlib/v1.9/LinearAlgebra/src/qr.jl:425
 [19] top-level scope
    @ REPL[4]:1
@pxl-th
Copy link
Collaborator

pxl-th commented Aug 6, 2023

That's weird, can you post AMDGPU.versioninfo() & versioninfo()?
Maybe that's some configuration issue.

Above example works on my machine:

julia> using LinearAlgebra, AMDGPU
[ Info: Navi 2 GPU detected, setting ENV variable: `HSA_OVERRIDE_GFX_VERSION=10.3.0`.

julia> A = ROCArray(rand(ComplexF64, 8, 4));

julia> qr(A)
QR{ComplexF64, ROCMatrix{ComplexF64, AMDGPU.Runtime.Mem.HIPBuffer}, ROCVector{ComplexF64, AMDGPU.Runtime.Mem.HIPBuffer}}
Q factor:
8×8 LinearAlgebra.QRPackedQ{ComplexF64, ROCMatrix{ComplexF64, AMDGPU.Runtime.Mem.HIPBuffer}, ROCVector{ComplexF64, AMDGPU.Runtime.Mem.HIPBuffer}}:
  -0.263534-0.383082im    0.201817+0.300202im   -0.0609926+0.323185im       -0.391813-0.115354im   -0.0163812+0.0353206im
  -0.149431-0.135789im  -0.0804106-0.393071im    -0.192847-0.104253im         -0.30923+0.306449im     -0.49432-0.225866im
  -0.361372-0.039774im   -0.050347-0.431445im    -0.320076+0.358908im         0.160851-0.228831im      0.30265+0.266208im
 -0.0163679-0.211219im   -0.372776+0.0878281im    0.459565-0.0414137im        0.118538-0.11094im      -0.19236+0.122445im
  -0.322477-0.365644im     0.12508+0.24006im      0.209779+0.270177im        0.0764277-0.0450508im   -0.118406+0.0710881im
  -0.130716-0.239194im   -0.279746-0.21806im      0.159488+0.00837835im     -0.214403-0.0708149im   -0.106042-0.185207im
  -0.167977-0.261044im    0.121521-0.15146im      0.266802-0.165913im         0.635625-0.0514819im  -0.0298735-0.3116im
   -0.20606-0.339365im   -0.360917-0.0759747im   -0.114503-0.381134im       -0.0908846+0.255466im     0.570497-0.0241447im
R factor:
4×4 ROCMatrix{ComplexF64, AMDGPU.Runtime.Mem.HIPBuffer}:
 -2.35654+0.0im  -1.79344+0.0237188im  -1.42258+0.412774im    -1.58647-0.0509862im
      0.0+0.0im  -1.66205+0.0im        -1.00484+0.0649698im  -0.696264-0.023673im
      0.0+0.0im       0.0+0.0im        0.923757+0.0im         0.460948+0.441239im
      0.0+0.0im       0.0+0.0im             0.0+0.0im         0.915658+0.0im

@mfherbst
Copy link
Contributor Author

mfherbst commented Aug 6, 2023

Here you go:

julia> AMDGPU.versioninfo()
ROCm provided by: system
[+] HSA Runtime v1.1.0
    @ /opt/rocm/hsa/lib/libhsa-runtime64.so
[+] ld.lld
    @ /opt/rocm/llvm/bin/ld.lld
[+] ROCm-Device-Libs
    @ /opt/rocm/amdgcn/bitcode
[+] HIP Runtime v5.504.22804
    @ /opt/rocm/hip/lib/libamdhip64.so
[-] rocBLAS 
[-] rocSOLVER 
[-] rocALUTION
[-] rocSPARSE
[-] rocRAND 
[+] rocFFT v1.0.21
    @ /opt/rocm/lib/librocfft.so
[-] MIOpen 

HIP Devices [2]
    1. HIPDevice(name="AMD Radeon RX Vega", id=1)
    2. HIPDevice(name="AMD Radeon RX 480 Graphics", id=2)

julia> versioninfo()
Julia Version 1.9.2
Commit e4ee485e909 (2023-07-05 09:39 UTC)
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 4 × Intel(R) Core(TM) i5-4590 CPU @ 3.30GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-14.0.6 (ORCJIT, haswell)
  Threads: 1 on 4 virtual cores

@mfherbst
Copy link
Contributor Author

mfherbst commented Aug 6, 2023

Thanks for looking into it!

@mfherbst
Copy link
Contributor Author

mfherbst commented Aug 6, 2023

Ah it seems rocsolver is not installed ... that's weird. But maybe there could be a more graceful error message?

@pxl-th
Copy link
Collaborator

pxl-th commented Aug 7, 2023

But maybe there could be a more graceful error message?

Agree, will add it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blas bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants