JuliaImageRecon / RegularizedLeastSquares.jl

MIT License
21 stars 10 forks source link

Is CUDA supported? #64

Closed roflmaostc closed 3 months ago

roflmaostc commented 11 months ago

Hi!

my code is running on CPU but for a CuArray it fails:

MethodError: no method matching init!(::RegularizedLeastSquares.ADMM{Float32, LinearOperators.LinearOperator{Float32, Int64, typeof(Main.var"workspace#190".radon_f!), Nothing, typeof(Main.var"workspace#190".iradon_f!), Vector{Float32}}, LinearOperators.LinearOperator{Float32, Int64, LinearOperators.var"#18#21"{LinearOperators.AdjointLinearOperator{Float32, LinearOperators.LinearOperator{Float32, Int64, typeof(Main.var"workspace#190".radon_f!), Nothing, typeof(Main.var"workspace#190".iradon_f!), Vector{Float32}}}, LinearOperators.LinearOperator{Float32, Int64, typeof(Main.var"workspace#190".radon_f!), Nothing, typeof(Main.var"workspace#190".iradon_f!), Vector{Float32}}, Vector{Float32}}, LinearOperators.var"#19#22"{LinearOperators.LinearOperator{Float32, Int64, typeof(Main.var"workspace#190".radon_f!), Nothing, typeof(Main.var"workspace#190".iradon_f!), Vector{Float32}}, LinearOperators.AdjointLinearOperator{Float32, LinearOperators.LinearOperator{Float32, Int64, typeof(Main.var"workspace#190".radon_f!), Nothing, typeof(Main.var"workspace#190".iradon_f!), Vector{Float32}}}, Vector{Float32}}, LinearOperators.var"#20#23"{LinearOperators.LinearOperator{Float32, Int64, typeof(Main.var"workspace#190".radon_f!), Nothing, typeof(Main.var"workspace#190".iradon_f!), Vector{Float32}}, LinearOperators.AdjointLinearOperator{Float32, LinearOperators.LinearOperator{Float32, Int64, typeof(Main.var"workspace#190".radon_f!), Nothing, typeof(Main.var"workspace#190".iradon_f!), Vector{Float32}}}, Vector{Float32}}, Vector{Float32}}, RegularizedLeastSquares.TVRegularization{Float32, 2, Int64}, LinearOperators.LinearOperator{Float32, Int64, LinearOperators.var"#127#128"{Int64}, LinearOperators.var"#127#128"{Int64}, LinearOperators.var"#127#128"{Int64}, Vector{Float32}}, Any, Vector{Float32}, Vector{Float32}, IterativeSolvers.Identity}, ::CUDA.CuArray{Float32, 1, CUDA.Mem.DeviceBuffer}; A::LinearOperators.LinearOperator{Float32, Int64, typeof(Main.var"workspace#190".radon_f!), Nothing, typeof(Main.var"workspace#190".iradon_f!), Vector{Float32}}, AᴴA::LinearOperators.LinearOperator{Float32, Int64, LinearOperators.var"#18#21"{LinearOperators.AdjointLinearOperator{Float32, LinearOperators.LinearOperator{Float32, Int64, typeof(Main.var"workspace#190".radon_f!), Nothing, typeof(Main.var"workspace#190".iradon_f!), Vector{Float32}}}, LinearOperators.LinearOperator{Float32, Int64, typeof(Main.var"workspace#190".radon_f!), Nothing, typeof(Main.var"workspace#190".iradon_f!), Vector{Float32}}, Vector{Float32}}, LinearOperators.var"#19#22"{LinearOperators.LinearOperator{Float32, Int64, typeof(Main.var"workspace#190".radon_f!), Nothing, typeof(Main.var"workspace#190".iradon_f!), Vector{Float32}}, LinearOperators.AdjointLinearOperator{Float32, LinearOperators.LinearOperator{Float32, Int64, typeof(Main.var"workspace#190".radon_f!), Nothing, typeof(Main.var"workspace#190".iradon_f!), Vector{Float32}}}, Vector{Float32}}, LinearOperators.var"#20#23"{LinearOperators.LinearOperator{Float32, Int64, typeof(Main.var"workspace#190".radon_f!), Nothing, typeof(Main.var"workspace#190".iradon_f!), Vector{Float32}}, LinearOperators.AdjointLinearOperator{Float32, LinearOperators.LinearOperator{Float32, Int64, typeof(Main.var"workspace#190".radon_f!), Nothing, typeof(Main.var"workspace#190".iradon_f!), Vector{Float32}}}, Vector{Float32}}, Vector{Float32}}, x::CUDA.CuArray{Float32, 1, CUDA.Mem.DeviceBuffer})

