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

Slack models on GPU #115

Closed
tmigot opened this issue Apr 29, 2024 · 3 comments · Fixed by #114
Closed

Slack models on GPU #115

tmigot opened this issue Apr 29, 2024 · 3 comments · Fixed by #114

Comments

@tmigot
Copy link
Member

tmigot commented Apr 29, 2024

using Test, NLPModels, CUDA, NLPModelsModifiers, NLPModelsTest
nlp = LINSV(CuArray{Float64})
SlackModel(nlp) # fails

fails, because we expected NLPModelMeta{S, T} if nlp is of type AbstractNLPModel{S, T} (see

mutable struct SlackModel{T, S, M <: AbstractNLPModel{T, S}} <: AbstractNLPModel{T, S}
).
However, nlp is {Float64, CuArray{Float64}} while the "slack" meta is {Float64, CuArray{Float64, 1, CUDA.Mem.DeviceBuffer}}

slackMeta = NLPModelsModifiers.slack_meta(meta) # https://github.com/JuliaSmoothOptimizers/NLPModelsModifiers.jl/blob/a9fa77496346fd5da171535295d949b570ac2f5a/src/slack-model.jl#L115

@amontoison an opinion on this? #114 is a suggestion to fix this.

@amontoison
Copy link
Member

I suggest to use S = eltype(v) with v a vector allocated with CuVector{Float64}(undef, n) when we create the NLPModel.

@tmigot
Copy link
Member Author

tmigot commented Apr 30, 2024

Not sure, I fully understand your suggestion. My question is more do you know the difference between CuArray{Float64, 1, CUDA.Mem.DeviceBuffer} and CuArray{Float64, 1}? and is it a problem to cast CuArray{Float64, 1, CUDA.Mem.DeviceBuffer} into CuArray{Float64, 1}?

@amontoison
Copy link
Member

Not sure, I fully understand your suggestion. My question is more do you know the difference between CuArray{Float64, 1, CUDA.Mem.DeviceBuffer} and CuArray{Float64, 1}? and is it a problem to cast CuArray{Float64, 1, CUDA.Mem.DeviceBuffer} into CuArray{Float64, 1}?

Yes, I know the difference.
The last attribute is the type of memory allocated by CUDA.
It can be host, device or unified memory.

I suggest this blog to understand it:
https://juliagpu.org/post/2023-11-07-cuda_5.1/

@tmigot tmigot linked a pull request Apr 30, 2024 that will close this issue
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

Successfully merging a pull request may close this issue.

2 participants