乔乔

tchotcho的Python项目详细描述


pipeline statuscoverage report

乔乔

 (tchotcho)OOOOOoo...
         _____      oo
 _______ ||_||__n_n__I_
 |__T__|-|_T_|_________)>
  oo oo   o ()() ()() o\

当你准备好做实验的时候就训练EC2!在

这个工具包含了设置EC2实例以进行培训的方法包。在

安装

^{pr2}$

要求

  • 设置私钥/公钥(登录EC2,有助于克隆私有repo)
  • 安装rsync(将项目复制到EC2)
  • 安装ssh(在EC2上远程执行命令)
  • 通过(~/.aws/credentials)设置您的aws凭据配置文件

行动

可用命令:

❯ tchotcho --help
Usage: tchotcho [OPTIONS] COMMAND [ARGS]...

Options:
  --help  Show this message and exit.

Commands:
  info
  key
  shell
  spot
  stack

信息

更新

https://ec2instances.info/检索EC2实例列表并查询aws 寻找合适的培训对象。它在本地缓存结果以便以后使用 用法。在

帮助:

❯ AWS_PROFILE=dev tchotcho info update --help
Usage: tchotcho info update [OPTIONS]

  Update the GPU info json file

Options:
  --ownerid TEXT     Owner id used (we use ubuntu)  [default: 898082745236;
                     required]

  --namefilter TEXT  AMI filter by name  [default: Deep Learning AMI* 18.04*;
                     required]

  --limit INTEGER    Number of AMI image  [default: 5; required]
  --csv / --no-csv
  --region TEXT      List in region  [required]
  --help             Show this message and exit.

用法:

❯ AWS_PROFILE=dev env/bin/tchotcho info update
╒═══════════════╤═══════╤══════════════╤═══════════════════════╤═══════╤═══════════╤═════════════╤═══════════════╕
│ name          │   gpu │   gpu_memory │ gpu_model             │   cpu │    memory │ supported   │ price         │
╞═══════════════╪═══════╪══════════════╪═══════════════════════╪═══════╪═══════════╪═════════════╪═══════════════╡
│ p2.16xlarge   │    16 │          192 │ NVIDIA Tesla K80      │    64 │   732     │ True        │ 21.216        │
├───────────────┼───────┼──────────────┼───────────────────────┼───────┼───────────┼─────────────┼───────────────┤
│ p3dn.24xlarge │     8 │          256 │ NVIDIA Tesla V100     │    96 │   768     │ True        │ Not available │
├───────────────┼───────┼──────────────┼───────────────────────┼───────┼───────────┼─────────────┼───────────────┤
│ p2.8xlarge    │     8 │           96 │ NVIDIA Tesla K80      │    32 │   488     │ True        │ 10.608        │
...
╒══════════════╤═══════════════════════════════════════════════╤══════════════════════════╤═══════════════════════╕
│ region       │ name                                          │ date                     │ ami                   │
╞══════════════╪═══════════════════════════════════════════════╪══════════════════════════╪═══════════════════════╡
│ eu-central-1 │ Deep Learning AMI (Ubuntu 18.04) Version 29.0 │ 2020-05-20T14:57:39.000Z │ ami-062a3145bcf312c71 │
├──────────────┼───────────────────────────────────────────────┼──────────────────────────┼───────────────────────┤
│ eu-central-1 │ Deep Learning AMI (Ubuntu 18.04) Version 28.1 │ 2020-05-03T19:46:44.000Z │ ami-061aaaac62de85935 │
├──────────────┼───────────────────────────────────────────────┼──────────────────────────┼───────────────────────┤
│ eu-central-1 │ Deep Learning AMI (Ubuntu 18.04) Version 28.0 │ 2020-04-29T09:32:42.000Z │ ami-0f162c7e9b0e7d6f1 │
├──────────────┼───────────────────────────────────────────────┼──────────────────────────┼───────────────────────┤
│ eu-central-1 │ Deep Learning AMI (Ubuntu 18.04) Version 27.0 │ 2020-03-03T03:13:27.000Z │ ami-09633db638556dc39 │
├──────────────┼───────────────────────────────────────────────┼──────────────────────────┼───────────────────────┤
│ eu-central-1 │ Deep Learning AMI (Ubuntu 18.04) Version 26.0 │ 2019-12-02T22:09:33.000Z │ ami-0dcdcc4bc9e75005f │
╘══════════════╧═══════════════════════════════════════════════╧══════════════════════════╧═══════════════════════╛

列表

使用来自~/.tchotcho/gpu_info.jsonupdate命令的缓存结果。在

钥匙

用于管理EC2上的密钥的功能。在

❯ AWS_PROFILE=dev tchotcho key --help
Usage: tchotcho key [OPTIONS] COMMAND [ARGS]...

