What's the best practice for GPU modules? I saw <n...
# gpu-acceleration
m
What's the best practice for GPU modules? I saw nf-co.re/docs/developing/components/gpu-modules , but I'm wondering who and where
process.accelerator
(docs.seqera.io/nextflow/reference/process#…) should be set by. Does every module that checks
task.accelerator
have to have the
process_gpu
label? Not all currently do ( which means they default to cpu - why not default to gpu? ) Should pipelines need to set
process.accelerator
? The
-profile gpu
sets
task.accelerator = 1
but I guess this should be overridden by an actual map that assigns
type
and
request
. It would make sense that institutional configs set this - but if they support multiple types, how exactly should this be supplied by the user? Is a user expected to override settings with a custom config with process selectors and set the accelerator?
Copy code
process {
    withName: 'GPU_PROCESS_ONE' {
        accelerator = [ type: 'h100', request: 4 ]
    }
    withName: 'GPU_PROCESS_TWO' {
        accelerator = [ type: 'l40s', request: 1 ]
    }
}
and then if they're using an executor that doesn't directly support the directive, should the institute config add it to say
process.clusterOptions
via the cluster directives e.g. slurm -> grus Is it turned off for a particular module in the same way
Copy code
process {
    withName: 'GPU_PROCESS_ONE' {
        accelerator = null
    }
}
and if so, what's the use of
ext.use_gpu
now? And if overriding generally, I guess they should first override
withLabel: 'process_gpu'
and then use
withName
?
p
(This is related to a institutional config PR, but touches on other issues.)
I believe this is not entrenched enough that it can't be changed if it's deemed non-functional, but I also don't see much unclarity - https://nf-co.re/docs/developing/components/gpu-modules#detecting-a-gpu-request says
Modules detect whether a GPU has been requested with task.accelerator. A module never sets the accelerator directive itself; the pipeline controls GPU allocation by setting accelerator = 1 in its process config (for example, via a process_gpu label or a withName block).
which I read as clear indication that the pipeline should make sure
accelerator
is set, but it may do so however it chooses.
A institutional profile may then do different things, including various degrees of "user enablement" (I don't remember what things allow for dynamic use but one could consider a cloud executor that uses the accelerator type - if any - as input to the machine requested). But I do think it's clear pipelines can't really set any accelerator type (for GPUs), and it's up to institutional configs to deal with that and offer users the possibilities to choose if there are multiple types of GPUs available.
m
I made an attempt to update the docs with the relevant information: github.com/nf-core/website/pull/4352
f
Maybe this PR / discussion is also related: github.com/nf-core/sarek/pull/2181
👍🏽 1
m
Thanks. It seems that PR at least agrees with my understanding. If Sarek continued to do it that way, a user would manually need to override the accelerator in order to use it on say slurm or locally. The way Paolo suggests is what I would expect.
f
Can you tell me why setting it per standard to 4 does not have that problem then?
m
Sorry, which problem? The
accelerator
directive does nothing by itself unless it's one of those four executors. However, having it set allows other executors to use it to determine if they should enable their GPU settings.
👍 1
f
Because I am eager to adapt and just denote in the docs what people need to do in their local configs. My goal was to make it as easy to use as possible and that seemed the best way but I can see the issues that paolo pointed out so I am happy to change.
p
I can have a go; because as Paolo mentions - it breaks consistency meaning if it's run on kubernetes it would run with
accelerator=4
whereas using the
slurm
executor in a cluster with the same GPUs available would have it run without.
👍 1
👍🏽 1
m
This is what I was trying to clear up in my PR, and how it flows through the different configs
f
I ran into problems when it was set to 4 on my hpc because we have a dedicated gpu queue (see github.com/nf-core/configs/blob/…/m3c.config). This is all a bit confusing for me to be honest because there is so many settings to set at different places 😄
m
This was what we did to redirect processes to our gpu queue/partition. github.com/nf-core/configs/blob/…/pelle.config#… The idea is to check if
task.accelerator
is set by the pipeline ( either through
-profile gpu
or
--enable_tool
). Generally at this point, only the
task.accelerator.request
is set, and then it's down to the cluster to set the
task.accelerator.type
and redirect it to the correct queue.
⬆️ 1
So for your profile, you should update it to check for
task.accelerator
rather than those other conditionals.
f
Can I ask why you would not utilize the label of the process?
m
Because the user might want to turn it off
p
There's no guaranteed consistency for that such that an institutional config can rely on it.
m
That too. Ribodetector is an example
f
ok so similar to task.time which we use to understand if we need a long-running node we then use task.accelerator to understand whether we need the gpu or not -> got it! I will try and adapt both the sarek config (or rather accept paolos PR) and my own Thanks!
👍🏽 1
👍 1