Closest candidates are:

init!(!Matched::RegularizedLeastSquares.CGNR, ::vecT; cl) where vecT got unsupported keyword arguments "A", "AᴴA", "x"

@ RegularizedLeastSquares ~/.julia/packages/RegularizedLeastSquares/Z4F72/src/CGNR.jl:99

init!(!Matched::RegularizedLeastSquares.FISTA{rT, vecT, matA, matAHA}, ::vecT; x, t) where {rT, vecT, matA, matAHA} got unsupported keyword arguments "A", "AᴴA"

@ RegularizedLeastSquares ~/.julia/packages/RegularizedLeastSquares/Z4F72/src/FISTA.jl:92

init!(!Matched::RegularizedLeastSquares.OptISTA{rT, vecT, matA, matAHA}, ::vecT; x, θ) where {rT, vecT, matA, matAHA} got unsupported keyword arguments "A", "AᴴA"

@ RegularizedLeastSquares ~/.julia/packages/RegularizedLeastSquares/Z4F72/src/OptISTA.jl:110

...

    var"#solve#145"(::LinearOperators.LinearOperator{Float32, Int64, typeof(Main.var"workspace#190".radon_f!), Nothing, typeof(Main.var"workspace#190".iradon_f!), Vector{Float32}}, ::LinearOperators.LinearOperator{Float32, Int64, LinearOperators.var"#18#21"{LinearOperators.AdjointLinearOperator{Float32, LinearOperators.LinearOperator{Float32, Int64, typeof(Main.var"workspace#190".radon_f!), Nothing, typeof(Main.var"workspace#190".iradon_f!), Vector{Float32}}}, LinearOperators.LinearOperator{Float32, Int64, typeof(Main.var"workspace#190".radon_f!), Nothing, typeof(Main.var"workspace#190".iradon_f!), Vector{Float32}}, Vector{Float32}}, LinearOperators.var"#19#22"{LinearOperators.LinearOperator{Float32, Int64, typeof(Main.var"workspace#190".radon_f!), Nothing, typeof(Main.var"workspace#190".iradon_f!), Vector{Float32}}, LinearOperators.AdjointLinearOperator{Float32, LinearOperators.LinearOperator{Float32, Int64, typeof(Main.var"workspace#190".radon_f!), Nothing, typeof(Main.var"workspace#190".iradon_f!), Vector{Float32}}}, Vector{Float32}}, LinearOperators.var"#20#23"{LinearOperators.LinearOperator{Float32, Int64, typeof(Main.var"workspace#190".radon_f!), Nothing, typeof(Main.var"workspace#190".iradon_f!), Vector{Float32}}, LinearOperators.AdjointLinearOperator{Float32, LinearOperators.LinearOperator{Float32, Int64, typeof(Main.var"workspace#190".radon_f!), Nothing, typeof(Main.var"workspace#190".iradon_f!), Vector{Float32}}}, Vector{Float32}}, Vector{Float32}}, ::CUDA.CuArray{Float32, 1, CUDA.Mem.DeviceBuffer}, ::Nothing, ::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, ::typeof(RegularizedLeastSquares.solve), ::RegularizedLeastSquares.ADMM{Float32, LinearOperators.LinearOperator{Float32, Int64, typeof(Main.var"workspace#190".radon_f!), Nothing, typeof(Main.var"workspace#190".iradon_f!), Vector{Float32}}, LinearOperators.LinearOperator{Float32, Int64, LinearOperators.var"#18#21"{LinearOperators.AdjointLinearOperator{Float32, LinearOperators.LinearOperator{Float32, Int64, typeof(Main.var"workspace#190".radon_f!), Nothing, typeof(Main.var"workspace#190".iradon_f!), Vector{Float32}}}, LinearOperators.LinearOperator{Float32, Int64, typeof(Main.var"workspace#190".radon_f!), Nothing, typeof(Main.var"workspace#190".iradon_f!), Vector{Float32}}, Vector{Float32}}, LinearOperators.var"#19#22"{LinearOperators.LinearOperator{Float32, Int64, typeof(Main.var"workspace#190".radon_f!), Nothing, typeof(Main.var"workspace#190".iradon_f!), Vector{Float32}}, LinearOperators.AdjointLinearOperator{Float32, LinearOperators.LinearOperator{Float32, Int64, typeof(Main.var"workspace#190".radon_f!), Nothing, typeof(Main.var"workspace#190".iradon_f!), Vector{Float32}}}, Vector{Float32}}, LinearOperators.var"#20#23"{LinearOperators.LinearOperator{Float32, Int64, typeof(Main.var"workspace#190".radon_f!), Nothing, typeof(Main.var"workspace#190".iradon_f!), Vector{Float32}}, LinearOperators.AdjointLinearOperator{Float32, LinearOperators.LinearOperator{Float32, Int64, typeof(Main.var"workspace#190".radon_f!), Nothing, typeof(Main.var"workspace#190".iradon_f!), Vector{Float32}}}, Vector{Float32}}, Vector{Float32}}, RegularizedLeastSquares.TVRegularization{Float32, 2, Int64}, LinearOperators.LinearOperator{Float32, Int64, LinearOperators.var"#127#128"{Int64}, LinearOperators.var"#127#128"{Int64}, LinearOperators.var"#127#128"{Int64}, Vector{Float32}}, Any, Vector{Float32}, Vector{Float32}, IterativeSolvers.Identity}, ::CUDA.CuArray{Float32, 1, CUDA.Mem.DeviceBuffer})@ADMM.jl:213
    solve(::RegularizedLeastSquares.ADMM{Float32, LinearOperators.LinearOperator{Float32, Int64, typeof(Main.var"workspace#190".radon_f!), Nothing, typeof(Main.var"workspace#190".iradon_f!), Vector{Float32}}, LinearOperators.LinearOperator{Float32, Int64, LinearOperators.var"#18#21"{LinearOperators.AdjointLinearOperator{Float32, LinearOperators.LinearOperator{Float32, Int64, typeof(Main.var"workspace#190".radon_f!), Nothing, typeof(Main.var"workspace#190".iradon_f!), Vector{Float32}}}, LinearOperators.LinearOperator{Float32, Int64, typeof(Main.var"workspace#190".radon_f!), Nothing, typeof(Main.var"workspace#190".iradon_f!), Vector{Float32}}, Vector{Float32}}, LinearOperators.var"#19#22"{LinearOperators.LinearOperator{Float32, Int64, typeof(Main.var"workspace#190".radon_f!), Nothing, typeof(Main.var"workspace#190".iradon_f!), Vector{Float32}}, LinearOperators.AdjointLinearOperator{Float32, LinearOperators.LinearOperator{Float32, Int64, typeof(Main.var"workspace#190".radon_f!), Nothing, typeof(Main.var"workspace#190".iradon_f!), Vector{Float32}}}, Vector{Float32}}, LinearOperators.var"#20#23"{LinearOperators.LinearOperator{Float32, Int64, typeof(Main.var"workspace#190".radon_f!), Nothing, typeof(Main.var"workspace#190".iradon_f!), Vector{Float32}}, LinearOperators.AdjointLinearOperator{Float32, LinearOperators.LinearOperator{Float32, Int64, typeof(Main.var"workspace#190".radon_f!), Nothing, typeof(Main.var"workspace#190".iradon_f!), Vector{Float32}}}, Vector{Float32}}, Vector{Float32}}, RegularizedLeastSquares.TVRegularization{Float32, 2, Int64}, LinearOperators.LinearOperator{Float32, Int64, LinearOperators.var"#127#128"{Int64}, LinearOperators.var"#127#128"{Int64}, LinearOperators.var"#127#128"{Int64}, Vector{Float32}}, Any, Vector{Float32}, Vector{Float32}, IterativeSolvers.Identity}, ::CUDA.CuArray{Float32, 1, CUDA.Mem.DeviceBuffer})@ADMM.jl:211
    top-level scope@[Local: 1](http://localhost:1234/edit?id=551a6392-91de-11ee-2460-ef1c6beb86d2#)[inlined]

Is CUDA being tested?

Thanks,

Felix

tknopp commented 11 months ago

So in principle we have used this package with CUDA before but due to recent changes it is somewhat expected that this does not work anymore. The key issue is:

Is CUDA being tested?

The question is: How? As far as I understand it, CUDA can't be run on Github Actions. So if there is any idea, how we can test it, that would be much appreciated. Local tests would of course be a first start to get things working.

roflmaostc commented 11 months ago

Yeah, in my case I usually test them locally.

I invited you to my https://github.com/roflmaostc/RadonKA.jl/blob/main/examples/CT_reconstruction.jl example where it fails, if you want to test it

nHackel commented 3 months ago

GPU support has now been implemented and released, though some solver depend on upstream PRs in LinearOperators which have not been merged yet