1
0

More than 1 year has passed since last update.

【個人的メモ】 EC2からSageMakerを扱う

Last updated at Posted at 2022-02-13

EC2(Linux) controls SageMaker instances

  • AWSのEC2インスタンスからSageMakerを操作して無駄遣い防止などをするためのメモ
  • シェルスクリプト作るときの参考用

前提

  • AWS Cli(v2) がLinux上にインストールされていること
  • aws configureでアクセスキーなどが設定済みであること

基本

$ aws sagemaker <サブコマンド> <パラメータ>

サブコマンド一覧を表示(ヘルプ)

$ aws sagemaker help

インスタンスの状態を確認する(json)

$ aws sagemaker list-notebook-instances
  • 下記形式のjsonを得られる
{
    "NotebookInstances": [
        {
            "NotebookInstanceName": "<インスタンス名>",
            "NotebookInstanceArn": "arn:aws:sagemaker:<リージョン>:<XXXXXXXXXX>:notebook-instance/<インスタンス名?>",
            "NotebookInstanceStatus": "<状態(Pending等)>",
            "Url": "<インスタンス名>-<ランダム値?>.<リージョン>.sagemaker.aws",
            "InstanceType": "<インスタンスのタイプ(ml.t2.medium等)>",
            "CreationTime": "20XX-XX-XXT00:00:00.000000+09:00",
            "LastModifiedTime": "20XX-XX-XXT00:00:00.000000+09:00",
            "NotebookInstanceLifecycleConfigName": "<ライフサイクル設定名>"
        }
    ]
}

インスタンス起動

$ aws sagemaker start-notebook-instance --notebook-instance-name <インスタンス名>
  • 終了コード:<0:正常><0以外:失敗>

インスタンス停止

$ aws sagemaker stop-notebook-instance --notebook-instance-name <インスタンス名>
  • 終了コード:<0:正常><0以外:失敗>

参考

sagemaker — AWS CLI 2.4.18 Command Reference

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0