import{S as vl,i as Ml,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 u,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 be}from"../../chunks/CodeBlock-hf-doc-builder.js";function jl(Xe){let f,z,h,b,I;return{c(){f=a("p"),z=l("To learn more, take a look at the "),h=a("a"),b=l("Distributed Inference with \u{1F917} Accelerate"),I=l(" guide."),this.h()},l(w){f=o(w,"P",{});var E=i(f);z=r(E,"To learn more, take a look at the "),h=o(E,"A",{href:!0,rel:!0});var N=i(h);b=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,f,E),t(f,z),t(f,h),t(h,b),t(f,I)},d(w){w&&s(f)}}}function gl(Xe){let f,z,h,b,I,w,E,N,yt,Be,U,wt,F,bt,_t,Q,vt,Mt,Ye,de,Jt,He,A,R,_e,q,Et,ve,Ut,xe,W,Tt,O,jt,gt,Ve,m,$t,K,kt,Ct,Me,Pt,Zt,Je,Gt,It,ue,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,_,Kt,ke,Lt,es,Ce,ts,ss,fe,ls,rs,st,re,lt,y,as,ae,Pe,os,is,Ze,ns,cs,Ge,ps,ds,Ie,us,fs,rt,v,hs,he,ms,ys,Ae,ws,bs,De,_s,vs,at,oe,ot,M,Ms,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 be({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 be({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 be({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 be({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 be({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 be({props:{code:"dG9yY2hydW4lMjBydW5fZGlzdHJpYnV0ZWQucHklMjAtLW5wcm9jX3Blcl9ub2RlJTNEMg==",highlighted:"torchrun run_distributed.py --nproc_per_node=2"}}),{c(){f=a("meta"),z=d(),h=a("h1"),b=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"),bt=l("Accelerate"),_t=l(" or "),Q=a("a"),vt=l("PyTorch Distributed"),Mt=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"),_e=a("span"),$(q.$$.fragment),Et=d(),ve=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 "),Me=a("code"),Pt=l("rank"),Zt=l(" or "),Je=a("code"),Gt=l("world_size"),It=l(". Move the "),ue=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(),_=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 "),fe=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"),us=l("world_size"),fs=l(" is 2."),rt=d(),v=a("p"),hs=l("Move the "),he=a("a"),ms=l("DiffusionPipeline"),ys=l(" to "),Ae=a("code"),ws=l("rank"),bs=l(" and use "),De=a("code"),_s=l("get_rank"),vs=l(" to assign a GPU to each process, where each process handles a different prompt:"),at=d(),$(oe.$$.fragment),ot=d(),M=a("p"),Ms=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);f=o(n,"META",{name:!0,content:!0}),n.forEach(s),z=u(e),h=o(e,"H1",{class:!0});var pe=i(h);b=o(pe,"A",{id:!0,class:!0,href:!0});var Is=i(b);I=o(Is,"SPAN",{});var As=i(I);k(w.$$.fragment,As),As.forEach(s),Is.forEach(s),E=u(pe),N=o(pe,"SPAN",{});var Ds=i(N);yt=r(Ds,"Distributed inference with multiple GPUs"),Ds.forEach(s),pe.forEach(s),Be=u(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);bt=r(zs,"Accelerate"),zs.forEach(s),_t=r(me," or "),Q=o(me,"A",{href:!0,rel:!0});var Ns=i(Q);vt=r(Ns,"PyTorch Distributed"),Ns.forEach(s),Mt=r(me,", which is useful for generating with multiple prompts in parallel."),me.forEach(s),Ye=u(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=u(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);_e=o(Ws,"SPAN",{});var Ss=i(_e);k(q.$$.fragment,Ss),Ss.forEach(s),Ws.forEach(s),Et=u(dt),ve=o(dt,"SPAN",{});var Xs=i(ve);Ut=r(Xs,"\u{1F917} Accelerate"),Xs.forEach(s),dt.forEach(s),xe=u(e),W=o(e,"P",{});var ut=i(W);Tt=r(ut,"\u{1F917} "),O=o(ut,"A",{href:!0,rel:!0});var Bs=i(O);jt=r(Bs,"Accelerate"),Bs.forEach(s),gt=r(ut," 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."),ut.forEach(s),Ve=u(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 "),Me=o(J,"CODE",{});var Hs=i(Me);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 "),ue=o(J,"A",{href:!0});var Vs=i(ue);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=u(e),S=o(e,"P",{});var ft=i(S);Rt=r(ft,"Now use the "),L=o(ft,"A",{href:!0,rel:!0});var Qs=i(L);Wt=r(Qs,"split_between_processes"),Qs.forEach(s),St=r(ft," utility as a context manager to automatically distribute the prompts between the number of processes."),ft.forEach(s),Qe=u(e),k(ee.$$.fragment,e),qe=u(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=u(e),k(te.$$.fragment,e),Ke=u(e),k(X.$$.fragment,e),Le=u(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=u(ht),ge=o(ht,"SPAN",{});var el=i(ge);Ft=r(el,"PyTorch Distributed"),el.forEach(s),ht.forEach(s),et=u(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=u(e),_=o(e,"P",{});var H=i(_);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 "),fe=o(H,"A",{href:!0});var al=i(fe);ls=r(al,"DiffusionPipeline"),al.forEach(s),rs=r(H,":"),H.forEach(s),st=u(e),k(re.$$.fragment,e),lt=u(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);us=r(pl,"world_size"),pl.forEach(s),fs=r(g," is 2."),g.forEach(s),rt=u(e),v=o(e,"P",{});var x=i(v);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 ul=i(Ae);ws=r(ul,"rank"),ul.forEach(s),bs=r(x," and use "),De=o(x,"CODE",{});var fl=i(De);_s=r(fl,"get_rank"),fl.forEach(s),vs=r(x," to assign a GPU to each process, where each process handles a different prompt:"),x.forEach(s),at=u(e),k(oe.$$.fragment,e),ot=u(e),M=o(e,"P",{});var V=i(M);Ms=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=u(e),k(ne.$$.fragment,e),nt=u(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 bl=i(We);ks=r(bl,"--nproc_per_node"),bl.forEach(s),Cs=r(we," argument to specify the number of GPUs to use and call "),Se=o(we,"CODE",{});var _l=i(Se);Ps=r(_l,"torchrun"),_l.forEach(s),Zs=r(we," to run the script:"),we.forEach(s),ct=u(e),k(ce.$$.fragment,e),this.h()},h(){p(f,"name","hf:doc:metadata"),p(f,"content",JSON.stringify($l)),p(b,"id","distributed-inference-with-multiple-gpus"),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","#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.21.0/en/package_reference/state#accelerate.PartialState"),p(K,"rel","nofollow"),p(ue,"href","/docs/diffusers/v0.19.2/en/api/pipelines/overview#diffusers.DiffusionPipeline"),p(L,"href","https://huggingface.co/docs/accelerate/v0.21.0/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(fe,"href","/docs/diffusers/v0.19.2/en/api/pipelines/overview#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.19.2/en/api/pipelines/overview#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,f),c(e,z,n),c(e,h,n),t(h,b),t(b,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,bt),t(U,_t),t(U,Q),t(Q,vt),t(U,Mt),c(e,Ye,n),c(e,de,n),t(de,Jt),c(e,He,n),c(e,A,n),t(A,R),t(R,_e),C(q,_e,null),t(A,Et),t(A,ve),t(ve,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,Me),t(Me,Pt),t(m,Zt),t(m,Je),t(Je,Gt),t(m,It),t(m,ue),t(ue,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,_,n),t(_,Kt),t(_,ke),t(ke,Lt),t(_,es),t(_,Ce),t(Ce,ts),t(_,ss),t(_,fe),t(fe,ls),t(_,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,us),t(y,fs),c(e,rt,n),c(e,v,n),t(v,hs),t(v,he),t(he,ms),t(v,ys),t(v,Ae),t(Ae,ws),t(v,bs),t(v,De),t(De,_s),t(v,vs),c(e,at,n),C(oe,e,n),c(e,ot,n),c(e,M,n),t(M,Ms),t(M,ie),t(ie,ze),t(ze,Js),t(M,Es),t(M,Ne),t(Ne,Us),t(M,Ts),t(M,Re),t(Re,js),t(M,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(f),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(_),e&&s(st),G(re,e),e&&s(lt),e&&s(y),e&&s(rt),e&&s(v),e&&s(at),G(oe,e),e&&s(ot),e&&s(M),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 vl{constructor(f){super();Ml(this,f,kl,gl,Jl,{})}}export{Il as default,$l as metadata};
