gpt4 book ai didi

python - 高效且经济地运行 python 程序的多个实例?

转载 作者:太空狗 更新时间:2023-10-30 00:37:26 30 4
gpt4 key购买 nike

我写了一个调用函数的程序,原型(prototype)如下:

def Process(n):

# the function uses data that is stored as binary files on the hard drive and
# -- based on the value of 'n' -- scans it using functions from numpy & cython.
# the function creates new binary files and saves the results of the scan in them.
#
# I optimized the running time of the function as much as I could using numpy &
# cython, and at present it takes about 4hrs to complete one function run on
# a typical winXP desktop (three years old machine, 2GB memory etc).

我的目标是以最快和最经济的方式恰好运行此函数 10,000 次(对于 10,000 个不同的“n”值)。在这些运行之后,我将拥有 10,000 个不同的二进制文件,其中包含所有单独扫描的结果。请注意,每个函数“运行”都是独立的(这意味着,各个运行之间没有任何依赖关系)。

所以问题是这样的。如果家里只有一台 PC,很明显我需要大约 4.5 年(10,000 次运行 x 每次运行 4 小时 = 40,000 小时 ~= 4.5 年)才能在家里完成所有运行。然而,我希望在一两周内完成所有运行。

我知道解决方案涉及同时访问许多计算资源。这样做的最佳(最快/最实惠,因为我的预算有限)方法是什么?我必须购买一台功能强大的服务器(要花多少钱?)或者我可以在线运行它吗?在这种情况下,这样做会暴露我的专有代码吗?

如果有帮助,“Process()”的每个实例只需要大约 500MB 的内存。谢谢。

最佳答案

查看 PiCloud:http://www.picloud.com/

import cloud
cloud.call(function)

也许这是一个简单的解决方案。

关于python - 高效且经济地运行 python 程序的多个实例?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3596029/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com