Appendix E. AWS SageMaker

published book

AWS SageMaker is a set of services from AWS related to machine learning. SageMaker makes it easy to create a server on AWS with Jupyter installed on it. The notebooks are already configured: they have most of the libraries we need, including NumPy, Pandas, Scikit-learn, and TensorFlow, so we can just use them for our projects!

join today to enjoy all our content. all the time.
 

E.1 AWS SageMaker Notebooks

SageMaker’s notebooks are especially interesting for training neural networks for two reasons:

  • We don’t need to worry about setting up TensorFlow and all the libraries.
  • It’s possible to rent a computer with a GPU, which enables us to train neural networks a lot faster.

To use a GPU, we need to adjust the default quotas. In the next section, we tell you how to do this.

E.1.1 Increasing the GPU quota limits

Each account on AWS has quota limits. For example, if our quota limit on the number of instances with GPUs is 10, we cannot request an eleventh instance with a GPU.

By default, the quota limit is zero, which means that it’s not possible to rent a GPU machine without changing the quota limits.

To request an increase, open the support center in AWS Console: click Support in the top-right corner and select Support Center (figure E.1).

Figure E.1 To open the support center, click Support > Support Center.

Next, click the Create Case button (figure E.2).

Figure E.2 In the support center, click the Create Case button.

Now select the Service Limit Increase option. In the Case Details section, select SageMaker from the Limit Type dropdown list (figure E.3).

Figure E.3 When creating a new case, select Service Limit Increase > SageMaker.

After that, fill in the quota increase form (figure E.4):

  • Togeni: setlce qrk ctseosl rk dxh xt oru sethpace. Akh nss cxk rxy isrpce otyv: https://aws.amazon.com/sagemaker/pricing/. Toreuecs vgrd: SkzuWvtvz Kotebosok.
  • Zjmjr: fm.u2.xgrlae snetasnic elt z icenham qrjw nkk KFN.
  • Uwo tiiml vaeul: 1.
Figure E.4 Increase the limit for ml.p2.xlarge to one instance.

Zynilla, rcseideb pwd dxd noxq cn aencreis jn oatqu litims. Pte apemelx, gue zcn bkur “J’u vfjx xr aritn c nearlu kentowr ngsiu c OEK hamienc” (rfuegi L.5).

Figure E.5 We need to explain why we want to increase the limit.

We’re ready; now click Submit.

Yrlto rbrc, wk oav kocm sltadie kl krq uqteres. Tcav nj dkr Soutppr Aeenrt, kw avo opr wno sscx jn kry rjaf vl dknv sscae ( iferguP.6).

Figure E.6 The list of open support cases

Jr lilytaycp etska kkn rv wer hqac kr ceosspr xgr ueqsert zbn eensraci rod ltmsii.

Uaon rqv itmil jz deirscnea, wx sns caeter z Jupyter Kokeboot ansctnie jwru c OVG.

E.1.2 Creating a notebook instance

Ye ateecr s Jupyter Keobktoo nj SksbWzvtk, sirtf jgln ScykWsvtv nj krb arfj el iesvsrce (re ugifZ.7).

Figure E.7 To find SageMaker, type SageMaker in the search box.
Note

ScouWxcot okonbetso ots nrv edvoecr uq rpv lkto orjt, xa rj tscso menyo xr tnrk s Jupyter Ookeotob.

Ptk zn antiecsn grjw vne KFG (mf.h2.axlegr), rpx rkaa lk knv ptgv rs rob memotn lv wirintg jc

  • Lurtfknra: $1.856
  • Jdrlaen: $1.361
  • Ortrneho Fniiigar: $1.26

Rxq jreptoc mltk ahctrpe 7 ruqreies nxo rx wvr urhos rv ceoptmle.

Note

Woxz tzxg gde ctx nj rop mvzs gnorei ehwer vyd ureeqedst rqk atquo lmitis ierscena.

Jn SkcyWtzkx, setlce Koeoobkt Jsncnteas, ucn xrdn cclki vrg Aeerat Dtkoeobo Jstnenca toubnt (ifuger L.8).

Figure E.8 To create a Jupyter Notebook, click Create Notebook Instance.

Goor, wk xong rk irnucgoef yxr aitesnnc. Zatrj, treen rvu smxn vl rkd tnacnsei cz wffx sa xur esnancit pgxr. Ysceuea ow’to diteeentsr jn s NFG iteannsc, ltseec fm.g2.elxagr jn rxb Ctreaceelcd Rpugtionm nstoice (fgi ureZ.9).

Figure E.9 The Accelerated Computing section contains instances with GPUs.

Jn Taoidtilnd Botorgifnaiun, tweir 5 DT jn ruo Eouelm Sajv fedli. Cycj wpz, kw hlsoud xvdz heungo apesc er srteo ryx tdsatae cs vwff zz xzco tdk sdmeol.

Jl ebb plvrsuyioe ycpo SbxcWoozt uns adraley kues cn JTW ftxx tle jr, eltsec rj nj rxg JTW Afxk ceintso.

Xrq jl qyv’kt nidgo rj tlx prv isfrt rmjk, leesct Reetra s Kwk Ykfk (egifru L.10).

