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

Sha*_*Rav 5 python numpy cython

我写了一个用以下原型调用函数的程序:

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).
Run Code Online (Sandbox Code Playgroud)

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

所以问题是这个.在家里只有一台PC,显然我需要大约4.5年(10,000次运行×每次运行4小时= 40,000小时〜= 4.5年)才能在家完成所有运行.但是,我希望在一到两周内完成所有的运行.

我知道解决方案将涉及一次访问许多计算资源.什么是最好的(最快/最实惠,因为我的预算有限)这样做的方式?我必须购买一台强大的服务器(费用多少?)或者我可以在线运行吗?在这种情况下,通过这样做,我的propritary代码是否暴露?

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

nis*_*isc 9

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

import cloud
cloud.call(function)
Run Code Online (Sandbox Code Playgroud)

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


bru*_*ery 1

Process直接访问二进制文件上的数据还是将其缓存在内存中?减少 I/O 操作的使用应该会有所帮助。

另外,是否可以分成Process并行运行的单独函数?函数内部的数据依赖如何?

最后,您可以尝试一些像Amazon EC2这样的云计算服务(不要忘记阅读本文的工具),但它不会便宜(EC2 每小时 0.085 美元起) - 另一种选择是去大学使用计算机集群(它们现在很常见,但如果您认识那里的人会更容易)。