import{S as Ml,i as vl,s as Jl,e as a,k as d,w as $,t as l,M as El,c as o,d as s,m as f,a as i,x as k,h as r,b as p,G as t,g as c,y as C,q as P,o as Z,B as G,v as Ul}from"../../chunks/vendor-hf-doc-builder.js";import{T as Tl}from"../../chunks/Tip-hf-doc-builder.js";import{I as Gs}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{C as _e}from"../../chunks/CodeBlock-hf-doc-builder.js";function jl(Xe){let u,z,h,_,I;return{c(){u=a("p"),z=l("To learn more, take a look at the "),h=a("a"),_=l("Distributed Inference with \u{1F917} Accelerate"),I=l(" guide."),this.h()},l(w){u=o(w,"P",{});var E=i(u);z=r(E,"To learn more, take a look at the "),h=o(E,"A",{href:!0,rel:!0});var N=i(h);_=r(N,"Distributed Inference with \u{1F917} Accelerate"),N.forEach(s),I=r(E," guide."),E.forEach(s),this.h()},h(){p(h,"href","https://huggingface.co/docs/accelerate/en/usage_guides/distributed_inference#distributed-inference-with-accelerate"),p(h,"rel","nofollow")},m(w,E){c(w,u,E),t(u,z),t(u,h),t(h,_),t(u,I)},d(w){w&&s(u)}}}function gl(Xe){let u,z,h,_,I,w,E,N,yt,Be,U,wt,F,_t,bt,Q,Mt,vt,Ye,de,Jt,He,A,R,be,q,Et,Me,Ut,xe,W,Tt,O,jt,gt,Ve,m,$t,K,kt,Ct,ve,Pt,Zt,Je,Gt,It,fe,At,Dt,Ee,zt,Nt,Fe,S,Rt,L,Wt,St,Qe,ee,qe,T,Xt,Ue,Bt,Yt,Te,Ht,xt,Oe,te,Ke,X,Le,D,B,je,se,Vt,ge,Ft,et,Y,Qt,le,$e,qt,Ot,tt,b,Kt,ke,Lt,es,Ce,ts,ss,ue,ls,rs,st,re,lt,y,as,ae,Pe,os,is,Ze,ns,cs,Ge,ps,ds,Ie,fs,us,rt,M,hs,he,ms,ys,Ae,ws,_s,De,bs,Ms,at,oe,ot,v,vs,ie,ze,Js,Es,Ne,Us,Ts,Re,js,gs,it,ne,nt,j,$s,We,ks,Cs,Se,Ps,Zs,ct,ce,pt;return w=new Gs({}),q=new Gs({}),ee=new _e({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>)`}}),te=new _e({props:{code:"YWNjZWxlcmF0ZSUyMGxhdW5jaCUyMHJ1bl9kaXN0cmlidXRlZC5weSUyMC0tbnVtX3Byb2Nlc3NlcyUzRDI=",highlighted:"accelerate launch run_distributed.py --num_processes=2"}}),X=new Tl({props:{$$slots:{default:[jl]},$$scope:{ctx:Xe}}}),se=new Gs({}),re=new _e({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)`}}),oe=new _e({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>)`}}),ne=new _e({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()`}}),ce=new _e({props:{code:"dG9yY2hydW4lMjBydW5fZGlzdHJpYnV0ZWQucHklMjAtLW5wcm9jX3Blcl9ub2RlJTNEMg==",highlighted:"torchrun run_distributed.py --nproc_per_node=2"}}),{c(){u=a("meta"),z=d(),h=a("h1"),_=a("a"),I=a("span"),$(w.$$.fragment),E=d(),N=a("span"),yt=l("Distributed inference with multiple GPUs"),Be=d(),U=a("p"),wt=l("On distributed setups, you can run inference across multiple GPUs with \u{1F917} "),F=a("a"),_t=l("Accelerate"),bt=l(" or "),Q=a("a"),Mt=l("PyTorch Distributed"),vt=l(", which is useful for generating with multiple prompts in parallel."),Ye=d(),de=a("p"),Jt=l("This guide will show you how to use \u{1F917} Accelerate and PyTorch Distributed for distributed inference."),He=d(),A=a("h2"),R=a("a"),be=a("span"),$(q.$$.fragment),Et=d(),Me=a("span"),Ut=l("\u{1F917} Accelerate"),xe=d(),W=a("p"),Tt=l("\u{1F917} "),O=a("a"),jt=l("Accelerate"),gt=l(" is a library designed to make it easy to train or run inference across distributed setups. It simplifies the process of setting up the distributed environment, allowing you to focus on your PyTorch code."),Ve=d(),m=a("p"),$t=l("To begin, create a Python file and initialize an "),K=a("a"),kt=l("accelerate.PartialState"),Ct=l(" to create a distributed environment; your setup is automatically detected so you don\u2019t need to explicitly define the "),ve=a("code"),Pt=l("rank"),Zt=l(" or "),Je=a("code"),Gt=l("world_size"),It=l(". Move the "),fe=a("a"),At=l("DiffusionPipeline"),Dt=l(" to "),Ee=a("code"),zt=l("distributed_state.device"),Nt=l(" to assign a GPU to each process."),Fe=d(),S=a("p"),Rt=l("Now use the "),L=a("a"),Wt=l("split_between_processes"),St=l(" utility as a context manager to automatically distribute the prompts between the number of processes."),Qe=d(),$(ee.$$.fragment),qe=d(),T=a("p"),Xt=l("Use the "),Ue=a("code"),Bt=l("--num_processes"),Yt=l(" argument to specify the number of GPUs to use, and call "),Te=a("code"),Ht=l("accelerate launch"),xt=l(" to run the script:"),Oe=d(),$(te.$$.fragment),Ke=d(),$(X.$$.fragment),Le=d(),D=a("h2"),B=a("a"),je=a("span"),$(se.$$.fragment),Vt=d(),ge=a("span"),Ft=l("PyTorch Distributed"),et=d(),Y=a("p"),Qt=l("PyTorch supports "),le=a("a"),$e=a("code"),qt=l("DistributedDataParallel"),Ot=l(" which enables data parallelism."),tt=d(),b=a("p"),Kt=l("To start, create a Python file and import "),ke=a("code"),Lt=l("torch.distributed"),es=l(" and "),Ce=a("code"),ts=l("torch.multiprocessing"),ss=l(" to set up the distributed process group and to spawn the processes for inference on each GPU. You should also initialize a "),ue=a("a"),ls=l("DiffusionPipeline"),rs=l(":"),st=d(),$(re.$$.fragment),lt=d(),y=a("p"),as=l("You\u2019ll want to create a function to run inference; "),ae=a("a"),Pe=a("code"),os=l("init_process_group"),is=l(" handles creating a distributed environment with the type of backend to use, the "),Ze=a("code"),ns=l("rank"),cs=l(" of the current process, and the "),Ge=a("code"),ps=l("world_size"),ds=l(" or the number of processes participating. If you\u2019re running inference in parallel over 2 GPUs, then the "),Ie=a("code"),fs=l("world_size"),us=l(" is 2."),rt=d(),M=a("p"),hs=l("Move the "),he=a("a"),ms=l("DiffusionPipeline"),ys=l(" to "),Ae=a("code"),ws=l("rank"),_s=l(" and use "),De=a("code"),bs=l("get_rank"),Ms=l(" to assign a GPU to each process, where each process handles a different prompt:"),at=d(),$(oe.$$.fragment),ot=d(),v=a("p"),vs=l("To run the distributed inference, call "),ie=a("a"),ze=a("code"),Js=l("mp.spawn"),Es=l(" to run the "),Ne=a("code"),Us=l("run_inference"),Ts=l(" function on the number of GPUs defined in "),Re=a("code"),js=l("world_size"),gs=l(":"),it=d(),$(ne.$$.fragment),nt=d(),j=a("p"),$s=l("Once you\u2019ve completed the inference script, use the "),We=a("code"),ks=l("--nproc_per_node"),Cs=l(" argument to specify the number of GPUs to use and call "),Se=a("code"),Ps=l("torchrun"),Zs=l(" to run the script:"),ct=d(),$(ce.$$.fragment),this.h()},l(e){const n=El('[data-svelte="svelte-1phssyn"]',document.head);u=o(n,"META",{name:!0,content:!0}),n.forEach(s),z=f(e),h=o(e,"H1",{class:!0});var pe=i(h);_=o(pe,"A",{id:!0,class:!0,href:!0});var Is=i(_);I=o(Is,"SPAN",{});var As=i(I);k(w.$$.fragment,As),As.forEach(s),Is.forEach(s),E=f(pe),N=o(pe,"SPAN",{});var Ds=i(N);yt=r(Ds,"Distributed inference with multiple GPUs"),Ds.forEach(s),pe.forEach(s),Be=f(e),U=o(e,"P",{});var me=i(U);wt=r(me,"On distributed setups, you can run inference across multiple GPUs with \u{1F917} "),F=o(me,"A",{href:!0,rel:!0});var zs=i(F);_t=r(zs,"Accelerate"),zs.forEach(s),bt=r(me," or "),Q=o(me,"A",{href:!0,rel:!0});var Ns=i(Q);Mt=r(Ns,"PyTorch Distributed"),Ns.forEach(s),vt=r(me,", which is useful for generating with multiple prompts in parallel."),me.forEach(s),Ye=f(e),de=o(e,"P",{});var Rs=i(de);Jt=r(Rs,"This guide will show you how to use \u{1F917} Accelerate and PyTorch Distributed for distributed inference."),Rs.forEach(s),He=f(e),A=o(e,"H2",{class:!0});var dt=i(A);R=o(dt,"A",{id:!0,class:!0,href:!0});var Ws=i(R);be=o(Ws,"SPAN",{});var Ss=i(be);k(q.$$.fragment,Ss),Ss.forEach(s),Ws.forEach(s),Et=f(dt),Me=o(dt,"SPAN",{});var Xs=i(Me);Ut=r(Xs,"\u{1F917} Accelerate"),Xs.forEach(s),dt.forEach(s),xe=f(e),W=o(e,"P",{});var ft=i(W);Tt=r(ft,"\u{1F917} "),O=o(ft,"A",{href:!0,rel:!0});var Bs=i(O);jt=r(Bs,"Accelerate"),Bs.forEach(s),gt=r(ft," is a library designed to make it easy to train or run inference across distributed setups. It simplifies the process of setting up the distributed environment, allowing you to focus on your PyTorch code."),ft.forEach(s),Ve=f(e),m=o(e,"P",{});var J=i(m);$t=r(J,"To begin, create a Python file and initialize an "),K=o(J,"A",{href:!0,rel:!0});var Ys=i(K);kt=r(Ys,"accelerate.PartialState"),Ys.forEach(s),Ct=r(J," to create a distributed environment; your setup is automatically detected so you don\u2019t need to explicitly define the "),ve=o(J,"CODE",{});var Hs=i(ve);Pt=r(Hs,"rank"),Hs.forEach(s),Zt=r(J," or "),Je=o(J,"CODE",{});var xs=i(Je);Gt=r(xs,"world_size"),xs.forEach(s),It=r(J,". Move the "),fe=o(J,"A",{href:!0});var Vs=i(fe);At=r(Vs,"DiffusionPipeline"),Vs.forEach(s),Dt=r(J," to "),Ee=o(J,"CODE",{});var Fs=i(Ee);zt=r(Fs,"distributed_state.device"),Fs.forEach(s),Nt=r(J," to assign a GPU to each process."),J.forEach(s),Fe=f(e),S=o(e,"P",{});var ut=i(S);Rt=r(ut,"Now use the "),L=o(ut,"A",{href:!0,rel:!0});var Qs=i(L);Wt=r(Qs,"split_between_processes"),Qs.forEach(s),St=r(ut," utility as a context manager to automatically distribute the prompts between the number of processes."),ut.forEach(s),Qe=f(e),k(ee.$$.fragment,e),qe=f(e),T=o(e,"P",{});var ye=i(T);Xt=r(ye,"Use the "),Ue=o(ye,"CODE",{});var qs=i(Ue);Bt=r(qs,"--num_processes"),qs.forEach(s),Yt=r(ye," argument to specify the number of GPUs to use, and call "),Te=o(ye,"CODE",{});var Os=i(Te);Ht=r(Os,"accelerate launch"),Os.forEach(s),xt=r(ye," to run the script:"),ye.forEach(s),Oe=f(e),k(te.$$.fragment,e),Ke=f(e),k(X.$$.fragment,e),Le=f(e),D=o(e,"H2",{class:!0});var ht=i(D);B=o(ht,"A",{id:!0,class:!0,href:!0});var Ks=i(B);je=o(Ks,"SPAN",{});var Ls=i(je);k(se.$$.fragment,Ls),Ls.forEach(s),Ks.forEach(s),Vt=f(ht),ge=o(ht,"SPAN",{});var el=i(ge);Ft=r(el,"PyTorch Distributed"),el.forEach(s),ht.forEach(s),et=f(e),Y=o(e,"P",{});var mt=i(Y);Qt=r(mt,"PyTorch supports "),le=o(mt,"A",{href:!0,rel:!0});var tl=i(le);$e=o(tl,"CODE",{});var sl=i($e);qt=r(sl,"DistributedDataParallel"),sl.forEach(s),tl.forEach(s),Ot=r(mt," which enables data parallelism."),mt.forEach(s),tt=f(e),b=o(e,"P",{});var H=i(b);Kt=r(H,"To start, create a Python file and import "),ke=o(H,"CODE",{});var ll=i(ke);Lt=r(ll,"torch.distributed"),ll.forEach(s),es=r(H," and "),Ce=o(H,"CODE",{});var rl=i(Ce);ts=r(rl,"torch.multiprocessing"),rl.forEach(s),ss=r(H," to set up the distributed process group and to spawn the processes for inference on each GPU. You should also initialize a "),ue=o(H,"A",{href:!0});var al=i(ue);ls=r(al,"DiffusionPipeline"),al.forEach(s),rs=r(H,":"),H.forEach(s),st=f(e),k(re.$$.fragment,e),lt=f(e),y=o(e,"P",{});var g=i(y);as=r(g,"You\u2019ll want to create a function to run inference; "),ae=o(g,"A",{href:!0,rel:!0});var ol=i(ae);Pe=o(ol,"CODE",{});var il=i(Pe);os=r(il,"init_process_group"),il.forEach(s),ol.forEach(s),is=r(g," handles creating a distributed environment with the type of backend to use, the "),Ze=o(g,"CODE",{});var nl=i(Ze);ns=r(nl,"rank"),nl.forEach(s),cs=r(g," of the current process, and the "),Ge=o(g,"CODE",{});var cl=i(Ge);ps=r(cl,"world_size"),cl.forEach(s),ds=r(g," or the number of processes participating. If you\u2019re running inference in parallel over 2 GPUs, then the "),Ie=o(g,"CODE",{});var pl=i(Ie);fs=r(pl,"world_size"),pl.forEach(s),us=r(g," is 2."),g.forEach(s),rt=f(e),M=o(e,"P",{});var x=i(M);hs=r(x,"Move the "),he=o(x,"A",{href:!0});var dl=i(he);ms=r(dl,"DiffusionPipeline"),dl.forEach(s),ys=r(x," to "),Ae=o(x,"CODE",{});var fl=i(Ae);ws=r(fl,"rank"),fl.forEach(s),_s=r(x," and use "),De=o(x,"CODE",{});var ul=i(De);bs=r(ul,"get_rank"),ul.forEach(s),Ms=r(x," to assign a GPU to each process, where each process handles a different prompt:"),x.forEach(s),at=f(e),k(oe.$$.fragment,e),ot=f(e),v=o(e,"P",{});var V=i(v);vs=r(V,"To run the distributed inference, call "),ie=o(V,"A",{href:!0,rel:!0});var hl=i(ie);ze=o(hl,"CODE",{});var ml=i(ze);Js=r(ml,"mp.spawn"),ml.forEach(s),hl.forEach(s),Es=r(V," to run the "),Ne=o(V,"CODE",{});var yl=i(Ne);Us=r(yl,"run_inference"),yl.forEach(s),Ts=r(V," function on the number of GPUs defined in "),Re=o(V,"CODE",{});var wl=i(Re);js=r(wl,"world_size"),wl.forEach(s),gs=r(V,":"),V.forEach(s),it=f(e),k(ne.$$.fragment,e),nt=f(e),j=o(e,"P",{});var we=i(j);$s=r(we,"Once you\u2019ve completed the inference script, use the "),We=o(we,"CODE",{});var _l=i(We);ks=r(_l,"--nproc_per_node"),_l.forEach(s),Cs=r(we," argument to specify the number of GPUs to use and call "),Se=o(we,"CODE",{});var bl=i(Se);Ps=r(bl,"torchrun"),bl.forEach(s),Zs=r(we," to run the script:"),we.forEach(s),ct=f(e),k(ce.$$.fragment,e),this.h()},h(){p(u,"name","hf:doc:metadata"),p(u,"content",JSON.stringify($l)),p(_,"id","distributed-inference-with-multiple-gpus"),p(_,"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"),p(_,"href","#distributed-inference-with-multiple-gpus"),p(h,"class","relative group"),p(F,"href","https://huggingface.co/docs/accelerate/index"),p(F,"rel","nofollow"),p(Q,"href","https://pytorch.org/tutorials/beginner/dist_overview.html"),p(Q,"rel","nofollow"),p(R,"id","accelerate"),p(R,"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"),p(R,"href","#accelerate"),p(A,"class","relative group"),p(O,"href","https://huggingface.co/docs/accelerate/index"),p(O,"rel","nofollow"),p(K,"href","https://huggingface.co/docs/accelerate/v0.20.3/en/package_reference/state#accelerate.PartialState"),p(K,"rel","nofollow"),p(fe,"href","/docs/diffusers/v0.17.0/en/api/diffusion_pipeline#diffusers.DiffusionPipeline"),p(L,"href","https://huggingface.co/docs/accelerate/v0.20.3/en/package_reference/state#accelerate.PartialState.split_between_processes"),p(L,"rel","nofollow"),p(B,"id","pytorch-distributed"),p(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"),p(B,"href","#pytorch-distributed"),p(D,"class","relative group"),p(le,"href","https://pytorch.org/docs/stable/generated/torch.nn.parallel.DistributedDataParallel.html"),p(le,"rel","nofollow"),p(ue,"href","/docs/diffusers/v0.17.0/en/api/diffusion_pipeline#diffusers.DiffusionPipeline"),p(ae,"href","https://pytorch.org/docs/stable/distributed.html?highlight=init_process_group#torch.distributed.init_process_group"),p(ae,"rel","nofollow"),p(he,"href","/docs/diffusers/v0.17.0/en/api/diffusion_pipeline#diffusers.DiffusionPipeline"),p(ie,"href","https://pytorch.org/docs/stable/multiprocessing.html#torch.multiprocessing.spawn"),p(ie,"rel","nofollow")},m(e,n){t(document.head,u),c(e,z,n),c(e,h,n),t(h,_),t(_,I),C(w,I,null),t(h,E),t(h,N),t(N,yt),c(e,Be,n),c(e,U,n),t(U,wt),t(U,F),t(F,_t),t(U,bt),t(U,Q),t(Q,Mt),t(U,vt),c(e,Ye,n),c(e,de,n),t(de,Jt),c(e,He,n),c(e,A,n),t(A,R),t(R,be),C(q,be,null),t(A,Et),t(A,Me),t(Me,Ut),c(e,xe,n),c(e,W,n),t(W,Tt),t(W,O),t(O,jt),t(W,gt),c(e,Ve,n),c(e,m,n),t(m,$t),t(m,K),t(K,kt),t(m,Ct),t(m,ve),t(ve,Pt),t(m,Zt),t(m,Je),t(Je,Gt),t(m,It),t(m,fe),t(fe,At),t(m,Dt),t(m,Ee),t(Ee,zt),t(m,Nt),c(e,Fe,n),c(e,S,n),t(S,Rt),t(S,L),t(L,Wt),t(S,St),c(e,Qe,n),C(ee,e,n),c(e,qe,n),c(e,T,n),t(T,Xt),t(T,Ue),t(Ue,Bt),t(T,Yt),t(T,Te),t(Te,Ht),t(T,xt),c(e,Oe,n),C(te,e,n),c(e,Ke,n),C(X,e,n),c(e,Le,n),c(e,D,n),t(D,B),t(B,je),C(se,je,null),t(D,Vt),t(D,ge),t(ge,Ft),c(e,et,n),c(e,Y,n),t(Y,Qt),t(Y,le),t(le,$e),t($e,qt),t(Y,Ot),c(e,tt,n),c(e,b,n),t(b,Kt),t(b,ke),t(ke,Lt),t(b,es),t(b,Ce),t(Ce,ts),t(b,ss),t(b,ue),t(ue,ls),t(b,rs),c(e,st,n),C(re,e,n),c(e,lt,n),c(e,y,n),t(y,as),t(y,ae),t(ae,Pe),t(Pe,os),t(y,is),t(y,Ze),t(Ze,ns),t(y,cs),t(y,Ge),t(Ge,ps),t(y,ds),t(y,Ie),t(Ie,fs),t(y,us),c(e,rt,n),c(e,M,n),t(M,hs),t(M,he),t(he,ms),t(M,ys),t(M,Ae),t(Ae,ws),t(M,_s),t(M,De),t(De,bs),t(M,Ms),c(e,at,n),C(oe,e,n),c(e,ot,n),c(e,v,n),t(v,vs),t(v,ie),t(ie,ze),t(ze,Js),t(v,Es),t(v,Ne),t(Ne,Us),t(v,Ts),t(v,Re),t(Re,js),t(v,gs),c(e,it,n),C(ne,e,n),c(e,nt,n),c(e,j,n),t(j,$s),t(j,We),t(We,ks),t(j,Cs),t(j,Se),t(Se,Ps),t(j,Zs),c(e,ct,n),C(ce,e,n),pt=!0},p(e,[n]){const pe={};n&2&&(pe.$$scope={dirty:n,ctx:e}),X.$set(pe)},i(e){pt||(P(w.$$.fragment,e),P(q.$$.fragment,e),P(ee.$$.fragment,e),P(te.$$.fragment,e),P(X.$$.fragment,e),P(se.$$.fragment,e),P(re.$$.fragment,e),P(oe.$$.fragment,e),P(ne.$$.fragment,e),P(ce.$$.fragment,e),pt=!0)},o(e){Z(w.$$.fragment,e),Z(q.$$.fragment,e),Z(ee.$$.fragment,e),Z(te.$$.fragment,e),Z(X.$$.fragment,e),Z(se.$$.fragment,e),Z(re.$$.fragment,e),Z(oe.$$.fragment,e),Z(ne.$$.fragment,e),Z(ce.$$.fragment,e),pt=!1},d(e){s(u),e&&s(z),e&&s(h),G(w),e&&s(Be),e&&s(U),e&&s(Ye),e&&s(de),e&&s(He),e&&s(A),G(q),e&&s(xe),e&&s(W),e&&s(Ve),e&&s(m),e&&s(Fe),e&&s(S),e&&s(Qe),G(ee,e),e&&s(qe),e&&s(T),e&&s(Oe),G(te,e),e&&s(Ke),G(X,e),e&&s(Le),e&&s(D),G(se),e&&s(et),e&&s(Y),e&&s(tt),e&&s(b),e&&s(st),G(re,e),e&&s(lt),e&&s(y),e&&s(rt),e&&s(M),e&&s(at),G(oe,e),e&&s(ot),e&&s(v),e&&s(it),G(ne,e),e&&s(nt),e&&s(j),e&&s(ct),G(ce,e)}}}const $l={local:"distributed-inference-with-multiple-gpus",sections:[{local:"accelerate",title:"\u{1F917} Accelerate"},{local:"pytorch-distributed",title:"PyTorch Distributed"}],title:"Distributed inference with multiple GPUs"};function kl(Xe){return Ul(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Il extends Ml{constructor(u){super();vl(this,u,kl,gl,Jl,{})}}export{Il as default,$l as metadata};