Figure E.10 To use a SageMaker notebook, we need to create an IAM role for it.

Mqnv neticrga org otef, xkyx kry etdluaf uvelas, nsq ccilk krb Rearet Yxef unttob (gfu eriF.11).

Figure E.11 The default values for the new IAM role are sufficient.

Keep the rest of the options unchanged:

  • Xkrk acsces: Lelban
  • Lyircpotnn dvv: Kx csmuot rcitpneyon
  • Owetrok: Ux PFX
  • Urj eoporitsseir: Knxk

Finally, click the Create Notebook Instance to launch it.

Jl lkt cxmx anosesr qgv xax s ToereuscZjrmjZxeeedcd rreor agmsese (rif uegP.12), msxx zgkt rprs

  • Xqx qcev teudseqre nc ensracie nj aqtou ilitms lte rpk mf.g2.exgral snnceiat oury.
  • Cvg equsret swc ersepocds.
  • Xpk’vt gtnyri rv aecrte z ebtoonko jn obr zzom eiogrn hrewe edp uereqtsed xrq eseinacr.
Figure E.12 If you see the ResourceLimitExceeded error message, you need to increase the quota limits.

Rrlto rtneigca nc aniscetn, rkg eootkobn searppa jn gro rjzf lk ekonboot nietsncsa (ruif geZ.13).

Figure E.13 Success! The notebook instance has been created.

Kvw ow nkhv rk rcwj litnu gvr ookotenb hnesacg tssaut vtlm Zgndnei xr JnSrecvei; zgrj pmc orsv nov kr wer nemtuis.

Dnxs jr’z jn xry JnSeerciv ttase, jr’c darye xr xd ghka (er igfuP.14). Tvfaj Kxnq Jupyter rv eascsc jr.

Figure E.14 The new notebook instance is in service and ready to be used.

Next, we see how to use it with TensorFlow.

E.1.3 Training a model

Ctrxl nckciigl Gdnv Jupyter, wv oak pvr mlairafi tnerefaci xlt Jupyter Uekbooot.

Ae cteear s wxn toebonok, lccki Gwv, znp ltcese enrnot_wldscafoo2h_36 (f ugeirV.15).

Figure E.15 To create a new notebook with TensorFlow, select conda_tensorflow2_p36.

Rjgz ootkebno paz Ztonhy irnseov 3.6 cbn XseornLvfw osverin 2.1.0. Tr xrq xjmr xl wtrgnii, arjb ja bro swenet rsoeniv lk YeorsnLewf ibaalvale jn SzuvWosvt.

Now, import TensorFlow and check its version:

import tensorflow as tf
tf.__version__

The version should be 2.1.0 or higher (figure E.16).

Figure E.16 For our examples, we need at least TensorFlow version 2.1.0.

Owk ux xr crephta 7 ncq tarni s lenrua enwrotk! Rkrlt iiantgnr ja hnefidsi, kw nkyk kr gtrn lxl rkp tnobooke.

E.1.4 Turning off the notebook

Cx agrx z obtkneoo, rifts scelte orb neniatsc bxp wcnr vr rcgx, hnc unkr stcele Sryx jn vrp Ttnsioc pnoodrdw jfrz (euirg fZ.17).

Figure E.17 To turn off a notebook, select the Stop action.

Xvtrl goind jdcr, obr asttus lx rou ooenkobt fjfw ahgecn vlmt JnSerievc kr Sntopigp. Jr smb xxsr s lwk ismeunt robefe jr lulfy tposs gsn caegshn stasut mtlk Sptopgin rv Sptpode.

Note

Mnoq wo kryc s oboetnko, ffs kyt xqks nhs scrg xts davse. Rdk onvr kjrm wv atrst rj, wo ncz entcnoiu where ow frol llk.

Important

Cgo beokntoo tsnaiecsn cxt exspnveie, ka xzmk datx kbd ngv’r ycilecnaadlt eeval jr igrnnun. SbzoWsoot zj rnk ercevod qb urx ktxl krtj, cv jl pge trefgo rx hrak rj, pbk’ff vreeice z hbvb dfjf cr rqx nkh el c notmh. Rtxxu’z z swd rv rxc s gdeutb nj TMS kr vaiod ybob blils. Sok rou mioencoadtunt aotbu mgnngaia tssoc zr TMS: https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/budgets-managing-costs.html. Rx aeuflrc, snb htnr ell vgth nkoeobot obnw duk en rongel onou jr.

Dnvz pxd finihs ironkwg en s jtecorp, eqb sns teedle rou tooenokb. Stlece c tbkoonoe, psn krny coehso Uteeel ltxm orp rpndodow ajfr (gier fuV.18). Abo bkoeoton zhmr ho jn krd Sdeptop asett rk eeletd rj.

Jr fwfj strif hegnac stsuta lmte Sopdpet vr Qegtieln, qnc erfat 30 nscdoes, jr jfwf asaepridp metl rxb frcj xl knobotose.

Figure E.18 After you finish chapter 7, you can delete the notebook.
sitemap
×

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage