https://grapeot.me/easy-and-cheap-cluster-building-on-aws.html

Thu 17 July 2014 , by Yan Wang | 2 Comments Linux Parallel github Image

Why?

It often requires a lot of computational resources to do machine learning / computer vision research, like extracting features from a lot of images, and training large-scale or many classifiers. Therefore people use more than one machines to do the task. The procedures are often like, copy executable/data files to all the machines, configure environments, manually divide the tasks, actually run the commands, and collect the results. In addition to the complicated workflow, another practical problem is where to get the machines. Maintaining your own cluster is definitely an option, an extremely expensive and time-costing option. Renting from AWS, especially using spot instances, is a much cheaper and more practical alternative.

But a lot of factors prevent them to be really useful (I assume you already know how spot instances work):

  • Spot instances don't have persistent storage, which means whatever you have on the hard disk may lost in the next minute. How to deal with this?
  • This property of spot instances also makes system configuration a problem -- how do you easily make a blank system usable?
  • How to efficiently copy bulk of data to AWS?
  • Manual task division and command execution doesn't sound right. How to make it easier and smarter (and faster)?

After quite a few months, I gradually accumulate a tool chain to handle all of these problems.

What will you get?

Here is an example of a 128-core 240GB cluster. It requires ~10 minutes to build it from scratch (or ~1 minute to build from AMI image), and costs about 1 dollar per hour. Like any AWS instances, the instances themselves cost nothing if you don't use them (by shutting them down). All your data will be on your hard disk and the loss due to spot request failure will be minimized. The best thing is, task submission is fairly simple -- one single line of bash command will do the job, like

cat cluster.sh | parallel --sshlogin 8/m1 --sshlogin 8/m2 --sshlogin 8/m3 --sshlogin 8/m4 bash -c '{}'

It will automatically distribute every line of cluster.sh to the four nodes, and display all the stdouts on your screen. Whenever a node has less than 8 tasks running, the script will automatically dispatch one to it.

How? (TL; DR)

  • Use automated script to do fast system configuration.
  • Use sshfs to do selective file transfer with compression, including training data transfer and result collection.
  • Use GNU parallel to do job submission.
  • AMI can also be used to further expedite virtual machine initialization

How?

  1. Create spot instances on AWS.
  2. On each machine, run curl https://grapeot.me/aws.sh | sh if that fits you. Orgit clone http://github.com/grapeot/debianinit and execute setup-ubuntu.sh to initialize the system. Note the script is personalized for me with python and vim support. Folk it to add your own stuffs.
  3. That's it for configuration. To submit jobs, use parallel. Let's look at this example:
cat cluster.sh | parallel --sshlogin 8/m1 --sshlogin 8/m2 --sshlogin 8/m3 --sshlogin 8/m4 bash -c '{}'

We already explained what it means, and here are more details. For switches like --sshlogin 8/m1--sshlogin means to send the task to remote machines. 8/m1 tells parallel to send it to a ssh host named m1, which you can configure in ~/.ssh/config, and maintain at most 8 tasks on that host. bash -c '{}' is the actual command to execute on the remote machine, with {} as the placeholder for each line from stdinparallel is much more flexible than this, and I'd leave the exploration of more switches and usage to you. :)

Easy and cheap cluster building on AWS backup的更多相关文章

  1. Nacos Cluster Building

    原文链接:https://www.javaspring.net/nacos/nacos-cluster-building Continue to talk about the Nacos build ...

  2. AWS backup

    shadowsocks ssserver -c /etc/shadowsocks/config.json start/stop/reset

  3. AWS 免费套餐

    AWS 免费套餐 转载自:https://aws.amazon.com/cn/free/?sc_channel=PS&sc_campaign=acquisition_CN&sc_pub ...

  4. AWS 存储服务(三)

    目录 AWS S3 业务场景 挑战 解决方案 S3的好处 S3 属性 存储桶 Buckets 对象 Object S3 特性 S3 操作 可用性和持久性 一致性 S3 定价策略 S3高级功能 存储级别 ...

  5. Awesome Go

    A curated list of awesome Go frameworks, libraries and software. Inspired by awesome-python. Contrib ...

  6. Go 语言相关的优秀框架,库及软件列表

    If you see a package or project here that is no longer maintained or is not a good fit, please submi ...

  7. Awesome Go (http://awesome-go.com/)

    A curated list of awesome Go frameworks, libraries and software. Inspired by awesome-python. Contrib ...

  8. Awesome Go精选的Go框架,库和软件的精选清单.A curated list of awesome Go frameworks, libraries and software

    Awesome Go      financial support to Awesome Go A curated list of awesome Go frameworks, libraries a ...

  9. RAC的QA

    RAC: Frequently Asked Questions [ID 220970.1]   修改时间 13-JAN-2011     类型 FAQ     状态 PUBLISHED   Appli ...

随机推荐

  1. 浅谈Linux文件系统

    Linux 与其他类 UNIX 系统一样并不区分文件与目录:目录是记录了其他文件名的文件.使用命令 mkdir 创建目录时,若期望创建的目录的名称与现有的文件名(或目录名)重复,则会创建失败. Lin ...

  2. JavaSE 字符串和正则表达式

    根据不懂的自己整理一下,跟着老师进度刷一遍课本,记录琐碎不懂知识 1.StringTokenizer类 String[] mess= {"整数部分","小数部分" ...

  3. 虚拟机安装---vm12+ubuntukylin16.04

    虚拟机安装及部分问题解决方案: https://blog.csdn.net/qq_35208390/article/details/78271743 安装vmware tools后,需设置共享文件夹才 ...

  4. 在vscode中,自定义代码片段,例vue组件的模板

    1---- 2----  输入vue,  选 vue.json 3----  在vue.json中编辑, 有说明 a.  tab符,要用空格, 也可以转义 4----   新建vue文件, 输入自定义 ...

  5. img 下方的4px像素问题

    问题:在一个div块里面放了一个图片,图片下面有内容,可以不管怎么调试,在火狐浏览器,IE6下.图片img底部多出了4个像素 解决:img样式中   vertical-align: top/middl ...

  6. 学习笔记16—Matlab 基础集

    1.常用相关 [r, p] = corr(X,Y), [r, p] = partialcorr(X,Y, Z) , 其中Z是协变量. 2.TD_age = importdata('F:\BrainAg ...

  7. vue2总结

    1.ref可跨页面取.vue文件的所有内容: <!--echart图自定义公用模板--> <echar-tem ref="echar"> </echa ...

  8. 在python中使用正则表达式(三)

    这里主要说一下贪婪匹配和非贪婪匹配  贪婪匹配:匹配尽可能多的字符:  非贪婪匹配:匹配尽可能少的字符 python的正则匹配默认是贪婪匹配 例子: >>> re.match(r'^ ...

  9. Lasso linear model实例 | Proliferation index | 评估单细胞的增殖指数

    背景:We developed a cell-cycle scoring approach that uses expression data to compute an index for ever ...

  10. Linux ----> debian中环境的常见配置

    环境: (debian 9)/(lubuntu18.0.4+virtualbox) 1.配置下载源: gedit /etc/apt/sources.list #163 deb http://mirro ...