Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions docs/reference/process.md
Original file line number Diff line number Diff line change
Expand Up @@ -290,9 +290,6 @@ The following options are available for all process outputs:

### accelerator

:::{versionadded} 19.09.0-edge
:::

The `accelerator` directive allows you to request hardware accelerators (e.g. GPUs) for the task execution. For example:

```nextflow
Expand All @@ -313,17 +310,23 @@ This directive is only used by certain executors. Refer to the {ref}`executor-pa
:::

:::{note}
Additional options may be required to fully enable the use of accelerators. When using containers with GPUs, you must pass the GPU drivers through to the container. For Docker, this requires the option `--gpus all` in the docker run command. For Apptainer/Singularity, this requires the option `--nv`. The specific implementation details depend on the accelerator and container type being used.
Additional options may be required to fully enable the use of accelerators. When using containers with GPUs, you must pass the GPU drivers through to the container. For Docker, this requires the option `--gpus all` in the `docker run` command. For Apptainer/Singularity, this requires the option `--nv`. The specific implementation details depend on the accelerator and container type being used.
:::

:::{note}
The accelerator `type` option depends on the target execution platform. Refer to the platform-specific documentation for details on the available accelerators:
The following options are available:

- [Google Cloud](https://cloud.google.com/compute/docs/gpus/)
- [Kubernetes](https://kubernetes.io/docs/tasks/manage-gpus/scheduling-gpus/#clusters-containing-different-types-of-gpus)
`request: Integer`
: The number of requested accelerators.
: Specifying this directive with a number (e.g., `accelerator 4`) is equivalent to the `request` option (e.g., `accelerator request: 4`).

The accelerator `type` option is not supported for AWS Batch. You can control the accelerator type indirectly through the allowed instance types in your Compute Environment. See the [AWS Batch FAQs](https://aws.amazon.com/batch/faqs/?#GPU_Scheduling_) for more information.
:::
`type: String`
: The accelerator type.
: The meaning of this option depends on the target execution platform. See the platform-specific documentation for more information about the available accelerators:

- [Google Cloud](https://cloud.google.com/compute/docs/gpus/)
- [Kubernetes](https://kubernetes.io/docs/tasks/manage-gpus/scheduling-gpus/#clusters-containing-different-types-of-gpus)

: This option is not supported for AWS Batch. You can control the accelerator type indirectly through the allowed instance types in your Compute Environment. See the [AWS Batch FAQs](https://aws.amazon.com/batch/faqs/?#GPU_Scheduling_) for more information.

(process-afterscript)=

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,20 @@ class AcceleratorResource {
}

AcceleratorResource( Map res ) {
if( res.limit!=null && res.request!=null ) {
if( res.limit != null && res.request != null ) {
this.limit = res.limit as int
this.request = res.request as int
}
else if( res.limit!=null ) {
else if( res.limit != null ) {
this.limit = res.limit as int
this.request = res.limit as int
}
else if( res.request != null ) {
this.request = res.request as int
}
else {
throw new IllegalArgumentException("Invalid `accelerator` directive value -- `request` or `limit` is required: $res")
}

if( res.type )
this.type = res.type as String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import spock.lang.Specification
*/
class AcceleratorResourceTest extends Specification {

def 'should create a gpu resource' () {
def 'should create an accelerator resource' () {

when:
def acc = new AcceleratorResource(VALUE)
Expand All @@ -46,4 +46,12 @@ class AcceleratorResourceTest extends Specification {
[limit: 3, type: 'nvidia'] | 3 | 3 | 'nvidia' | null
[limit: 3, runtime: 'foo'] | 3 | 3 | null | 'foo'
}

def 'should throw error for invalid resource' () {
when:
def acc = new AcceleratorResource([count: 1, type: 'nvidia-tesla-t4'])
then:
def err = thrown(IllegalArgumentException)
err.message.contains('Invalid `accelerator` directive value -- `request` or `limit` is required')
}
}
Loading