-
Notifications
You must be signed in to change notification settings - Fork 0
/
codeserver-on-sagemaker-notebook-with-gpu.yml
113 lines (97 loc) · 3.61 KB
/
codeserver-on-sagemaker-notebook-with-gpu.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
AWSTemplateFormatVersion: 2010-09-09
Description: >
Create a Sagemaker Notebook on a GPU instance with code-server pre-installed.
Parameters:
GPUInstance:
Type: String
Default: ml.g4dn.xlarge
Description: >
Specify a GPU instance to create a Sagemaker Notebook on.
You can find the full list here: https://aws.amazon.com/sagemaker/pricing/
Resources:
SagemakerNotebookInstance:
Type: AWS::SageMaker::NotebookInstance
Properties:
NotebookInstanceName: codeserver-on-sagemaker-notebook-with-gpu
InstanceType: !Ref GPUInstance
RoleArn: !GetAtt SageMakerRole.Arn
LifecycleConfigName: !GetAtt SagemakerNotebookInstanceLifecycleConfig.NotebookInstanceLifecycleConfigName
DirectInternetAccess: Enabled
SagemakerNotebookInstanceLifecycleConfig:
Type: AWS::SageMaker::NotebookInstanceLifecycleConfig
Properties:
NotebookInstanceLifecycleConfigName: codeserver-on-sagemaker-notebook-with-gpu
OnStart:
- Content:
Fn::Base64: |
#!/bin/bash
set -e
# Got inspiration from here
# https://aws.amazon.com/blogs/machine-learning/host-code-server-on-amazon-sagemaker/
ls -l /home/ec2-user/amazon-sagemaker-codeserver/install-scripts/notebook-instances/
sudo /home/ec2-user/amazon-sagemaker-codeserver/install-scripts/notebook-instances/setup-codeserver.sh
OnCreate:
- Content:
Fn::Base64: |
#!/bin/bash
set -e
cd /home/ec2-user
# Got inspiration from here
# https://aws.amazon.com/blogs/machine-learning/host-code-server-on-amazon-sagemaker/
curl -LO https://github.com/aws-samples/amazon-sagemaker-codeserver/releases/download/v0.1.5/amazon-sagemaker-codeserver-0.1.5.tar.gz
tar -xvzf amazon-sagemaker-codeserver-0.1.5.tar.gz
cd amazon-sagemaker-codeserver/install-scripts/notebook-instances
# show where we are for debugging purposes
echo $PWD
ls -l
chmod +x install-codeserver.sh
chmod +x setup-codeserver.sh
sudo ./install-codeserver.sh
sudo ./setup-codeserver.sh
SageMakerRole:
Type: AWS::IAM::Role
Properties:
RoleName: codeserver-on-sagemaker-notebook-with-gpu
Path: /
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Principal:
Service: sagemaker.amazonaws.com
Action: sts:AssumeRole
ManagedPolicyArns:
- !Ref SagemakerPolicy
MaxSessionDuration: 3600
SagemakerPolicy:
Type: AWS::IAM::ManagedPolicy
Properties:
ManagedPolicyName: codeserver-on-sagemaker-notebook-with-gpu
PolicyDocument:
Version: '2012-10-17'
Statement:
- Sid: S3
Effect: Allow
Action:
- s3:*
Resource:
- "*"
- Sid: Sagemaker
Effect: Allow
Action:
- sagemaker:*
Resource:
- "*"
- Sid: Cloudwatch
Effect: Allow
Action:
- logs:CreateLogGroup
- logs:DescribeLogGroups
- logs:GetLogGroupFields
- logs:CreateLogStream
- logs:DescribeLogStreams
- logs:PutLogEvents
- logs:GetLogEvents
- logs:FilterLogEvents
Resource:
- "*"