import{S as Po,i as xo,s as zo,e as r,k as m,w as u,t as c,M as Ho,c as l,d as a,m as d,a as s,x as h,h as p,b as n,G as o,g as i,y as f,L as qo,q as M,o as w,B as y,v as Ko}from"../chunks/vendor-hf-doc-builder.js";import{I as ie}from"../chunks/IconCopyLink-hf-doc-builder.js";import{C as S}from"../chunks/CodeBlock-hf-doc-builder.js";function Do(so){let J,Ge,j,g,fe,V,ba,Me,va,We,k,Ja,R,ja,Ta,Xe,T,B,we,Q,Ua,ye,Aa,Ne,ne,$a,Ye,F,Se,b,Ia,P,be,_a,ga,ve,ka,Ba,Ve,x,Re,U,C,Je,z,Ca,je,Ea,Qe,E,Za,H,Te,Ga,Wa,Fe,q,Pe,A,Z,Ue,K,Xa,Ae,Na,xe,v,Ya,$e,Sa,Va,D,Ie,Ra,Qa,ze,L,He,ce,Fa,qe,O,Ke,$,G,_e,ee,Pa,ge,xa,De,pe,za,Le,I,W,ke,ae,Ha,Be,qa,Oe,me,Ka,ea,oe,aa,de,Da,oa,te,ta,_,X,Ce,re,La,Ee,Oa,ra,N,eo,Ze,ao,oo,la,le,sa,Y,to,se,ro,lo,ia;return V=new ie({}),Q=new ie({}),F=new S({props:{code:"cGlwJTIwaW5zdGFsbCUyMGFjY2VsZXJhdGU=",highlighted:"pip install accelerate"}}),x=new S({props:{code:"ZnJvbSUyMGFjY2VsZXJhdGUlMjBpbXBvcnQlMjBBY2NlbGVyYXRvciUwQSUwQWFjY2VsZXJhdG9yJTIwJTNEJTIwQWNjZWxlcmF0b3IoKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> accelerate <span class="hljs-keyword">import</span> Accelerator

<span class="hljs-meta">&gt;&gt;&gt; </span>accelerator = Accelerator()`}}),z=new ie({}),q=new S({props:{code:"dHJhaW5fZGF0YWxvYWRlciUyQyUyMGV2YWxfZGF0YWxvYWRlciUyQyUyMG1vZGVsJTJDJTIwb3B0aW1pemVyJTIwJTNEJTIwYWNjZWxlcmF0b3IucHJlcGFyZSglMEElMjAlMjAlMjAlMjB0cmFpbl9kYXRhbG9hZGVyJTJDJTIwZXZhbF9kYXRhbG9hZGVyJTJDJTIwbW9kZWwlMkMlMjBvcHRpbWl6ZXIlMEEp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>train_dataloader, eval_dataloader, model, optimizer = accelerator.prepare(
<span class="hljs-meta">... </span>    train_dataloader, eval_dataloader, model, optimizer
<span class="hljs-meta">... </span>)`}}),K=new ie({}),L=new S({props:{code:"Zm9yJTIwZXBvY2glMjBpbiUyMHJhbmdlKG51bV9lcG9jaHMpJTNBJTBBJTIwJTIwJTIwJTIwZm9yJTIwYmF0Y2glMjBpbiUyMHRyYWluX2RhdGFsb2FkZXIlM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBvdXRwdXRzJTIwJTNEJTIwbW9kZWwoKipiYXRjaCklMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBsb3NzJTIwJTNEJTIwb3V0cHV0cy5sb3NzJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwYWNjZWxlcmF0b3IuYmFja3dhcmQobG9zcyklMEElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBvcHRpbWl6ZXIuc3RlcCgpJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwbHJfc2NoZWR1bGVyLnN0ZXAoKSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMG9wdGltaXplci56ZXJvX2dyYWQoKSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHByb2dyZXNzX2Jhci51cGRhdGUoMSk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">for</span> epoch <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(num_epochs):
<span class="hljs-meta">... </span>    <span class="hljs-keyword">for</span> batch <span class="hljs-keyword">in</span> train_dataloader:
<span class="hljs-meta">... </span>        outputs = model(**batch)
<span class="hljs-meta">... </span>        loss = outputs.loss
<span class="hljs-meta">... </span>        accelerator.backward(loss)

<span class="hljs-meta">... </span>        optimizer.step()
<span class="hljs-meta">... </span>        lr_scheduler.step()
<span class="hljs-meta">... </span>        optimizer.zero_grad()
<span class="hljs-meta">... </span>        progress_bar.update(<span class="hljs-number">1</span>)`}}),O=new S({props:{code:"JTJCJTIwZnJvbSUyMGFjY2VsZXJhdGUlMjBpbXBvcnQlMjBBY2NlbGVyYXRvciUwQSUyMCUyMGZyb20lMjB0cmFuc2Zvcm1lcnMlMjBpbXBvcnQlMjBBZGFtVyUyQyUyMEF1dG9Nb2RlbEZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24lMkMlMjBnZXRfc2NoZWR1bGVyJTBBJTBBJTJCJTIwYWNjZWxlcmF0b3IlMjAlM0QlMjBBY2NlbGVyYXRvcigpJTBBJTBBJTIwJTIwbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JTZXF1ZW5jZUNsYXNzaWZpY2F0aW9uLmZyb21fcHJldHJhaW5lZChjaGVja3BvaW50JTJDJTIwbnVtX2xhYmVscyUzRDIpJTBBJTIwJTIwb3B0aW1pemVyJTIwJTNEJTIwQWRhbVcobW9kZWwucGFyYW1ldGVycygpJTJDJTIwbHIlM0QzZS01KSUwQSUwQS0lMjBkZXZpY2UlMjAlM0QlMjB0b3JjaC5kZXZpY2UoJTIyY3VkYSUyMiklMjBpZiUyMHRvcmNoLmN1ZGEuaXNfYXZhaWxhYmxlKCklMjBlbHNlJTIwdG9yY2guZGV2aWNlKCUyMmNwdSUyMiklMEEtJTIwbW9kZWwudG8oZGV2aWNlKSUwQSUwQSUyQiUyMHRyYWluX2RhdGFsb2FkZXIlMkMlMjBldmFsX2RhdGFsb2FkZXIlMkMlMjBtb2RlbCUyQyUyMG9wdGltaXplciUyMCUzRCUyMGFjY2VsZXJhdG9yLnByZXBhcmUoJTBBJTJCJTIwJTIwJTIwJTIwJTIwdHJhaW5fZGF0YWxvYWRlciUyQyUyMGV2YWxfZGF0YWxvYWRlciUyQyUyMG1vZGVsJTJDJTIwb3B0aW1pemVyJTBBJTJCJTIwKSUwQSUwQSUyMCUyMG51bV9lcG9jaHMlMjAlM0QlMjAzJTBBJTIwJTIwbnVtX3RyYWluaW5nX3N0ZXBzJTIwJTNEJTIwbnVtX2Vwb2NocyUyMColMjBsZW4odHJhaW5fZGF0YWxvYWRlciklMEElMjAlMjBscl9zY2hlZHVsZXIlMjAlM0QlMjBnZXRfc2NoZWR1bGVyKCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMmxpbmVhciUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMG9wdGltaXplciUzRG9wdGltaXplciUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMG51bV93YXJtdXBfc3RlcHMlM0QwJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwbnVtX3RyYWluaW5nX3N0ZXBzJTNEbnVtX3RyYWluaW5nX3N0ZXBzJTBBJTIwJTIwKSUwQSUwQSUyMCUyMHByb2dyZXNzX2JhciUyMCUzRCUyMHRxZG0ocmFuZ2UobnVtX3RyYWluaW5nX3N0ZXBzKSklMEElMEElMjAlMjBtb2RlbC50cmFpbigpJTBBJTIwJTIwZm9yJTIwZXBvY2glMjBpbiUyMHJhbmdlKG51bV9lcG9jaHMpJTNBJTBBJTIwJTIwJTIwJTIwJTIwJTIwZm9yJTIwYmF0Y2glMjBpbiUyMHRyYWluX2RhdGFsb2FkZXIlM0ElMEEtJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwYmF0Y2glMjAlM0QlMjAlN0JrJTNBJTIwdi50byhkZXZpY2UpJTIwZm9yJTIwayUyQyUyMHYlMjBpbiUyMGJhdGNoLml0ZW1zKCklN0QlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBvdXRwdXRzJTIwJTNEJTIwbW9kZWwoKipiYXRjaCklMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBsb3NzJTIwJTNEJTIwb3V0cHV0cy5sb3NzJTBBLSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGxvc3MuYmFja3dhcmQoKSUwQSUyQiUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGFjY2VsZXJhdG9yLmJhY2t3YXJkKGxvc3MpJTBBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwb3B0aW1pemVyLnN0ZXAoKSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGxyX3NjaGVkdWxlci5zdGVwKCklMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBvcHRpbWl6ZXIuemVyb19ncmFkKCklMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBwcm9ncmVzc19iYXIudXBkYXRlKDEp",highlighted:`<span class="hljs-addition">+ from accelerate import Accelerator</span>
  from transformers import AdamW, AutoModelForSequenceClassification, get_scheduler

<span class="hljs-addition">+ accelerator = Accelerator()</span>

  model = AutoModelForSequenceClassification.from_pretrained(checkpoint, num_labels=2)
  optimizer = AdamW(model.parameters(), lr=3e-5)

<span class="hljs-deletion">- device = torch.device(&quot;cuda&quot;) if torch.cuda.is_available() else torch.device(&quot;cpu&quot;)</span>
<span class="hljs-deletion">- model.to(device)</span>

<span class="hljs-addition">+ train_dataloader, eval_dataloader, model, optimizer = accelerator.prepare(</span>
<span class="hljs-addition">+     train_dataloader, eval_dataloader, model, optimizer</span>
<span class="hljs-addition">+ )</span>

  num_epochs = 3
  num_training_steps = num_epochs * len(train_dataloader)
  lr_scheduler = get_scheduler(
      &quot;linear&quot;,
      optimizer=optimizer,
      num_warmup_steps=0,
      num_training_steps=num_training_steps
  )

  progress_bar = tqdm(range(num_training_steps))

  model.train()
  for epoch in range(num_epochs):
      for batch in train_dataloader:
<span class="hljs-deletion">-         batch = {k: v.to(device) for k, v in batch.items()}</span>
          outputs = model(**batch)
          loss = outputs.loss
<span class="hljs-deletion">-         loss.backward()</span>
<span class="hljs-addition">+         accelerator.backward(loss)</span>

          optimizer.step()
          lr_scheduler.step()
          optimizer.zero_grad()
          progress_bar.update(1)`}}),ee=new ie({}),ae=new ie({}),oe=new S({props:{code:"YWNjZWxlcmF0ZSUyMGNvbmZpZw==",highlighted:"accelerate config"}}),te=new S({props:{code:"YWNjZWxlcmF0ZSUyMGxhdW5jaCUyMHRyYWluLnB5",highlighted:"accelerate launch train.py"}}),re=new ie({}),le=new S({props:{code:"ZnJvbSUyMGFjY2VsZXJhdGUlMjBpbXBvcnQlMjBub3RlYm9va19sYXVuY2hlciUwQSUwQW5vdGVib29rX2xhdW5jaGVyKHRyYWluaW5nX2Z1bmN0aW9uKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> accelerate <span class="hljs-keyword">import</span> notebook_launcher

<span class="hljs-meta">&gt;&gt;&gt; </span>notebook_launcher(training_function)`}}),{c(){J=r("meta"),Ge=m(),j=r("h1"),g=r("a"),fe=r("span"),u(V.$$.fragment),ba=m(),Me=r("span"),va=c("Treinamento distribu\xEDdo com o \u{1F917} Accelerate"),We=m(),k=r("p"),Ja=c(`O paralelismo surgiu como uma estrat\xE9gia para treinar modelos grandes em hardware limitado e aumentar a velocidade
de treinamento em v\xE1rias \xF3rdens de magnitude. Na Hugging Face criamos a biblioteca `),R=r("a"),ja=c("\u{1F917} Accelerate"),Ta=c(`
para ajudar os usu\xE1rios a treinar modelos \u{1F917} Transformers com qualquer configura\xE7\xE3o distribu\xEDda, seja em uma m\xE1quina
com m\xFAltiplos GPUs ou em m\xFAltiplos GPUs distribuidos entre muitas m\xE1quinas. Neste tutorial, voc\xEA ir\xE1 aprender como
personalizar seu la\xE7o de treinamento de PyTorch para poder treinar em ambientes distribu\xEDdos.`),Xe=m(),T=r("h2"),B=r("a"),we=r("span"),u(Q.$$.fragment),Ua=m(),ye=r("span"),Aa=c("Configura\xE7\xE3o"),Ne=m(),ne=r("p"),$a=c("De in\xEDcio, instale o \u{1F917} Accelerate:"),Ye=m(),u(F.$$.fragment),Se=m(),b=r("p"),Ia=c("Logo, devemos importar e criar um objeto "),P=r("a"),be=r("code"),_a=c("Accelerator"),ga=c(`.
O `),ve=r("code"),ka=c("Accelerator"),Ba=c(` detectar\xE1 autom\xE1ticamente a configura\xE7\xE3o distribu\xEDda dispon\xEDvel e inicializar\xE1 todos os
componentes necess\xE1rios para o treinamento. N\xE3o h\xE1 necessidade portanto de especificar o dispositivo onde deve colocar seu modelo.`),Ve=m(),u(x.$$.fragment),Re=m(),U=r("h2"),C=r("a"),Je=r("span"),u(z.$$.fragment),Ca=m(),je=r("span"),Ea=c("Preparando a acelera\xE7\xE3o"),Qe=m(),E=r("p"),Za=c("Passe todos os objetos relevantes ao treinamento para o m\xE9todo "),H=r("a"),Te=r("code"),Ga=c("prepare"),Wa=c(`.
Isto inclui os DataLoaders de treino e evalua\xE7\xE3o, um modelo e um otimizador:`),Fe=m(),u(q.$$.fragment),Pe=m(),A=r("h2"),Z=r("a"),Ue=r("span"),u(K.$$.fragment),Xa=m(),Ae=r("span"),Na=c("Backward"),xe=m(),v=r("p"),Ya=c("Por \xFAltimo, substitua o "),$e=r("code"),Sa=c("loss.backward()"),Va=c(" padr\xE3o em seu la\xE7o de treinamento com o m\xE9todo "),D=r("a"),Ie=r("code"),Ra=c("backward"),Qa=c(" do \u{1F917} Accelerate:"),ze=m(),u(L.$$.fragment),He=m(),ce=r("p"),Fa=c(`Como se poder ver no seguinte c\xF3digo, s\xF3 precisar\xE1 adicionar quatro linhas de c\xF3digo ao seu la\xE7o de treinamento
para habilitar o treinamento distribu\xEDdo!`),qe=m(),u(O.$$.fragment),Ke=m(),$=r("h2"),G=r("a"),_e=r("span"),u(ee.$$.fragment),Pa=m(),ge=r("span"),xa=c("Treinamento"),De=m(),pe=r("p"),za=c("Quando tiver adicionado as linhas de c\xF3digo relevantes, inicie o treinamento por um script ou notebook como o Colab."),Le=m(),I=r("h3"),W=r("a"),ke=r("span"),u(ae.$$.fragment),Ha=m(),Be=r("span"),qa=c("Treinamento em um Script"),Oe=m(),me=r("p"),Ka=c("Se estiver rodando seu treinamento em um Script, execute o seguinte comando para criar e guardar um arquivo de configura\xE7\xE3o:"),ea=m(),u(oe.$$.fragment),aa=m(),de=r("p"),Da=c("Comece o treinamento com:"),oa=m(),u(te.$$.fragment),ta=m(),_=r("h3"),X=r("a"),Ce=r("span"),u(re.$$.fragment),La=m(),Ee=r("span"),Oa=c("Treinamento em um Notebook"),ra=m(),N=r("p"),eo=c(`O \u{1F917} Accelerate pode rodar em um notebook, por exemplo, se estiver planejando usar as TPUs do Google Colab.
Encapsule o c\xF3digo respons\xE1vel pelo treinamento de uma fun\xE7\xE3o e passe-o ao `),Ze=r("code"),ao=c("notebook_launcher"),oo=c(":"),la=m(),u(le.$$.fragment),sa=m(),Y=r("p"),to=c("Para obter mais informa\xE7\xF5es sobre o \u{1F917} Accelerate e suas numerosas fun\xE7\xF5es, consulte a "),se=r("a"),ro=c("documentaci\xF3n"),lo=c("."),this.h()},l(e){const t=Ho('[data-svelte="svelte-1phssyn"]',document.head);J=l(t,"META",{name:!0,content:!0}),t.forEach(a),Ge=d(e),j=l(e,"H1",{class:!0});var na=s(j);g=l(na,"A",{id:!0,class:!0,href:!0});var io=s(g);fe=l(io,"SPAN",{});var no=s(fe);h(V.$$.fragment,no),no.forEach(a),io.forEach(a),ba=d(na),Me=l(na,"SPAN",{});var co=s(Me);va=p(co,"Treinamento distribu\xEDdo com o \u{1F917} Accelerate"),co.forEach(a),na.forEach(a),We=d(e),k=l(e,"P",{});var ca=s(k);Ja=p(ca,`O paralelismo surgiu como uma estrat\xE9gia para treinar modelos grandes em hardware limitado e aumentar a velocidade
de treinamento em v\xE1rias \xF3rdens de magnitude. Na Hugging Face criamos a biblioteca `),R=l(ca,"A",{href:!0,rel:!0});var po=s(R);ja=p(po,"\u{1F917} Accelerate"),po.forEach(a),Ta=p(ca,`
para ajudar os usu\xE1rios a treinar modelos \u{1F917} Transformers com qualquer configura\xE7\xE3o distribu\xEDda, seja em uma m\xE1quina
com m\xFAltiplos GPUs ou em m\xFAltiplos GPUs distribuidos entre muitas m\xE1quinas. Neste tutorial, voc\xEA ir\xE1 aprender como
personalizar seu la\xE7o de treinamento de PyTorch para poder treinar em ambientes distribu\xEDdos.`),ca.forEach(a),Xe=d(e),T=l(e,"H2",{class:!0});var pa=s(T);B=l(pa,"A",{id:!0,class:!0,href:!0});var mo=s(B);we=l(mo,"SPAN",{});var uo=s(we);h(Q.$$.fragment,uo),uo.forEach(a),mo.forEach(a),Ua=d(pa),ye=l(pa,"SPAN",{});var ho=s(ye);Aa=p(ho,"Configura\xE7\xE3o"),ho.forEach(a),pa.forEach(a),Ne=d(e),ne=l(e,"P",{});var fo=s(ne);$a=p(fo,"De in\xEDcio, instale o \u{1F917} Accelerate:"),fo.forEach(a),Ye=d(e),h(F.$$.fragment,e),Se=d(e),b=l(e,"P",{});var ue=s(b);Ia=p(ue,"Logo, devemos importar e criar um objeto "),P=l(ue,"A",{href:!0,rel:!0});var Mo=s(P);be=l(Mo,"CODE",{});var wo=s(be);_a=p(wo,"Accelerator"),wo.forEach(a),Mo.forEach(a),ga=p(ue,`.
O `),ve=l(ue,"CODE",{});var yo=s(ve);ka=p(yo,"Accelerator"),yo.forEach(a),Ba=p(ue,` detectar\xE1 autom\xE1ticamente a configura\xE7\xE3o distribu\xEDda dispon\xEDvel e inicializar\xE1 todos os
componentes necess\xE1rios para o treinamento. N\xE3o h\xE1 necessidade portanto de especificar o dispositivo onde deve colocar seu modelo.`),ue.forEach(a),Ve=d(e),h(x.$$.fragment,e),Re=d(e),U=l(e,"H2",{class:!0});var ma=s(U);C=l(ma,"A",{id:!0,class:!0,href:!0});var bo=s(C);Je=l(bo,"SPAN",{});var vo=s(Je);h(z.$$.fragment,vo),vo.forEach(a),bo.forEach(a),Ca=d(ma),je=l(ma,"SPAN",{});var Jo=s(je);Ea=p(Jo,"Preparando a acelera\xE7\xE3o"),Jo.forEach(a),ma.forEach(a),Qe=d(e),E=l(e,"P",{});var da=s(E);Za=p(da,"Passe todos os objetos relevantes ao treinamento para o m\xE9todo "),H=l(da,"A",{href:!0,rel:!0});var jo=s(H);Te=l(jo,"CODE",{});var To=s(Te);Ga=p(To,"prepare"),To.forEach(a),jo.forEach(a),Wa=p(da,`.
Isto inclui os DataLoaders de treino e evalua\xE7\xE3o, um modelo e um otimizador:`),da.forEach(a),Fe=d(e),h(q.$$.fragment,e),Pe=d(e),A=l(e,"H2",{class:!0});var ua=s(A);Z=l(ua,"A",{id:!0,class:!0,href:!0});var Uo=s(Z);Ue=l(Uo,"SPAN",{});var Ao=s(Ue);h(K.$$.fragment,Ao),Ao.forEach(a),Uo.forEach(a),Xa=d(ua),Ae=l(ua,"SPAN",{});var $o=s(Ae);Na=p($o,"Backward"),$o.forEach(a),ua.forEach(a),xe=d(e),v=l(e,"P",{});var he=s(v);Ya=p(he,"Por \xFAltimo, substitua o "),$e=l(he,"CODE",{});var Io=s($e);Sa=p(Io,"loss.backward()"),Io.forEach(a),Va=p(he," padr\xE3o em seu la\xE7o de treinamento com o m\xE9todo "),D=l(he,"A",{href:!0,rel:!0});var _o=s(D);Ie=l(_o,"CODE",{});var go=s(Ie);Ra=p(go,"backward"),go.forEach(a),_o.forEach(a),Qa=p(he," do \u{1F917} Accelerate:"),he.forEach(a),ze=d(e),h(L.$$.fragment,e),He=d(e),ce=l(e,"P",{});var ko=s(ce);Fa=p(ko,`Como se poder ver no seguinte c\xF3digo, s\xF3 precisar\xE1 adicionar quatro linhas de c\xF3digo ao seu la\xE7o de treinamento
para habilitar o treinamento distribu\xEDdo!`),ko.forEach(a),qe=d(e),h(O.$$.fragment,e),Ke=d(e),$=l(e,"H2",{class:!0});var ha=s($);G=l(ha,"A",{id:!0,class:!0,href:!0});var Bo=s(G);_e=l(Bo,"SPAN",{});var Co=s(_e);h(ee.$$.fragment,Co),Co.forEach(a),Bo.forEach(a),Pa=d(ha),ge=l(ha,"SPAN",{});var Eo=s(ge);xa=p(Eo,"Treinamento"),Eo.forEach(a),ha.forEach(a),De=d(e),pe=l(e,"P",{});var Zo=s(pe);za=p(Zo,"Quando tiver adicionado as linhas de c\xF3digo relevantes, inicie o treinamento por um script ou notebook como o Colab."),Zo.forEach(a),Le=d(e),I=l(e,"H3",{class:!0});var fa=s(I);W=l(fa,"A",{id:!0,class:!0,href:!0});var Go=s(W);ke=l(Go,"SPAN",{});var Wo=s(ke);h(ae.$$.fragment,Wo),Wo.forEach(a),Go.forEach(a),Ha=d(fa),Be=l(fa,"SPAN",{});var Xo=s(Be);qa=p(Xo,"Treinamento em um Script"),Xo.forEach(a),fa.forEach(a),Oe=d(e),me=l(e,"P",{});var No=s(me);Ka=p(No,"Se estiver rodando seu treinamento em um Script, execute o seguinte comando para criar e guardar um arquivo de configura\xE7\xE3o:"),No.forEach(a),ea=d(e),h(oe.$$.fragment,e),aa=d(e),de=l(e,"P",{});var Yo=s(de);Da=p(Yo,"Comece o treinamento com:"),Yo.forEach(a),oa=d(e),h(te.$$.fragment,e),ta=d(e),_=l(e,"H3",{class:!0});var Ma=s(_);X=l(Ma,"A",{id:!0,class:!0,href:!0});var So=s(X);Ce=l(So,"SPAN",{});var Vo=s(Ce);h(re.$$.fragment,Vo),Vo.forEach(a),So.forEach(a),La=d(Ma),Ee=l(Ma,"SPAN",{});var Ro=s(Ee);Oa=p(Ro,"Treinamento em um Notebook"),Ro.forEach(a),Ma.forEach(a),ra=d(e),N=l(e,"P",{});var wa=s(N);eo=p(wa,`O \u{1F917} Accelerate pode rodar em um notebook, por exemplo, se estiver planejando usar as TPUs do Google Colab.
Encapsule o c\xF3digo respons\xE1vel pelo treinamento de uma fun\xE7\xE3o e passe-o ao `),Ze=l(wa,"CODE",{});var Qo=s(Ze);ao=p(Qo,"notebook_launcher"),Qo.forEach(a),oo=p(wa,":"),wa.forEach(a),la=d(e),h(le.$$.fragment,e),sa=d(e),Y=l(e,"P",{});var ya=s(Y);to=p(ya,"Para obter mais informa\xE7\xF5es sobre o \u{1F917} Accelerate e suas numerosas fun\xE7\xF5es, consulte a "),se=l(ya,"A",{href:!0,rel:!0});var Fo=s(se);ro=p(Fo,"documentaci\xF3n"),Fo.forEach(a),lo=p(ya,"."),ya.forEach(a),this.h()},h(){n(J,"name","hf:doc:metadata"),n(J,"content",JSON.stringify(Lo)),n(g,"id","treinamento-distribudo-com-o-accelerate"),n(g,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),n(g,"href","#treinamento-distribudo-com-o-accelerate"),n(j,"class","relative group"),n(R,"href","https://huggingface.co/docs/accelerate"),n(R,"rel","nofollow"),n(B,"id","configurao"),n(B,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),n(B,"href","#configurao"),n(T,"class","relative group"),n(P,"href","https://huggingface.co/docs/accelerate/package_reference/accelerator#accelerate.Accelerator"),n(P,"rel","nofollow"),n(C,"id","preparando-a-acelerao"),n(C,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),n(C,"href","#preparando-a-acelerao"),n(U,"class","relative group"),n(H,"href","https://huggingface.co/docs/accelerate/package_reference/accelerator#accelerate.Accelerator.prepare"),n(H,"rel","nofollow"),n(Z,"id","backward"),n(Z,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),n(Z,"href","#backward"),n(A,"class","relative group"),n(D,"href","https://huggingface.co/docs/accelerate/package_reference/accelerator#accelerate.Accelerator.backward"),n(D,"rel","nofollow"),n(G,"id","treinamento"),n(G,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),n(G,"href","#treinamento"),n($,"class","relative group"),n(W,"id","treinamento-em-um-script"),n(W,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),n(W,"href","#treinamento-em-um-script"),n(I,"class","relative group"),n(X,"id","treinamento-em-um-notebook"),n(X,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),n(X,"href","#treinamento-em-um-notebook"),n(_,"class","relative group"),n(se,"href","https://huggingface.co/docs/accelerate/index"),n(se,"rel","nofollow")},m(e,t){o(document.head,J),i(e,Ge,t),i(e,j,t),o(j,g),o(g,fe),f(V,fe,null),o(j,ba),o(j,Me),o(Me,va),i(e,We,t),i(e,k,t),o(k,Ja),o(k,R),o(R,ja),o(k,Ta),i(e,Xe,t),i(e,T,t),o(T,B),o(B,we),f(Q,we,null),o(T,Ua),o(T,ye),o(ye,Aa),i(e,Ne,t),i(e,ne,t),o(ne,$a),i(e,Ye,t),f(F,e,t),i(e,Se,t),i(e,b,t),o(b,Ia),o(b,P),o(P,be),o(be,_a),o(b,ga),o(b,ve),o(ve,ka),o(b,Ba),i(e,Ve,t),f(x,e,t),i(e,Re,t),i(e,U,t),o(U,C),o(C,Je),f(z,Je,null),o(U,Ca),o(U,je),o(je,Ea),i(e,Qe,t),i(e,E,t),o(E,Za),o(E,H),o(H,Te),o(Te,Ga),o(E,Wa),i(e,Fe,t),f(q,e,t),i(e,Pe,t),i(e,A,t),o(A,Z),o(Z,Ue),f(K,Ue,null),o(A,Xa),o(A,Ae),o(Ae,Na),i(e,xe,t),i(e,v,t),o(v,Ya),o(v,$e),o($e,Sa),o(v,Va),o(v,D),o(D,Ie),o(Ie,Ra),o(v,Qa),i(e,ze,t),f(L,e,t),i(e,He,t),i(e,ce,t),o(ce,Fa),i(e,qe,t),f(O,e,t),i(e,Ke,t),i(e,$,t),o($,G),o(G,_e),f(ee,_e,null),o($,Pa),o($,ge),o(ge,xa),i(e,De,t),i(e,pe,t),o(pe,za),i(e,Le,t),i(e,I,t),o(I,W),o(W,ke),f(ae,ke,null),o(I,Ha),o(I,Be),o(Be,qa),i(e,Oe,t),i(e,me,t),o(me,Ka),i(e,ea,t),f(oe,e,t),i(e,aa,t),i(e,de,t),o(de,Da),i(e,oa,t),f(te,e,t),i(e,ta,t),i(e,_,t),o(_,X),o(X,Ce),f(re,Ce,null),o(_,La),o(_,Ee),o(Ee,Oa),i(e,ra,t),i(e,N,t),o(N,eo),o(N,Ze),o(Ze,ao),o(N,oo),i(e,la,t),f(le,e,t),i(e,sa,t),i(e,Y,t),o(Y,to),o(Y,se),o(se,ro),o(Y,lo),ia=!0},p:qo,i(e){ia||(M(V.$$.fragment,e),M(Q.$$.fragment,e),M(F.$$.fragment,e),M(x.$$.fragment,e),M(z.$$.fragment,e),M(q.$$.fragment,e),M(K.$$.fragment,e),M(L.$$.fragment,e),M(O.$$.fragment,e),M(ee.$$.fragment,e),M(ae.$$.fragment,e),M(oe.$$.fragment,e),M(te.$$.fragment,e),M(re.$$.fragment,e),M(le.$$.fragment,e),ia=!0)},o(e){w(V.$$.fragment,e),w(Q.$$.fragment,e),w(F.$$.fragment,e),w(x.$$.fragment,e),w(z.$$.fragment,e),w(q.$$.fragment,e),w(K.$$.fragment,e),w(L.$$.fragment,e),w(O.$$.fragment,e),w(ee.$$.fragment,e),w(ae.$$.fragment,e),w(oe.$$.fragment,e),w(te.$$.fragment,e),w(re.$$.fragment,e),w(le.$$.fragment,e),ia=!1},d(e){a(J),e&&a(Ge),e&&a(j),y(V),e&&a(We),e&&a(k),e&&a(Xe),e&&a(T),y(Q),e&&a(Ne),e&&a(ne),e&&a(Ye),y(F,e),e&&a(Se),e&&a(b),e&&a(Ve),y(x,e),e&&a(Re),e&&a(U),y(z),e&&a(Qe),e&&a(E),e&&a(Fe),y(q,e),e&&a(Pe),e&&a(A),y(K),e&&a(xe),e&&a(v),e&&a(ze),y(L,e),e&&a(He),e&&a(ce),e&&a(qe),y(O,e),e&&a(Ke),e&&a($),y(ee),e&&a(De),e&&a(pe),e&&a(Le),e&&a(I),y(ae),e&&a(Oe),e&&a(me),e&&a(ea),y(oe,e),e&&a(aa),e&&a(de),e&&a(oa),y(te,e),e&&a(ta),e&&a(_),y(re),e&&a(ra),e&&a(N),e&&a(la),y(le,e),e&&a(sa),e&&a(Y)}}}const Lo={local:"treinamento-distribudo-com-o-accelerate",sections:[{local:"configurao",title:"Configura\xE7\xE3o"},{local:"preparando-a-acelerao",title:"Preparando a acelera\xE7\xE3o"},{local:"backward",title:"Backward"},{local:"treinamento",sections:[{local:"treinamento-em-um-script",title:"Treinamento em um Script"},{local:"treinamento-em-um-notebook",title:"Treinamento em um Notebook"}],title:"Treinamento"}],title:"Treinamento distribu\xEDdo com o \u{1F917} Accelerate"};function Oo(so){return Ko(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class tt extends Po{constructor(J){super();xo(this,J,Oo,Do,zo,{})}}export{tt as default,Lo as metadata};
