Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

sagemaker-cfn.yml 3.6 KB

You have to be logged in to leave a comment. Sign In
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
  1. Description: "Creates the SageMaker resources to run the fast.ai course on a SageMaker notebook instance."
  2. Parameters:
  3. NotebookName:
  4. Type: String
  5. Default: fastai
  6. Description: Enter the name of the SageMaker notebook instance. Deafault is fastai.
  7. InstanceType:
  8. Type: String
  9. Default: ml.p2.xlarge
  10. AllowedValues:
  11. - ml.p2.xlarge
  12. - ml.p3.2xlarge
  13. Description: Enter ml.p2.xlarge or ml.p3.2xlarge. Default is ml.p2.xlarge.
  14. VolumeSize:
  15. Type: Number
  16. Default: 50
  17. MinValue: 5
  18. MaxValue: 16384
  19. ConstraintDescription: Must be an integer between 5 (GB) and 16384 (16 TB).
  20. Description: Enter the size of the EBS volume in GB.
  21. Resources:
  22. SageMakerIamRole:
  23. Type: "AWS::IAM::Role"
  24. Properties:
  25. AssumeRolePolicyDocument:
  26. Version: "2012-10-17"
  27. Statement:
  28. -
  29. Effect: Allow
  30. Principal:
  31. Service: sagemaker.amazonaws.com
  32. Action: sts:AssumeRole
  33. Path: "/"
  34. ManagedPolicyArns:
  35. - "arn:aws:iam::aws:policy/AmazonSageMakerFullAccess"
  36. FastaiNbLifecycleConfig:
  37. Type: "AWS::SageMaker::NotebookInstanceLifecycleConfig"
  38. Properties:
  39. OnCreate:
  40. - Content:
  41. Fn::Base64: |
  42. #!/bin/bash
  43. sudo -H -i -u ec2-user bash << EOF
  44. # create symlinks to EBS volume
  45. echo "Creating symlinks"
  46. mkdir /home/ec2-user/SageMaker/.torch && ln -s /home/ec2-user/SageMaker/.torch /home/ec2-user/.torch
  47. mkdir /home/ec2-user/SageMaker/.fastai && ln -s /home/ec2-user/SageMaker/.fastai /home/ec2-user/.fastai
  48. # clone the course notebooks
  49. echo "Clone the course repo"
  50. git clone https://github.com/fastai/course-v3.git /home/ec2-user/SageMaker/course-v3
  51. echo "Finished running onCreate script"
  52. EOF
  53. OnStart:
  54. - Content:
  55. Fn::Base64: |
  56. #!/bin/bash
  57. sudo -H -i -u ec2-user bash << EOF
  58. echo "Creating symlinks"
  59. [ ! -L "/home/ec2-user/.torch" ] && ln -s /home/ec2-user/SageMaker/.torch /home/ec2-user/.torch
  60. [ ! -L "/home/ec2-user/.fastai" ] && ln -s /home/ec2-user/SageMaker/.fastai /home/ec2-user/.fastai
  61. echo "Install a new kernel for fastai with name 'Python 3'"
  62. source /home/ec2-user/anaconda3/bin/activate pytorch_p36
  63. python -m ipykernel install --name 'fastai' --display-name 'Python 3' --user
  64. # uncomment if you want to update PyTorch on every start
  65. #echo "Update PyTorch library"
  66. #conda install -y pytorch torchvision -c pytorch
  67. echo "Update fastai library"
  68. conda install -y fastai -c fastai
  69. echo "Install jupyter nbextension"
  70. source /home/ec2-user/anaconda3/bin/activate JupyterSystemEnv
  71. pip install jupyter_contrib_nbextensions
  72. jupyter contrib nbextensions install --user
  73. echo "Restarting jupyter notebook server"
  74. pkill -f jupyter-notebook
  75. echo "Getting latest version of fastai course"
  76. cd /home/ec2-user/SageMaker/course-v3
  77. git pull
  78. echo "Finished running onStart script"
  79. EOF
  80. FastaiNotebookInstance:
  81. Type: "AWS::SageMaker::NotebookInstance"
  82. Properties:
  83. InstanceType: !Ref InstanceType
  84. LifecycleConfigName: !GetAtt FastaiNbLifecycleConfig.NotebookInstanceLifecycleConfigName
  85. NotebookInstanceName: !Ref NotebookName
  86. RoleArn: !GetAtt SageMakerIamRole.Arn
  87. VolumeSizeInGB: !Ref VolumeSize
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...