Jupyter Notebook Tour of Amazon SageMaker Studio
Tags: aws, sagemaker, s3, iam
Published: 2022-01-23 11:10:41

“Challenges faced to find a solution where I can perform all machine learning activities”. I have found the solution as Amazon Sagemaker Studio in which it is easy to train, build and deploy machine learning models. In terms of cost and security perspective, it's cheaper and highly secure for users. And can easily integrate and migrate with other AWS services.

Amazon SageMaker is a cloud [machine-learning](https://en.wikipedia.org/wiki/Machine-learning) platform that was launched in November 2017. SageMaker enables developers to create, train, and deploy machine-learning (ML) models in the cloud. SageMaker also enables developers to deploy ML models on [embedded systems](https://en.wikipedia.org/wiki/Embedded_system) and [edge-devices](https://en.wikipedia.org/wiki/Edge_device). 

Amazon SageMaker Studio provides a single, web-based visual interface where you can perform all ML development steps, improving data science team productivity by up to 10x. SageMaker Studio gives you complete access, control, and visibility into each step required to build, train, and deploy models. You can quickly upload data, create new notebooks, train and tune models, move back and forth between steps to adjust experiments, compare results, and deploy models to production all in one place, making you much more productive. All ML development activities including notebooks, experiment management, automatic model creation, debugging, and model and data drift detection can be performed within SageMaker Studio.

In this post, you will get to know how to configure sagemaker studio and create a notebook in the sagemaker studio app. Here I have configured a sagemaker studio domain and user for sagemaker studio. And running an amazon sample project in jupyter notebook. Also having logs in cloudwatch.

#Prerequisites
You’ll need an Amazon Simple Storage Service for this post. [Getting started with Amazon Simple Storage Service](https://aws.amazon.com/s3/getting-started/) provides instructions on how to create a bucket in simple storage service. For this blog, I assume that I have created a s3 bucket.

#Architecture Overview
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hqdj3zlb5kem1qat0yuu.png)
The architecture diagram shows the overall deployment architecture with data flow, amazon sagemaker and s3 bucket.

#Solution overview
The blog post consists of the following phases:
1. Configuration of SageMaker Studio Domain
2. Add of User in SageMaker Studio and Creation of Notebook in Amazon SageMaker Studio App
3. Monitoring of S3 Bucket and Logs in Cloudwatch
I have a s3 bucket created as below →
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s4rbqbumvc2nn4ocf1hy.png)

##Phase 1: Configuration of SageMaker Studio Domain 
1. Open the SageMaker Studio console, get started creating a sagemaker domain as choose standard setup and click on configure button.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2aod9pwjbl8ufm7faoas.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5cbg0bj4mn2w5anfluqi.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5dctrep0akty6gclcu7p.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/carix6xavav9nndhjquv.png)
2. In general settings, Choose IAM as authentication and create a new role in permission. While creating a new role, we can specify the bucket created or choose any s3 bucket option. Then click on create role. In the network and storage section, choose default vpc with any subnet and default security group. Choose the public internet only option. Leave the encryption option.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ic5b89ammavstqjjh0jv.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wxi6wjt60ps8pa2tlx8y.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uxsryszjowa72ai3wsc4.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7a7p0nx60qc2gcwk9256.png)
3. In the notebook sharing configuration section, enable the sharing option and leave all options as default. And click on the submit button. Once the domain is created, we can proceed for user creation in it.  
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cqjvkyxdnmdnsmtnukuv.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wu0ufjswhjhafhyepwu4.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lvvram9czrhv9xjdjp12.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i61lrq1lul8a5ko1dozp.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2oij3on01fkjmbd7pxbn.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0ztu9ehr7p5ziiaicnau.png)

