@@ -47,6 +47,49 @@ When we submit tasks to the cluster we specify constraints per task
47
47
processed = [client.submit(process, d, resources = {' GPU' : 1 }) for d in data]
48
48
final = client.submit(aggregate, processed, resources = {' MEMORY' : 70e9 })
49
49
50
+ Specifying Resources
51
+ --------------------
52
+
53
+ Resources can be specifed in several ways. The easiest option will depend on exactly
54
+ how your cluster is being created.
55
+
56
+ **From the command line **
57
+
58
+ Resources can be provided when starting the worker process, as shown above:
59
+
60
+ .. code-block :: console
61
+
62
+ dask-worker scheduler:8786 --resources "GPU=2"
63
+
64
+ The keys are used as the resource name and the values are parsed into a numeric value.
65
+
66
+ **From Dask's configuration system **
67
+
68
+ Alternatively, resources can be specified using Dask's
69
+ `configuration system <https://docs.dask.org/en/latest/configuration.html >`_.
70
+
71
+ .. code-block :: python
72
+
73
+ from distributed import LocalCluster
74
+
75
+ with dask.config.set({" distributed.worker.resources.GPU" : 2 }):
76
+ cluster = LocalCluster()
77
+
78
+ The configuration will need to be set in the process that's spawning the actual worker.
79
+ This might be easiest to achieve by specifying resources as an environment variable
80
+ (shown in the next section).
81
+
82
+ **From environment variables **
83
+
84
+ Like any other Dask config value, resources can be specified as environment variables
85
+ before starting the process. Using Bash syntax
86
+
87
+ .. code-block :: console
88
+
89
+ $ DASK_DISTRIBUTED__WORKER__RESOURCES__GPU=2 dask-worker
90
+ ...
91
+
92
+ This might be the easiest solution if you aren't able to pass options to the :class: `distributed.Worker ` class.
50
93
51
94
Resources are applied separately to each worker process
52
95
-------------------------------------------------------
0 commit comments