Options:
  --help  Show this message and exit.

Commands:
  create
  delete
  fingerprint
  import
  list

贝壳

目前实现了rsync和ssh。在

Rsync

同步本地实验到EC2。文件夹.git被排除,并且所有规则 从.gitignore应用。在

用法:

❯ tchotcho shell rsync --src . --dst ubuntu@1.2.3.4:/home/ubuntu/project --privat-key ~/.ssh/id_rsa

Ssh

在EC2上执行远程命令。在

用法:

❯ tchotcho shell ssh --host ubuntu@1.2.3.4 --privat-key ~/.ssh/id_rsa --cmd "pwd && date"

斑点

列出给定实例和地区的现货价格。在

❯ AWS_PROFILE=dev tchotcho spot list --help
Usage: tchotcho spot list [OPTIONS]

Options:
  --region TEXT     List spot prices in region
  --gpu / --no-gpu  Limit results to show only GPU instances
  --inst TEXT       List spot prices for instance type
  --csv / --no-csv
  --help            Show this message and exit.

列表

默认情况下,只显示受支持的GPU实例。在

用法:

❯ AWS_PROFILE=dev tchotcho spot list --region eu-central-1
╒════════════════╤════════════════════╤═════════════╕
│ InstanceType   │ AvailabilityZone   │   SpotPrice │
╞════════════════╪════════════════════╪═════════════╡
│ g4dn.xlarge    │ eu-central-1b      │      0.1974 │
├────────────────┼────────────────────┼─────────────┤
│ g4dn.xlarge    │ eu-central-1a      │      0.1974 │
├────────────────┼────────────────────┼─────────────┤
│ g3.4xlarge     │ eu-central-1b      │      0.4275 │
├────────────────┼────────────────────┼─────────────┤
│ g3.4xlarge     │ eu-central-1a      │      0.4275 │
...
│ g3.16xlarge    │ eu-central-1a      │      1.71   │
├────────────────┼────────────────────┼─────────────┤
│ g4dn.16xlarge  │ eu-central-1b      │      1.8593 │
├────────────────┼────────────────────┼─────────────┤
│ p3.8xlarge     │ eu-central-1b      │      4.5876 │
├────────────────┼────────────────────┼─────────────┤
│ p3.8xlarge     │ eu-central-1a      │      4.5876 │
├────────────────┼────────────────────┼─────────────┤
│ p3.16xlarge    │ eu-central-1b      │      9.1752 │
├────────────────┼────────────────────┼─────────────┤
│ p2.8xlarge     │ eu-central-1b      │     10.608  │
├────────────────┼────────────────────┼─────────────┤
│ p2.8xlarge     │ eu-central-1a      │     10.608  │
╘════════════════╧════════════════════╧═════════════╛

堆栈

这个工具的核心是通过cloudformation创建一个EC2实例。在

❯ AWS_PROFILE=dev tchotcho stack --help
Usage: tchotcho stack [OPTIONS] COMMAND [ARGS]...

Options:
  --help  Show this message and exit.

Commands:
  create
  delete
  list

创建

创建云信息堆栈。名称必须与导入的名称相同 输入aws。在

用法:

❯ AWS_PROFILE=dev tchotcho stack create --help
Usage: tchotcho stack create [OPTIONS]

Options:
  --name TEXT            Name of stack to create && key  [required]
  --ami TEXT             Name of ami to use  [default: ami-061aaaac62de85935;
                         required]

  --inst TEXT            Name of the instance to use  [required]
  --security_group TEXT  Name of the security group to use
  --subnet TEXT          Name of the subnet to use
  --price FLOAT          Name of the instance to use
  --size INTEGER         Size of the disk in GB
  --dry / --no-dry       Only print yaml no create
  --help                 Show this message and exit.

示例:

❯ AWS_PROFILE=dev tchotcho stack create --name test-dl --inst t2.medium --price 0.02 --dry

用户脚本

TODO目前只能通过api更改。解释一下:

  • 通过羊群等待apt
  • 向cloudformation发送信号,以便我们等待用户脚本安装完成

代码样式

我们使用flake8来确保代码质量,black来自动格式化代码。在

将其添加为git钩子:

$ flake8 --install-hook git
$ git config --bool flake8.strict true

托多

  • 尝试paramiko+scp成为纯python

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java语义理解递归反向字符串返回语句   java toString()方法打印空值   java大型IN子句   如何使用JavaSpring在JavaScriptjQuery中设置post路径   java ByteArrayOutputStream已上载到服务器   java为什么轮询在SocketIO上获取数据“无法加载请求的项”?   java源代码应该以UTF8格式保存   Java数据库轮询器?   在Java中将double转换为float   java AccessDeniedException:C:\Windows\System32\drivers\etc\hosts