##Phase 2: Add of User in SageMaker Studio and Creation of Notebook in Amazon SageMaker Studio App 
1. Create a user in sagemaker studio by clicking on add user button. Give the user name as studio-gargee-demo and leave the default execution role. And leave all other options as default and create a user. Once the user is created, launch the studio app by selecting the launch app dropdown option. We navigate to the Amazon sagemaker studio jupyter server app. And we can also edit the sagemaker domain settings.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ngk56800pzl8f3b3plhx.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qc5v97m6bsdcmqdoy349.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4u61q1iw5mvv1hw78qau.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p8umklolzu52zujncyvl.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9b3nqdc24u7x05l9zbyz.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0szub15ery3jhtaia76d.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ttdxxzh1a3uwjc5ribg9.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w5esys0jl65tkq5ur0m3.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8xezb0ko2il8xz6b6n8i.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3f2dbfs9b2ui1d2zgi80.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6d4llu6icicp2icbp4qt.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dkgbuxdettrbyagt4vks.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lxbtonyd2acpkv03lzgm.png)
2. In jupyter app, Goto Git option and clone a repository as amazon sagemaker examples. Check various options available in the app such as to create a new console or project, to see whether the project is running, how to share the running snapshots, how to change the instance type and so on in below screenshots. Also how create a directory in a notebook and how to close and shutdown it. 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sdz9rqwmue5kgagyg0i3.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/erzacn5tiwkadav9p81x.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gp6zzetd6edopfc0uhbp.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ex17jtbh542upcmna80c.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ny4l3xtm22se2e1w5h1v.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u46qcloixb6cxaaywgr7.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jop2tik6yyvmjoq0a8j4.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n18asmgvyebcdppamzvc.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fthrsw6o6nns2nep2kut.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ybhpwy2fs504fkt0pfd1.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n0h6un8t9r8jp3nb27kq.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6g2a2fx9uo2zbw6xodyu.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4tbrbjs4gf9g78r8sj4f.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1cqpgfzlg8ph4l1iou1r.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h6yjxbk0vfzjiwuzzgjq.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/isawvh67tcppr06gr920.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3kl6d8yoqq89wh5wxr8w.png)

##Phase 3: Monitoring of S3 Bucket and Logs in Cloudwatch  
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8sfbi699i9fdvpbfh4oq.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o0spko7rj432nr8yzahi.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9tvxzyft82p940ghc7tv.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bcplovcdyx0d144wtduh.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nq425odkgudkbdtyqanx.png)

#Clean-up
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m74enpj7ohng3kc2g2hn.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fj3s96hy51pkg6omk5pr.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t01p6glh7nb5d68ovt0z.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5l1s4vj67r2uwd47fe43.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0xlcao0fokdef52w3nq1.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/skwppgxh4954ho05rfam.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iydpjs8ugj15siv32m2l.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rfb88wdevzie3u7r28df.png)

#Pricing
I review the pricing and estimated cost of this example. 
Cost of Amazon SageMaker →
$0.00 for Studio-Notebook:ml.t3.medium per hour under monthly free tier = 0.072 Hrs = $0.0 
$0.054 for Studio-Notebook:ml.t3.medium per hour = 0 Hrs = $0.0
Total = $(0.0+0.0) = $0.0
Cost of Simple Storage Service = $0.1 
Cost of Cloudwatch = $0.0
Total Cost = $(0.0+0.1+0.0) = $0.1

#Summary
In this post, I showed “how to configure sagemaker studio and create a notebook in the sagemaker studio app”.

For more details on Amazon SageMaker Studio, Checkout Get started Amazon SageMaker Studio, open the [Amazon SageMaker Studio Console](https://ap-south-1.console.aws.amazon.com/sagemaker/home?region=ap-south-1#/landing). To learn more, read the [Amazon SageMaker Studio Documentation](https://docs.aws.amazon.com/sagemaker/?id=docs_gateway).

Thanks for reading!

Connect with me: [Linkedin](https://www.linkedin.com/in/gargee-bhatnagar-6b7223114)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/38sdi4nsp89fnui8h7dk.png)