Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
453 views
in Technique[技术] by (71.8m points)

dask - How can I keep a PBSCluster running?

I have access to a cluster running PBS Pro and would like to keep a PBSCluster instance running on the headnode. My current (obviously broken) script is:

import dask_jobqueue

from paths import get_temp_dir


def main():
    temp_dir = get_temp_dir()
    scheduler_options = {'scheduler_file': temp_dir / 'scheduler.json'}
    cluster = dask_jobqueue.PBSCluster(cores=24, memory='100GB', processes=1, scheduler_options=scheduler_options)


if __name__ == '__main__':
    main()

This script is obviously broken because after the cluster is created the main() function exits and the cluster is destroyed. I imagine I must call some sort of execute_io_loop function, but I can't find anything in the API.

So, how can I keep my PBSCluster alive?

question from:https://stackoverflow.com/questions/65516931/how-can-i-keep-a-pbscluster-running

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I'm thinking that the section of the Python API (advanced) in the docs might be a good way to try to solve this issue.

Mind you this is an example of how to create Schedulers and Workers, but I'm assuming that the logic could be used in a similar way for your case.

import asyncio

async def create_cluster():
    temp_dir = get_temp_dir()
    scheduler_options = {'scheduler_file': temp_dir / 'scheduler.json'}
    cluster = dask_jobqueue.PBSCluster(cores=24, memory='100GB', processes=1, scheduler_options=scheduler_options)

if __name__ == "__main__":
    asyncio.get_event_loop().run_until_complete(create_cluster())

You might have to change the code a bit, but it should keep your create_cluster running until it finished.

Let me know if this works for you.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...