用法:
dask.distributed.SSHCluster(hosts: list[str] | None = None, connect_options: dict | list[dict] = {}, worker_options: dict = {}, scheduler_options: dict = {}, worker_module: str = 'deprecated', worker_class: str = 'distributed.Nanny', remote_python: str | list[str] | None = None, **kwargs)
使用 SSH 部署 Dask 集群
SSHCluster 函數在您提供的一組機器地址上為您部署 Dask Scheduler 和 Workers。第一個地址將用於調度程序,其餘的將用於工作程序(如果您希望調度程序和工作程序 co-habitate 一台機器,請隨意重複第一個主機名。)
您可以通過傳遞
scheduler_options
和worker_options
字典關鍵字來配置調度程序和工作程序。有關可用選項的詳細信息,請參閱dask.distributed.Scheduler
和dask.distributed.Worker
類,但默認值應該適用於大多數情況。您可以使用
connect_options
關鍵字配置您對 SSH 本身的使用,該關鍵字將值傳遞給asyncssh.connect
函數。有關這些的更多信息,請參閱asyncssh
庫 https://asyncssh.readthedocs.io 的文檔。- hosts:列表[str]
啟動集群的主機名或地址列表。第一個將用於調度程序,其餘用於工作人員。
- connect_options:dict或dict列表,可選
要傳遞給
asyncssh.connect()
的關鍵字。這可能包括諸如port
,username
,password
或known_hosts
之類的東西。有關完整信息,請參閱asyncssh.connect()
和asyncssh.SSHClientConnectionOptions
的文檔。如果是列表,它的長度必須與hosts
相同。- worker_options:字典,可選
傳遞給工人的關鍵字。
- scheduler_options:字典,可選
傳遞給調度程序的關鍵字。
- worker_class: str:
用於創建工作人員的 python 類。
- remote_python:str 或 str 列表,可選
遠程節點上的 Python 路徑。
參數:
例子:
創建一個包含一個工作人員的集群:
>>> from dask.distributed import Client, SSHCluster >>> cluster = SSHCluster(["localhost", "localhost"]) >>> client = Client(cluster)
創建一個包含三個工作人員的集群,每個工作人員有兩個線程,並在端口 8797 上托管儀表板:
>>> from dask.distributed import Client, SSHCluster >>> cluster = SSHCluster( ... ["localhost", "localhost", "localhost", "localhost"], ... connect_options={"known_hosts": None}, ... worker_options={"nthreads": 2}, ... scheduler_options={"port": 0, "dashboard_address": ":8797"} ... ) >>> client = Client(cluster)
在每台主機上創建一個包含兩個工作人員的集群:
>>> from dask.distributed import Client, SSHCluster >>> cluster = SSHCluster( ... ["localhost", "localhost", "localhost", "localhost"], ... connect_options={"known_hosts": None}, ... worker_options={"nthreads": 2, "n_workers": 2}, ... scheduler_options={"port": 0, "dashboard_address": ":8797"} ... ) >>> client = Client(cluster)
使用不同工作類的示例,特別是來自
dask-cuda
項目的CUDAWorker
:>>> from dask.distributed import Client, SSHCluster >>> cluster = SSHCluster( ... ["localhost", "hostwithgpus", "anothergpuhost"], ... connect_options={"known_hosts": None}, ... scheduler_options={"port": 0, "dashboard_address": ":8797"}, ... worker_class="dask_cuda.CUDAWorker") >>> client = Client(cluster)
相關用法
- Python dask.distributed.get_task_stream用法及代碼示例
- Python dask.distributed.progress用法及代碼示例
- Python dask.diagnostics.Profiler用法及代碼示例
- Python dask.diagnostics.CacheProfiler用法及代碼示例
- Python dask.diagnostics.Callback用法及代碼示例
- Python dask.diagnostics.ResourceProfiler用法及代碼示例
- Python dask.diagnostics.ProgressBar用法及代碼示例
- Python dask.dataframe.Series.apply用法及代碼示例
- Python dask.dataframe.to_records用法及代碼示例
- Python dask.dataframe.DataFrame.applymap用法及代碼示例
- Python dask.dataframe.Series.clip用法及代碼示例
- Python dask.dataframe.Series.prod用法及代碼示例
- Python dask.dataframe.Series.fillna用法及代碼示例
- Python dask.dataframe.DataFrame.sub用法及代碼示例
- Python dask.dataframe.compute用法及代碼示例
- Python dask.dataframe.DataFrame.mod用法及代碼示例
- Python dask.dataframe.Series.to_frame用法及代碼示例
- Python dask.dataframe.read_table用法及代碼示例
- Python dask.dataframe.read_hdf用法及代碼示例
- Python dask.dataframe.Series.sum用法及代碼示例
注:本文由純淨天空篩選整理自dask.org大神的英文原創作品 dask.distributed.SSHCluster。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。