import{S as hs,i as ms,s as ys,e as a,k as i,w as j,t as s,M as ws,c as o,d as l,m as d,a as p,x as T,h as r,b as f,G as t,g as n,y as $,q as C,o as Z,B as G,v as _s}from"../../chunks/vendor-hf-doc-builder.js";import{T as Ms}from"../../chunks/Tip-hf-doc-builder.js";import{I as Gl}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{C as ie}from"../../chunks/CodeBlock-hf-doc-builder.js";function Js(Re){let u;return{c(){u=s("\uC790\uC138\uD55C \uB0B4\uC6A9\uC740 [\u{1F917} Accelerate\uB97C \uC0AC\uC6A9\uD55C \uBD84\uC0B0 \uCD94\uB860](https://huggingface.co/docs/accelerate/en/usage_guides/distributed_inference#distributed-inference-with-accelerate) \uAC00\uC774\uB4DC\uB97C \uCC38\uC870\uD558\uC138\uC694.")},l(M){u=r(M,"\uC790\uC138\uD55C \uB0B4\uC6A9\uC740 [\u{1F917} Accelerate\uB97C \uC0AC\uC6A9\uD55C \uBD84\uC0B0 \uCD94\uB860](https://huggingface.co/docs/accelerate/en/usage_guides/distributed_inference#distributed-inference-with-accelerate) \uAC00\uC774\uB4DC\uB97C \uCC38\uC870\uD558\uC138\uC694.")},m(M,_){n(M,u,_)},d(M){M&&l(u)}}}function Es(Re){let u,M,_,I,de,H,mt,fe,yt,We,J,wt,Y,_t,Mt,V,Jt,Et,Xe,ae,Ut,Se,k,z,ue,F,vt,he,bt,Be,A,jt,x,Tt,$t,He,h,Ct,me,Zt,Gt,ye,kt,Pt,we,It,zt,_e,At,Nt,Ye,N,gt,Me,Dt,Rt,Ve,Q,Fe,E,Wt,Je,Xt,St,Ee,Bt,Ht,xe,q,Qe,g,qe,P,D,Ue,O,Yt,ve,Vt,Oe,R,Ft,K,be,xt,Qt,Ke,m,qt,je,Ot,Kt,Te,Lt,el,$e,tl,ll,Le,U,sl,Ce,rl,al,Ze,ol,cl,et,L,tt,y,pl,Ge,nl,il,ke,dl,fl,Pe,ul,hl,lt,W,ml,Ie,yl,wl,st,ee,rt,w,_l,te,ze,Ml,Jl,Ae,El,Ul,Ne,vl,bl,at,le,ot,v,jl,ge,Tl,$l,De,Cl,Zl,ct,se,pt;return H=new Gl({}),F=new Gl({}),Q=new ie({props:{code:"ZnJvbSUyMGFjY2VsZXJhdGUlMjBpbXBvcnQlMjBQYXJ0aWFsU3RhdGUlMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwRGlmZnVzaW9uUGlwZWxpbmUlMEElMEFwaXBlbGluZSUyMCUzRCUyMERpZmZ1c2lvblBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMjJydW53YXltbCUyRnN0YWJsZS1kaWZmdXNpb24tdjEtNSUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiklMEFkaXN0cmlidXRlZF9zdGF0ZSUyMCUzRCUyMFBhcnRpYWxTdGF0ZSgpJTBBcGlwZWxpbmUudG8oZGlzdHJpYnV0ZWRfc3RhdGUuZGV2aWNlKSUwQSUwQXdpdGglMjBkaXN0cmlidXRlZF9zdGF0ZS5zcGxpdF9iZXR3ZWVuX3Byb2Nlc3NlcyglNUIlMjJhJTIwZG9nJTIyJTJDJTIwJTIyYSUyMGNhdCUyMiU1RCklMjBhcyUyMHByb21wdCUzQSUwQSUyMCUyMCUyMCUyMHJlc3VsdCUyMCUzRCUyMHBpcGVsaW5lKHByb21wdCkuaW1hZ2VzJTVCMCU1RCUwQSUyMCUyMCUyMCUyMHJlc3VsdC5zYXZlKGYlMjJyZXN1bHRfJTdCZGlzdHJpYnV0ZWRfc3RhdGUucHJvY2Vzc19pbmRleCU3RC5wbmclMjIp",highlighted:`<span class="hljs-keyword">from</span> accelerate <span class="hljs-keyword">import</span> PartialState
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline

pipeline = DiffusionPipeline.from_pretrained(<span class="hljs-string">&quot;runwayml/stable-diffusion-v1-5&quot;</span>, torch_dtype=torch.float16)
distributed_state = PartialState()
pipeline.to(distributed_state.device)

<span class="hljs-keyword">with</span> distributed_state.split_between_processes([<span class="hljs-string">&quot;a dog&quot;</span>, <span class="hljs-string">&quot;a cat&quot;</span>]) <span class="hljs-keyword">as</span> prompt:
    result = pipeline(prompt).images[<span class="hljs-number">0</span>]
    result.save(<span class="hljs-string">f&quot;result_<span class="hljs-subst">{distributed_state.process_index}</span>.png&quot;</span>)`}}),q=new ie({props:{code:"YWNjZWxlcmF0ZSUyMGxhdW5jaCUyMHJ1bl9kaXN0cmlidXRlZC5weSUyMC0tbnVtX3Byb2Nlc3NlcyUzRDI=",highlighted:"accelerate launch run_distributed.py --num_processes=2"}}),g=new Ms({props:{$$slots:{default:[Js]},$$scope:{ctx:Re}}}),O=new Gl({}),L=new ie({props:{code:"aW1wb3J0JTIwdG9yY2glMEFpbXBvcnQlMjB0b3JjaC5kaXN0cmlidXRlZCUyMGFzJTIwZGlzdCUwQWltcG9ydCUyMHRvcmNoLm11bHRpcHJvY2Vzc2luZyUyMGFzJTIwbXAlMEElMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwRGlmZnVzaW9uUGlwZWxpbmUlMEElMEFzZCUyMCUzRCUyMERpZmZ1c2lvblBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMjJydW53YXltbCUyRnN0YWJsZS1kaWZmdXNpb24tdjEtNSUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNik=",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">import</span> torch.distributed <span class="hljs-keyword">as</span> dist
<span class="hljs-keyword">import</span> torch.multiprocessing <span class="hljs-keyword">as</span> mp

<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline

sd = DiffusionPipeline.from_pretrained(<span class="hljs-string">&quot;runwayml/stable-diffusion-v1-5&quot;</span>, torch_dtype=torch.float16)`}}),ee=new ie({props:{code:"ZGVmJTIwcnVuX2luZmVyZW5jZShyYW5rJTJDJTIwd29ybGRfc2l6ZSklM0ElMEElMjAlMjAlMjAlMjBkaXN0LmluaXRfcHJvY2Vzc19ncm91cCglMjJuY2NsJTIyJTJDJTIwcmFuayUzRHJhbmslMkMlMjB3b3JsZF9zaXplJTNEd29ybGRfc2l6ZSklMEElMEElMjAlMjAlMjAlMjBzZC50byhyYW5rKSUwQSUwQSUyMCUyMCUyMCUyMGlmJTIwdG9yY2guZGlzdHJpYnV0ZWQuZ2V0X3JhbmsoKSUyMCUzRCUzRCUyMDAlM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBwcm9tcHQlMjAlM0QlMjAlMjJhJTIwZG9nJTIyJTBBJTIwJTIwJTIwJTIwZWxpZiUyMHRvcmNoLmRpc3RyaWJ1dGVkLmdldF9yYW5rKCklMjAlM0QlM0QlMjAxJTNBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwcHJvbXB0JTIwJTNEJTIwJTIyYSUyMGNhdCUyMiUwQSUwQSUyMCUyMCUyMCUyMGltYWdlJTIwJTNEJTIwc2QocHJvbXB0KS5pbWFnZXMlNUIwJTVEJTBBJTIwJTIwJTIwJTIwaW1hZ2Uuc2F2ZShmJTIyLiUyRiU3QidfJy5qb2luKHByb21wdCklN0QucG5nJTIyKQ==",highlighted:`<span class="hljs-keyword">def</span> <span class="hljs-title function_">run_inference</span>(<span class="hljs-params">rank, world_size</span>):
    dist.init_process_group(<span class="hljs-string">&quot;nccl&quot;</span>, rank=rank, world_size=world_size)

    sd.to(rank)

    <span class="hljs-keyword">if</span> torch.distributed.get_rank() == <span class="hljs-number">0</span>:
        prompt = <span class="hljs-string">&quot;a dog&quot;</span>
    <span class="hljs-keyword">elif</span> torch.distributed.get_rank() == <span class="hljs-number">1</span>:
        prompt = <span class="hljs-string">&quot;a cat&quot;</span>

    image = sd(prompt).images[<span class="hljs-number">0</span>]
    image.save(<span class="hljs-string">f&quot;./<span class="hljs-subst">{<span class="hljs-string">&#x27;_&#x27;</span>.join(prompt)}</span>.png&quot;</span>)`}}),le=new ie({props:{code:"ZGVmJTIwbWFpbigpJTNBJTBBJTIwJTIwJTIwJTIwd29ybGRfc2l6ZSUyMCUzRCUyMDIlMEElMjAlMjAlMjAlMjBtcC5zcGF3bihydW5faW5mZXJlbmNlJTJDJTIwYXJncyUzRCh3b3JsZF9zaXplJTJDKSUyQyUyMG5wcm9jcyUzRHdvcmxkX3NpemUlMkMlMjBqb2luJTNEVHJ1ZSklMEElMEElMEFpZiUyMF9fbmFtZV9fJTIwJTNEJTNEJTIwJTIyX19tYWluX18lMjIlM0ElMEElMjAlMjAlMjAlMjBtYWluKCk=",highlighted:`<span class="hljs-keyword">def</span> <span class="hljs-title function_">main</span>():
    world_size = <span class="hljs-number">2</span>
    mp.spawn(run_inference, args=(world_size,), nprocs=world_size, join=<span class="hljs-literal">True</span>)


<span class="hljs-keyword">if</span> __name__ == <span class="hljs-string">&quot;__main__&quot;</span>:
    main()`}}),se=new ie({props:{code:"dG9yY2hydW4lMjBydW5fZGlzdHJpYnV0ZWQucHklMjAtLW5wcm9jX3Blcl9ub2RlJTNEMg==",highlighted:"torchrun run_distributed.py --nproc_per_node=2"}}),{c(){u=a("meta"),M=i(),_=a("h1"),I=a("a"),de=a("span"),j(H.$$.fragment),mt=i(),fe=a("span"),yt=s("\uC5EC\uB7EC GPU\uB97C \uC0AC\uC6A9\uD55C \uBD84\uC0B0 \uCD94\uB860"),We=i(),J=a("p"),wt=s("\uBD84\uC0B0 \uC124\uC815\uC5D0\uC11C\uB294 \uC5EC\uB7EC \uAC1C\uC758 \uD504\uB86C\uD504\uD2B8\uB97C \uB3D9\uC2DC\uC5D0 \uC0DD\uC131\uD560 \uB54C \uC720\uC6A9\uD55C \u{1F917} "),Y=a("a"),_t=s("Accelerate"),Mt=s(" \uB610\uB294 "),V=a("a"),Jt=s("PyTorch Distributed"),Et=s("\uB97C \uC0AC\uC6A9\uD558\uC5EC \uC5EC\uB7EC GPU\uC5D0\uC11C \uCD94\uB860\uC744 \uC2E4\uD589\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4."),Xe=i(),ae=a("p"),Ut=s("\uC774 \uAC00\uC774\uB4DC\uC5D0\uC11C\uB294 \uBD84\uC0B0 \uCD94\uB860\uC744 \uC704\uD574 \u{1F917} Accelerate\uC640 PyTorch Distributed\uB97C \uC0AC\uC6A9\uD558\uB294 \uBC29\uBC95\uC744 \uBCF4\uC5EC\uB4DC\uB9BD\uB2C8\uB2E4."),Se=i(),k=a("h2"),z=a("a"),ue=a("span"),j(F.$$.fragment),vt=i(),he=a("span"),bt=s("\u{1F917} Accelerate"),Be=i(),A=a("p"),jt=s("\u{1F917} "),x=a("a"),Tt=s("Accelerate"),$t=s("\uB294 \uBD84\uC0B0 \uC124\uC815\uC5D0\uC11C \uCD94\uB860\uC744 \uC27D\uAC8C \uD6C8\uB828\uD558\uAC70\uB098 \uC2E4\uD589\uD560 \uC218 \uC788\uB3C4\uB85D \uC124\uACC4\uB41C \uB77C\uC774\uBE0C\uB7EC\uB9AC\uC785\uB2C8\uB2E4. \uBD84\uC0B0 \uD658\uACBD \uC124\uC815 \uD504\uB85C\uC138\uC2A4\uB97C \uAC04\uC18C\uD654\uD558\uC5EC PyTorch \uCF54\uB4DC\uC5D0 \uC9D1\uC911\uD560 \uC218 \uC788\uB3C4\uB85D \uD574\uC90D\uB2C8\uB2E4."),He=i(),h=a("p"),Ct=s("\uC2DC\uC791\uD558\uB824\uBA74 Python \uD30C\uC77C\uC744 \uC0DD\uC131\uD558\uACE0 "),me=a("code"),Zt=s("accelerate.PartialState"),Gt=s("\uB97C \uCD08\uAE30\uD654\uD558\uC5EC \uBD84\uC0B0 \uD658\uACBD\uC744 \uC0DD\uC131\uD558\uBA74, \uC124\uC815\uC774 \uC790\uB3D9\uC73C\uB85C \uAC10\uC9C0\uB418\uBBC0\uB85C "),ye=a("code"),kt=s("rank"),Pt=s(" \uB610\uB294 "),we=a("code"),It=s("world_size"),zt=s("\uB97C \uBA85\uC2DC\uC801\uC73C\uB85C \uC815\uC758\uD560 \uD544\uC694\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4. [\u2018DiffusionPipeline`]\uC744 "),_e=a("code"),At=s("distributed_state.device"),Nt=s("\uB85C \uC774\uB3D9\uD558\uC5EC \uAC01 \uD504\uB85C\uC138\uC2A4\uC5D0 GPU\uB97C \uD560\uB2F9\uD569\uB2C8\uB2E4."),Ye=i(),N=a("p"),gt=s("\uC774\uC81C \uCEE8\uD14D\uC2A4\uD2B8 \uAD00\uB9AC\uC790\uB85C "),Me=a("code"),Dt=s("split_between_processes"),Rt=s(" \uC720\uD2F8\uB9AC\uD2F0\uB97C \uC0AC\uC6A9\uD558\uC5EC \uD504\uB85C\uC138\uC2A4 \uC218\uC5D0 \uB530\uB77C \uD504\uB86C\uD504\uD2B8\uB97C \uC790\uB3D9\uC73C\uB85C \uBD84\uBC30\uD569\uB2C8\uB2E4."),Ve=i(),j(Q.$$.fragment),Fe=i(),E=a("p"),Wt=s("Use the "),Je=a("code"),Xt=s("--num_processes"),St=s(" argument to specify the number of GPUs to use, and call "),Ee=a("code"),Bt=s("accelerate launch"),Ht=s(" to run the script:"),xe=i(),j(q.$$.fragment),Qe=i(),j(g.$$.fragment),qe=i(),P=a("h2"),D=a("a"),Ue=a("span"),j(O.$$.fragment),Yt=i(),ve=a("span"),Vt=s("Pytoerch \uBD84\uC0B0"),Oe=i(),R=a("p"),Ft=s("PyTorch\uB294 \uB370\uC774\uD130 \uBCD1\uB82C \uCC98\uB9AC\uB97C \uAC00\uB2A5\uD558\uAC8C \uD558\uB294 "),K=a("a"),be=a("code"),xt=s("DistributedDataParallel"),Qt=s("\uC744 \uC9C0\uC6D0\uD569\uB2C8\uB2E4."),Ke=i(),m=a("p"),qt=s("\uC2DC\uC791\uD558\uB824\uBA74 Python \uD30C\uC77C\uC744 \uC0DD\uC131\uD558\uACE0 "),je=a("code"),Ot=s("torch.distributed"),Kt=s(" \uBC0F "),Te=a("code"),Lt=s("torch.multiprocessing"),el=s("\uC744 \uC784\uD3EC\uD2B8\uD558\uC5EC \uBD84\uC0B0 \uD504\uB85C\uC138\uC2A4 \uADF8\uB8F9\uC744 \uC124\uC815\uD558\uACE0 \uAC01 GPU\uC5D0\uC11C \uCD94\uB860\uC6A9 \uD504\uB85C\uC138\uC2A4\uB97C \uC0DD\uC131\uD569\uB2C8\uB2E4. \uADF8\uB9AC\uACE0 "),$e=a("code"),tl=s("DiffusionPipeline"),ll=s("\uB3C4 \uCD08\uAE30\uD654\uD574\uC57C \uD569\uB2C8\uB2E4:"),Le=i(),U=a("p"),sl=s("\uD655\uC0B0 \uD30C\uC774\uD504\uB77C\uC778\uC744 "),Ce=a("code"),rl=s("rank"),al=s("\uB85C \uC774\uB3D9\uD558\uACE0 "),Ze=a("code"),ol=s("get_rank"),cl=s("\uB97C \uC0AC\uC6A9\uD558\uC5EC \uAC01 \uD504\uB85C\uC138\uC2A4\uC5D0 GPU\uB97C \uD560\uB2F9\uD558\uBA74 \uAC01 \uD504\uB85C\uC138\uC2A4\uAC00 \uB2E4\uB978 \uD504\uB86C\uD504\uD2B8\uB97C \uCC98\uB9AC\uD569\uB2C8\uB2E4:"),et=i(),j(L.$$.fragment),tt=i(),y=a("p"),pl=s("\uC0AC\uC6A9\uD560 \uBC31\uC5D4\uB4DC \uC720\uD615, \uD604\uC7AC \uD504\uB85C\uC138\uC2A4\uC758 "),Ge=a("code"),nl=s("rank"),il=s(", "),ke=a("code"),dl=s("world_size"),fl=s(" \uB610\uB294 \uCC38\uC5EC\uD558\uB294 \uD504\uB85C\uC138\uC2A4 \uC218\uB85C \uBD84\uC0B0 \uD658\uACBD \uC0DD\uC131\uC744 \uCC98\uB9AC\uD558\uB294 \uD568\uC218"),Pe=a("code"),ul=s("init_process_group"),hl=s("\uB97C \uB9CC\uB4E4\uC5B4 \uCD94\uB860\uC744 \uC2E4\uD589\uD574\uC57C \uD569\uB2C8\uB2E4."),lt=i(),W=a("p"),ml=s("2\uAC1C\uC758 GPU\uC5D0\uC11C \uCD94\uB860\uC744 \uBCD1\uB82C\uB85C \uC2E4\uD589\uD558\uB294 \uACBD\uC6B0 "),Ie=a("code"),yl=s("world_size"),wl=s("\uB294 2\uC785\uB2C8\uB2E4."),st=i(),j(ee.$$.fragment),rt=i(),w=a("p"),_l=s("\uBD84\uC0B0 \uCD94\uB860\uC744 \uC2E4\uD589\uD558\uB824\uBA74 "),te=a("a"),ze=a("code"),Ml=s("mp.spawn"),Jl=s("\uC744 \uD638\uCD9C\uD558\uC5EC "),Ae=a("code"),El=s("world_size"),Ul=s("\uC5D0 \uC815\uC758\uB41C GPU \uC218\uC5D0 \uB300\uD574 "),Ne=a("code"),vl=s("run_inference"),bl=s(" \uD568\uC218\uB97C \uC2E4\uD589\uD569\uB2C8\uB2E4:"),at=i(),j(le.$$.fragment),ot=i(),v=a("p"),jl=s("\uCD94\uB860 \uC2A4\uD06C\uB9BD\uD2B8\uB97C \uC644\uB8CC\uD588\uC73C\uBA74 "),ge=a("code"),Tl=s("--nproc_per_node"),$l=s(" \uC778\uC218\uB97C \uC0AC\uC6A9\uD558\uC5EC \uC0AC\uC6A9\uD560 GPU \uC218\uB97C \uC9C0\uC815\uD558\uACE0 "),De=a("code"),Cl=s("torchrun"),Zl=s("\uC744 \uD638\uCD9C\uD558\uC5EC \uC2A4\uD06C\uB9BD\uD2B8\uB97C \uC2E4\uD589\uD569\uB2C8\uB2E4:"),ct=i(),j(se.$$.fragment),this.h()},l(e){const c=ws('[data-svelte="svelte-1phssyn"]',document.head);u=o(c,"META",{name:!0,content:!0}),c.forEach(l),M=d(e),_=o(e,"H1",{class:!0});var re=p(_);I=o(re,"A",{id:!0,class:!0,href:!0});var kl=p(I);de=o(kl,"SPAN",{});var Pl=p(de);T(H.$$.fragment,Pl),Pl.forEach(l),kl.forEach(l),mt=d(re),fe=o(re,"SPAN",{});var Il=p(fe);yt=r(Il,"\uC5EC\uB7EC GPU\uB97C \uC0AC\uC6A9\uD55C \uBD84\uC0B0 \uCD94\uB860"),Il.forEach(l),re.forEach(l),We=d(e),J=o(e,"P",{});var oe=p(J);wt=r(oe,"\uBD84\uC0B0 \uC124\uC815\uC5D0\uC11C\uB294 \uC5EC\uB7EC \uAC1C\uC758 \uD504\uB86C\uD504\uD2B8\uB97C \uB3D9\uC2DC\uC5D0 \uC0DD\uC131\uD560 \uB54C \uC720\uC6A9\uD55C \u{1F917} "),Y=o(oe,"A",{href:!0,rel:!0});var zl=p(Y);_t=r(zl,"Accelerate"),zl.forEach(l),Mt=r(oe," \uB610\uB294 "),V=o(oe,"A",{href:!0,rel:!0});var Al=p(V);Jt=r(Al,"PyTorch Distributed"),Al.forEach(l),Et=r(oe,"\uB97C \uC0AC\uC6A9\uD558\uC5EC \uC5EC\uB7EC GPU\uC5D0\uC11C \uCD94\uB860\uC744 \uC2E4\uD589\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4."),oe.forEach(l),Xe=d(e),ae=o(e,"P",{});var Nl=p(ae);Ut=r(Nl,"\uC774 \uAC00\uC774\uB4DC\uC5D0\uC11C\uB294 \uBD84\uC0B0 \uCD94\uB860\uC744 \uC704\uD574 \u{1F917} Accelerate\uC640 PyTorch Distributed\uB97C \uC0AC\uC6A9\uD558\uB294 \uBC29\uBC95\uC744 \uBCF4\uC5EC\uB4DC\uB9BD\uB2C8\uB2E4."),Nl.forEach(l),Se=d(e),k=o(e,"H2",{class:!0});var nt=p(k);z=o(nt,"A",{id:!0,class:!0,href:!0});var gl=p(z);ue=o(gl,"SPAN",{});var Dl=p(ue);T(F.$$.fragment,Dl),Dl.forEach(l),gl.forEach(l),vt=d(nt),he=o(nt,"SPAN",{});var Rl=p(he);bt=r(Rl,"\u{1F917} Accelerate"),Rl.forEach(l),nt.forEach(l),Be=d(e),A=o(e,"P",{});var it=p(A);jt=r(it,"\u{1F917} "),x=o(it,"A",{href:!0,rel:!0});var Wl=p(x);Tt=r(Wl,"Accelerate"),Wl.forEach(l),$t=r(it,"\uB294 \uBD84\uC0B0 \uC124\uC815\uC5D0\uC11C \uCD94\uB860\uC744 \uC27D\uAC8C \uD6C8\uB828\uD558\uAC70\uB098 \uC2E4\uD589\uD560 \uC218 \uC788\uB3C4\uB85D \uC124\uACC4\uB41C \uB77C\uC774\uBE0C\uB7EC\uB9AC\uC785\uB2C8\uB2E4. \uBD84\uC0B0 \uD658\uACBD \uC124\uC815 \uD504\uB85C\uC138\uC2A4\uB97C \uAC04\uC18C\uD654\uD558\uC5EC PyTorch \uCF54\uB4DC\uC5D0 \uC9D1\uC911\uD560 \uC218 \uC788\uB3C4\uB85D \uD574\uC90D\uB2C8\uB2E4."),it.forEach(l),He=d(e),h=o(e,"P",{});var b=p(h);Ct=r(b,"\uC2DC\uC791\uD558\uB824\uBA74 Python \uD30C\uC77C\uC744 \uC0DD\uC131\uD558\uACE0 "),me=o(b,"CODE",{});var Xl=p(me);Zt=r(Xl,"accelerate.PartialState"),Xl.forEach(l),Gt=r(b,"\uB97C \uCD08\uAE30\uD654\uD558\uC5EC \uBD84\uC0B0 \uD658\uACBD\uC744 \uC0DD\uC131\uD558\uBA74, \uC124\uC815\uC774 \uC790\uB3D9\uC73C\uB85C \uAC10\uC9C0\uB418\uBBC0\uB85C "),ye=o(b,"CODE",{});var Sl=p(ye);kt=r(Sl,"rank"),Sl.forEach(l),Pt=r(b," \uB610\uB294 "),we=o(b,"CODE",{});var Bl=p(we);It=r(Bl,"world_size"),Bl.forEach(l),zt=r(b,"\uB97C \uBA85\uC2DC\uC801\uC73C\uB85C \uC815\uC758\uD560 \uD544\uC694\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4. [\u2018DiffusionPipeline`]\uC744 "),_e=o(b,"CODE",{});var Hl=p(_e);At=r(Hl,"distributed_state.device"),Hl.forEach(l),Nt=r(b,"\uB85C \uC774\uB3D9\uD558\uC5EC \uAC01 \uD504\uB85C\uC138\uC2A4\uC5D0 GPU\uB97C \uD560\uB2F9\uD569\uB2C8\uB2E4."),b.forEach(l),Ye=d(e),N=o(e,"P",{});var dt=p(N);gt=r(dt,"\uC774\uC81C \uCEE8\uD14D\uC2A4\uD2B8 \uAD00\uB9AC\uC790\uB85C "),Me=o(dt,"CODE",{});var Yl=p(Me);Dt=r(Yl,"split_between_processes"),Yl.forEach(l),Rt=r(dt," \uC720\uD2F8\uB9AC\uD2F0\uB97C \uC0AC\uC6A9\uD558\uC5EC \uD504\uB85C\uC138\uC2A4 \uC218\uC5D0 \uB530\uB77C \uD504\uB86C\uD504\uD2B8\uB97C \uC790\uB3D9\uC73C\uB85C \uBD84\uBC30\uD569\uB2C8\uB2E4."),dt.forEach(l),Ve=d(e),T(Q.$$.fragment,e),Fe=d(e),E=o(e,"P",{});var ce=p(E);Wt=r(ce,"Use the "),Je=o(ce,"CODE",{});var Vl=p(Je);Xt=r(Vl,"--num_processes"),Vl.forEach(l),St=r(ce," argument to specify the number of GPUs to use, and call "),Ee=o(ce,"CODE",{});var Fl=p(Ee);Bt=r(Fl,"accelerate launch"),Fl.forEach(l),Ht=r(ce," to run the script:"),ce.forEach(l),xe=d(e),T(q.$$.fragment,e),Qe=d(e),T(g.$$.fragment,e),qe=d(e),P=o(e,"H2",{class:!0});var ft=p(P);D=o(ft,"A",{id:!0,class:!0,href:!0});var xl=p(D);Ue=o(xl,"SPAN",{});var Ql=p(Ue);T(O.$$.fragment,Ql),Ql.forEach(l),xl.forEach(l),Yt=d(ft),ve=o(ft,"SPAN",{});var ql=p(ve);Vt=r(ql,"Pytoerch \uBD84\uC0B0"),ql.forEach(l),ft.forEach(l),Oe=d(e),R=o(e,"P",{});var ut=p(R);Ft=r(ut,"PyTorch\uB294 \uB370\uC774\uD130 \uBCD1\uB82C \uCC98\uB9AC\uB97C \uAC00\uB2A5\uD558\uAC8C \uD558\uB294 "),K=o(ut,"A",{href:!0,rel:!0});var Ol=p(K);be=o(Ol,"CODE",{});var Kl=p(be);xt=r(Kl,"DistributedDataParallel"),Kl.forEach(l),Ol.forEach(l),Qt=r(ut,"\uC744 \uC9C0\uC6D0\uD569\uB2C8\uB2E4."),ut.forEach(l),Ke=d(e),m=o(e,"P",{});var X=p(m);qt=r(X,"\uC2DC\uC791\uD558\uB824\uBA74 Python \uD30C\uC77C\uC744 \uC0DD\uC131\uD558\uACE0 "),je=o(X,"CODE",{});var Ll=p(je);Ot=r(Ll,"torch.distributed"),Ll.forEach(l),Kt=r(X," \uBC0F "),Te=o(X,"CODE",{});var es=p(Te);Lt=r(es,"torch.multiprocessing"),es.forEach(l),el=r(X,"\uC744 \uC784\uD3EC\uD2B8\uD558\uC5EC \uBD84\uC0B0 \uD504\uB85C\uC138\uC2A4 \uADF8\uB8F9\uC744 \uC124\uC815\uD558\uACE0 \uAC01 GPU\uC5D0\uC11C \uCD94\uB860\uC6A9 \uD504\uB85C\uC138\uC2A4\uB97C \uC0DD\uC131\uD569\uB2C8\uB2E4. \uADF8\uB9AC\uACE0 "),$e=o(X,"CODE",{});var ts=p($e);tl=r(ts,"DiffusionPipeline"),ts.forEach(l),ll=r(X,"\uB3C4 \uCD08\uAE30\uD654\uD574\uC57C \uD569\uB2C8\uB2E4:"),X.forEach(l),Le=d(e),U=o(e,"P",{});var pe=p(U);sl=r(pe,"\uD655\uC0B0 \uD30C\uC774\uD504\uB77C\uC778\uC744 "),Ce=o(pe,"CODE",{});var ls=p(Ce);rl=r(ls,"rank"),ls.forEach(l),al=r(pe,"\uB85C \uC774\uB3D9\uD558\uACE0 "),Ze=o(pe,"CODE",{});var ss=p(Ze);ol=r(ss,"get_rank"),ss.forEach(l),cl=r(pe,"\uB97C \uC0AC\uC6A9\uD558\uC5EC \uAC01 \uD504\uB85C\uC138\uC2A4\uC5D0 GPU\uB97C \uD560\uB2F9\uD558\uBA74 \uAC01 \uD504\uB85C\uC138\uC2A4\uAC00 \uB2E4\uB978 \uD504\uB86C\uD504\uD2B8\uB97C \uCC98\uB9AC\uD569\uB2C8\uB2E4:"),pe.forEach(l),et=d(e),T(L.$$.fragment,e),tt=d(e),y=o(e,"P",{});var S=p(y);pl=r(S,"\uC0AC\uC6A9\uD560 \uBC31\uC5D4\uB4DC \uC720\uD615, \uD604\uC7AC \uD504\uB85C\uC138\uC2A4\uC758 "),Ge=o(S,"CODE",{});var rs=p(Ge);nl=r(rs,"rank"),rs.forEach(l),il=r(S,", "),ke=o(S,"CODE",{});var as=p(ke);dl=r(as,"world_size"),as.forEach(l),fl=r(S," \uB610\uB294 \uCC38\uC5EC\uD558\uB294 \uD504\uB85C\uC138\uC2A4 \uC218\uB85C \uBD84\uC0B0 \uD658\uACBD \uC0DD\uC131\uC744 \uCC98\uB9AC\uD558\uB294 \uD568\uC218"),Pe=o(S,"CODE",{});var os=p(Pe);ul=r(os,"init_process_group"),os.forEach(l),hl=r(S,"\uB97C \uB9CC\uB4E4\uC5B4 \uCD94\uB860\uC744 \uC2E4\uD589\uD574\uC57C \uD569\uB2C8\uB2E4."),S.forEach(l),lt=d(e),W=o(e,"P",{});var ht=p(W);ml=r(ht,"2\uAC1C\uC758 GPU\uC5D0\uC11C \uCD94\uB860\uC744 \uBCD1\uB82C\uB85C \uC2E4\uD589\uD558\uB294 \uACBD\uC6B0 "),Ie=o(ht,"CODE",{});var cs=p(Ie);yl=r(cs,"world_size"),cs.forEach(l),wl=r(ht,"\uB294 2\uC785\uB2C8\uB2E4."),ht.forEach(l),st=d(e),T(ee.$$.fragment,e),rt=d(e),w=o(e,"P",{});var B=p(w);_l=r(B,"\uBD84\uC0B0 \uCD94\uB860\uC744 \uC2E4\uD589\uD558\uB824\uBA74 "),te=o(B,"A",{href:!0,rel:!0});var ps=p(te);ze=o(ps,"CODE",{});var ns=p(ze);Ml=r(ns,"mp.spawn"),ns.forEach(l),ps.forEach(l),Jl=r(B,"\uC744 \uD638\uCD9C\uD558\uC5EC "),Ae=o(B,"CODE",{});var is=p(Ae);El=r(is,"world_size"),is.forEach(l),Ul=r(B,"\uC5D0 \uC815\uC758\uB41C GPU \uC218\uC5D0 \uB300\uD574 "),Ne=o(B,"CODE",{});var ds=p(Ne);vl=r(ds,"run_inference"),ds.forEach(l),bl=r(B," \uD568\uC218\uB97C \uC2E4\uD589\uD569\uB2C8\uB2E4:"),B.forEach(l),at=d(e),T(le.$$.fragment,e),ot=d(e),v=o(e,"P",{});var ne=p(v);jl=r(ne,"\uCD94\uB860 \uC2A4\uD06C\uB9BD\uD2B8\uB97C \uC644\uB8CC\uD588\uC73C\uBA74 "),ge=o(ne,"CODE",{});var fs=p(ge);Tl=r(fs,"--nproc_per_node"),fs.forEach(l),$l=r(ne," \uC778\uC218\uB97C \uC0AC\uC6A9\uD558\uC5EC \uC0AC\uC6A9\uD560 GPU \uC218\uB97C \uC9C0\uC815\uD558\uACE0 "),De=o(ne,"CODE",{});var us=p(De);Cl=r(us,"torchrun"),us.forEach(l),Zl=r(ne,"\uC744 \uD638\uCD9C\uD558\uC5EC \uC2A4\uD06C\uB9BD\uD2B8\uB97C \uC2E4\uD589\uD569\uB2C8\uB2E4:"),ne.forEach(l),ct=d(e),T(se.$$.fragment,e),this.h()},h(){f(u,"name","hf:doc:metadata"),f(u,"content",JSON.stringify(Us)),f(I,"id","gpu"),f(I,"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"),f(I,"href","#gpu"),f(_,"class","relative group"),f(Y,"href","https://huggingface.co/docs/accelerate/index"),f(Y,"rel","nofollow"),f(V,"href","https://pytorch.org/tutorials/beginner/dist_overview.html"),f(V,"rel","nofollow"),f(z,"id","accelerate"),f(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"),f(z,"href","#accelerate"),f(k,"class","relative group"),f(x,"href","https://huggingface.co/docs/accelerate/index"),f(x,"rel","nofollow"),f(D,"id","pytoerch"),f(D,"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"),f(D,"href","#pytoerch"),f(P,"class","relative group"),f(K,"href","https://pytorch.org/docs/stable/generated/torch.nn.parallel.DistributedDataParallel.html"),f(K,"rel","nofollow"),f(te,"href","https://pytorch.org/docs/stable/multiprocessing.html#torch.multiprocessing.spawn"),f(te,"rel","nofollow")},m(e,c){t(document.head,u),n(e,M,c),n(e,_,c),t(_,I),t(I,de),$(H,de,null),t(_,mt),t(_,fe),t(fe,yt),n(e,We,c),n(e,J,c),t(J,wt),t(J,Y),t(Y,_t),t(J,Mt),t(J,V),t(V,Jt),t(J,Et),n(e,Xe,c),n(e,ae,c),t(ae,Ut),n(e,Se,c),n(e,k,c),t(k,z),t(z,ue),$(F,ue,null),t(k,vt),t(k,he),t(he,bt),n(e,Be,c),n(e,A,c),t(A,jt),t(A,x),t(x,Tt),t(A,$t),n(e,He,c),n(e,h,c),t(h,Ct),t(h,me),t(me,Zt),t(h,Gt),t(h,ye),t(ye,kt),t(h,Pt),t(h,we),t(we,It),t(h,zt),t(h,_e),t(_e,At),t(h,Nt),n(e,Ye,c),n(e,N,c),t(N,gt),t(N,Me),t(Me,Dt),t(N,Rt),n(e,Ve,c),$(Q,e,c),n(e,Fe,c),n(e,E,c),t(E,Wt),t(E,Je),t(Je,Xt),t(E,St),t(E,Ee),t(Ee,Bt),t(E,Ht),n(e,xe,c),$(q,e,c),n(e,Qe,c),$(g,e,c),n(e,qe,c),n(e,P,c),t(P,D),t(D,Ue),$(O,Ue,null),t(P,Yt),t(P,ve),t(ve,Vt),n(e,Oe,c),n(e,R,c),t(R,Ft),t(R,K),t(K,be),t(be,xt),t(R,Qt),n(e,Ke,c),n(e,m,c),t(m,qt),t(m,je),t(je,Ot),t(m,Kt),t(m,Te),t(Te,Lt),t(m,el),t(m,$e),t($e,tl),t(m,ll),n(e,Le,c),n(e,U,c),t(U,sl),t(U,Ce),t(Ce,rl),t(U,al),t(U,Ze),t(Ze,ol),t(U,cl),n(e,et,c),$(L,e,c),n(e,tt,c),n(e,y,c),t(y,pl),t(y,Ge),t(Ge,nl),t(y,il),t(y,ke),t(ke,dl),t(y,fl),t(y,Pe),t(Pe,ul),t(y,hl),n(e,lt,c),n(e,W,c),t(W,ml),t(W,Ie),t(Ie,yl),t(W,wl),n(e,st,c),$(ee,e,c),n(e,rt,c),n(e,w,c),t(w,_l),t(w,te),t(te,ze),t(ze,Ml),t(w,Jl),t(w,Ae),t(Ae,El),t(w,Ul),t(w,Ne),t(Ne,vl),t(w,bl),n(e,at,c),$(le,e,c),n(e,ot,c),n(e,v,c),t(v,jl),t(v,ge),t(ge,Tl),t(v,$l),t(v,De),t(De,Cl),t(v,Zl),n(e,ct,c),$(se,e,c),pt=!0},p(e,[c]){const re={};c&2&&(re.$$scope={dirty:c,ctx:e}),g.$set(re)},i(e){pt||(C(H.$$.fragment,e),C(F.$$.fragment,e),C(Q.$$.fragment,e),C(q.$$.fragment,e),C(g.$$.fragment,e),C(O.$$.fragment,e),C(L.$$.fragment,e),C(ee.$$.fragment,e),C(le.$$.fragment,e),C(se.$$.fragment,e),pt=!0)},o(e){Z(H.$$.fragment,e),Z(F.$$.fragment,e),Z(Q.$$.fragment,e),Z(q.$$.fragment,e),Z(g.$$.fragment,e),Z(O.$$.fragment,e),Z(L.$$.fragment,e),Z(ee.$$.fragment,e),Z(le.$$.fragment,e),Z(se.$$.fragment,e),pt=!1},d(e){l(u),e&&l(M),e&&l(_),G(H),e&&l(We),e&&l(J),e&&l(Xe),e&&l(ae),e&&l(Se),e&&l(k),G(F),e&&l(Be),e&&l(A),e&&l(He),e&&l(h),e&&l(Ye),e&&l(N),e&&l(Ve),G(Q,e),e&&l(Fe),e&&l(E),e&&l(xe),G(q,e),e&&l(Qe),G(g,e),e&&l(qe),e&&l(P),G(O),e&&l(Oe),e&&l(R),e&&l(Ke),e&&l(m),e&&l(Le),e&&l(U),e&&l(et),G(L,e),e&&l(tt),e&&l(y),e&&l(lt),e&&l(W),e&&l(st),G(ee,e),e&&l(rt),e&&l(w),e&&l(at),G(le,e),e&&l(ot),e&&l(v),e&&l(ct),G(se,e)}}}const Us={local:"gpu",sections:[{local:"accelerate",title:"\u{1F917} Accelerate"},{local:"pytoerch",title:"Pytoerch \uBD84\uC0B0"}],title:"\uC5EC\uB7EC GPU\uB97C \uC0AC\uC6A9\uD55C \uBD84\uC0B0 \uCD94\uB860"};function vs(Re){return _s(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Cs extends hs{constructor(u){super();ms(this,u,vs,Es,ys,{})}}export{Cs as default,Us as metadata};
