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-create 2.7 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
  1. #!/bin/bash
  2. #set -e
  3. set -x
  4. # create symlinks to EBS volume
  5. echo "Creating symlinks"
  6. mkdir /home/ec2-user/SageMaker/.torch && ln -s /home/ec2-user/SageMaker/.torch /home/ec2-user/.torch
  7. mkdir /home/ec2-user/SageMaker/.fastai && ln -s /home/ec2-user/SageMaker/.fastai /home/ec2-user/.fastai
  8. # install the fastai library and dependencies
  9. echo "Install the fastai library and dependencies in new conda enviornment"
  10. cd /home/ec2-user/SageMaker
  11. # for explanations of the -mqyp flags, check `conda create --help`
  12. conda create -mqyp envs/fastai -c pytorch -c fastai fastai ipykernel
  13. echo "Finished installing environment"
  14. # clone the course notebooks
  15. echo "Clone the course repo"
  16. git clone https://github.com/fastai/course-v3.git /home/ec2-user/SageMaker/course-v3
  17. # install a custom start script which can be modified
  18. echo "Install the custom start script"
  19. cat > custom-start-script.sh <<\EOF
  20. #!/bin/bash
  21. if [ ! "$CONDA_DEFAULT_ENV" = "fastai" ]; then
  22. echo "Activate fastai conda environment"
  23. cd /home/ec2-user/SageMaker
  24. source activate envs/fastai
  25. fi
  26. echo "Updating fastai library"
  27. conda install -y -c fastai fastai
  28. echo "Getting latest version of course"
  29. cd /home/ec2-user/SageMaker/course-v3
  30. git pull
  31. echo "Finished running custom start script"
  32. EOF
  33. chmod u+x custom-start-script.sh
  34. # install a standard start script which is run each time the instance is started
  35. echo "Install the standard start script"
  36. cat > /home/ec2-user/SageMaker/.fastai/std-start-script.sh <<\EOF
  37. #!/bin/bash
  38. # install the ipython kernel
  39. echo "Install the ipython fastai kernel"
  40. cd /home/ec2-user/SageMaker
  41. source activate envs/fastai
  42. cuda_version=$(nvcc --version | awk 'match($0, /Cuda compilation tools, release [0-9]+\.[0-9]+/) { print substr($0, RSTART+32, RLENGTH-(RSTART+31))}')
  43. echo "Found Cuda version $cuda_version"
  44. # Install pytorch with correct cuda version
  45. # This command comes from the "Quick Start Locally" tool at https://pytorch.org/ as of 12 February, 2019
  46. # With selections Stable (1.0) / Linux / Conda / Python 3.6 / CUDA 9.0
  47. conda install -y pytorch torchvision cudatoolkit=${cuda_version} -c pytorch
  48. pip install --upgrade sagemaker
  49. python -m ipykernel install --name 'fastai' --display-name 'Python 3' --user
  50. echo "Install jupyter nbextension"
  51. source /home/ec2-user/anaconda3/bin/activate JupyterSystemEnv
  52. pip install jupyter_contrib_nbextensions
  53. jupyter contrib nbextensions install --user
  54. echo "Restarting jupyter notebook server"
  55. pkill -f jupyter-notebook
  56. EOF
  57. chmod u+x /home/ec2-user/SageMaker/.fastai/std-start-script.sh
  58. # put a empty file so start script knows if already run create script
  59. touch /home/ec2-user/.fastai/create_complete
  60. echo "Running standard start script"
  61. /home/ec2-user/SageMaker/.fastai/std-start-script.sh
  62. echo "Finished running onCreate script"
Tip!

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

Comments

Loading...