AWS ec2 到 运行 python 使用 latex 和 OpenCV 的程序

AWS ec2 to run a python program using latex and OpenCV

我和一个朋友正在一起做一个机器学习项目。我们已经设法收集了大约 5,000 个 tex 文档(我们希望很快能达到大约 100,000 个)。我们有一个 python 脚本,我们 运行 在每个文档上进行一些文本操作,提取 tex 代码的特定部分,编译这些部分,将编译的部分转换为裁剪后的 PNG 图像,并搜索转换后的图像使用 OpenCV 裁剪图像的完整文本的 PNG。到目前为止,我们已经尝试过的文档的代码需要 30 秒到 2 分钟,因此我们确实需要加快速度。

我的任务是获得对计算机集群的访问权限,并弄清楚如何在这样的集群上实现我们的代码。有人建议我考虑使用 AWS,所以我注册了一个帐户,并在过去几个小时里一直在尝试弄清楚如何使用 EC2。我的方向是否正确,或者 AWS 的其他部分或其他更适合我的任务的部分?

无论我使用什么,它都必须能够访问我们代码中的各种 python 库以及 pdflatex 和全套 tex 包。这在 EC2 上可行吗?我几乎不知道如何使用 EC2(我已经设法启动了一些实例,但我如何将它们用于 运行 我的脚本?我是否需要将我的 python 脚本更改为适应并行处理,还是 EC2 以某种方式处理它?是否像启动 linux 实例并像在任何其他 linux 机器上一样安装我需要的程序一样简单?)。 None 的教程立即有用,我什至不确定 EC2 是否能够满足我的需求。任何建议表示赞赏。

我通常不会回答这种问题,但听起来你在做一些有趣的事情。那么让我们开始吧

Q1.

"We have a python script that we run on each document to do some text manipulation, extract particular parts of the tex code, compile the parts, convert the compiled parts to cropped PNG images, and search a converted PNG of the full tex for the cropped images using OpenCV.. we really need to speed it up"

也许你可以将 100,000 个文件分成 10 个部分并设置 处理软件的 10 个实例并并行执行 运行。

设置10个相同的实例,有很多方法,但其中一种更简单的方法是根据需要设置一台机器,拍摄快照,制作AMI,然后 使用 AMI 启动更多副本。

可能需要一个额外的步骤将搜索结果放入某些 一种中央数据库。

我对 OpenCV 一无所知,但有几条建议表明使用 G3 实例类型(它有一个 GPU)它可能运行得更快。 Google 对于 "Open CV on AWS"

Q2.

"trying to figure out how to use EC2 for the past few hours. Am I on the right track, or is there some other part of AWS or something else entirely that would be better suited to my task?"

EC2 是一个通用虚拟机,因此如果您已经拥有 运行 的代码 一些其他机器很容易将它移动到 EC2 EC2 有许多功能,但您可能会发现一个有趣的功能是 "spot instances",这些功能寿命短但便宜(通常是价格的 10%)实例启动

Q3.

Whatever I use, it has to have access to the various python libraries in our code and to pdflatex and the full set of tex packages. Is this possible on EC2?

是的,他们会像其他系统一样通过 pip 安装或从包中安装

Q4.

how do I use them to run my script? and do I need to change my python script to accomodate the parallel processing, or does EC2 take care of that somehow? is it as easy as starting a linux instance and installing the programs I need like I would on any other linux machine?

如上所述,您的基本任务似乎可以很好地扩展,您可能需要一个步骤来 整理结果。是的,它与任何其他 linux 机器

基本相同