Buckets:

rtrm's picture
download
raw
9.21 kB
import{s as ae,o as oe,n as re}from"../chunks/scheduler.182ea377.js";import{S as pe,i as me,g as r,s as n,r as g,A as ce,h as p,f as s,c as a,j as le,u as G,x as c,k as ie,y as ue,a as l,v as j,d as $,t as I,w as _}from"../chunks/index.abf12888.js";import{T as fe}from"../chunks/Tip.230e2334.js";import{C as A}from"../chunks/CodeBlock.57fe6e13.js";import{H as ne}from"../chunks/Heading.16916d63.js";function he(C){let i,u='Generating multiple prompts in a batch can <a href="https://github.com/huggingface/diffusers/issues/363" rel="nofollow">crash</a> or fail to work reliably. We believe this is related to the <a href="https://github.com/pytorch/pytorch/issues/84039" rel="nofollow"><code>mps</code></a> backend in PyTorch. While this is being investigated, you should iterate instead of batching.';return{c(){i=r("p"),i.innerHTML=u},l(o){i=p(o,"P",{"data-svelte-h":!0}),c(i)!=="svelte-17wj08e"&&(i.innerHTML=u)},m(o,Z){l(o,i,Z)},p:re,d(o){o&&s(i)}}}function de(C){let i,u,o,Z,f,X,h,Q='🤗 Diffusers is compatible with Apple silicon (M1/M2 chips) using the PyTorch <a href="https://pytorch.org/docs/stable/notes/mps.html" rel="nofollow"><code>mps</code></a> device, which uses the Metal framework to leverage the GPU on MacOS devices. You’ll need to have:',P,d,F='<li>macOS computer with Apple silicon (M1/M2) hardware</li> <li>macOS 12.6 or later (13.0 or later recommended)</li> <li>arm64 version of Python</li> <li><a href="https://pytorch.org/get-started/locally/" rel="nofollow">PyTorch 2.0</a> (recommended) or 1.13 (minimum version supported for <code>mps</code>)</li>',S,y,D="The <code>mps</code> backend uses PyTorch’s <code>.to()</code> interface to move the Stable Diffusion pipeline on to your M1 or M2 device:",H,M,R,m,Y,w,K="If you’re using <strong>PyTorch 1.13</strong>, you need to “prime” the pipeline with an additional one-time pass through it. This is a temporary workaround for an issue where the first inference pass produces slightly different results than subsequent ones. You only need to do this pass once, and after just one inference step you can discard the result.",k,T,V,J,E,b,O="M1/M2 performance is very sensitive to memory pressure. When this occurs, the system automatically swaps if it needs to which significantly degrades performance.",z,v,ee='To prevent this from happening, we recommend <em>attention slicing</em> to reduce memory pressure during inference and prevent swapping. This is especially relevant if your computer has less than 64GB of system RAM, or if you generate images at non-standard resolutions larger than 512×512 pixels. Call the <a href="/docs/diffusers/v0.22.2/en/api/pipelines/stable_diffusion/image_variation#diffusers.StableDiffusionImageVariationPipeline.enable_attention_slicing">enable_attention_slicing()</a> function on your pipeline:',L,U,q,B,te="Attention slicing performs the costly attention operation in multiple steps instead of all at once. It usually improves performance by ~20% in computers without universal memory, but we’ve observed <em>better performance</em> in most Apple silicon computers unless you have 64GB of RAM or more.",x,W,N;return f=new ne({props:{title:"Metal Performance Shaders (MPS)",local:"metal-performance-shaders-mps",headingTag:"h1"}}),M=new A({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMERpZmZ1c2lvblBpcGVsaW5lJTBBJTBBcGlwZSUyMCUzRCUyMERpZmZ1c2lvblBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMjJydW53YXltbCUyRnN0YWJsZS1kaWZmdXNpb24tdjEtNSUyMiklMEFwaXBlJTIwJTNEJTIwcGlwZS50byglMjJtcHMlMjIpJTBBJTBBJTIzJTIwUmVjb21tZW5kZWQlMjBpZiUyMHlvdXIlMjBjb21wdXRlciUyMGhhcyUyMCUzQyUyMDY0JTIwR0IlMjBvZiUyMFJBTSUwQXBpcGUuZW5hYmxlX2F0dGVudGlvbl9zbGljaW5nKCklMEElMEFwcm9tcHQlMjAlM0QlMjAlMjJhJTIwcGhvdG8lMjBvZiUyMGFuJTIwYXN0cm9uYXV0JTIwcmlkaW5nJTIwYSUyMGhvcnNlJTIwb24lMjBtYXJzJTIy",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline
pipe = DiffusionPipeline.from_pretrained(<span class="hljs-string">&quot;runwayml/stable-diffusion-v1-5&quot;</span>)
pipe = pipe.to(<span class="hljs-string">&quot;mps&quot;</span>)
<span class="hljs-comment"># Recommended if your computer has &lt; 64 GB of RAM</span>
pipe.enable_attention_slicing()
prompt = <span class="hljs-string">&quot;a photo of an astronaut riding a horse on mars&quot;</span>`,wrap:!1}}),m=new fe({props:{warning:!0,$$slots:{default:[he]},$$scope:{ctx:C}}}),T=new A({props:{code:"JTIwJTIwZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMERpZmZ1c2lvblBpcGVsaW5lJTBBJTBBJTIwJTIwcGlwZSUyMCUzRCUyMERpZmZ1c2lvblBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMjJydW53YXltbCUyRnN0YWJsZS1kaWZmdXNpb24tdjEtNSUyMikudG8oJTIybXBzJTIyKSUwQSUyMCUyMHBpcGUuZW5hYmxlX2F0dGVudGlvbl9zbGljaW5nKCklMEElMEElMjAlMjBwcm9tcHQlMjAlM0QlMjAlMjJhJTIwcGhvdG8lMjBvZiUyMGFuJTIwYXN0cm9uYXV0JTIwcmlkaW5nJTIwYSUyMGhvcnNlJTIwb24lMjBtYXJzJTIyJTBBJTIzJTIwRmlyc3QtdGltZSUyMCUyMndhcm11cCUyMiUyMHBhc3MlMjBpZiUyMFB5VG9yY2glMjB2ZXJzaW9uJTIwaXMlMjAxLjEzJTBBJTJCJTIwXyUyMCUzRCUyMHBpcGUocHJvbXB0JTJDJTIwbnVtX2luZmVyZW5jZV9zdGVwcyUzRDEpJTBBJTBBJTIzJTIwUmVzdWx0cyUyMG1hdGNoJTIwdGhvc2UlMjBmcm9tJTIwdGhlJTIwQ1BVJTIwZGV2aWNlJTIwYWZ0ZXIlMjB0aGUlMjB3YXJtdXAlMjBwYXNzLiUwQSUyMCUyMGltYWdlJTIwJTNEJTIwcGlwZShwcm9tcHQpLmltYWdlcyU1QjAlNUQ=",highlighted:` from diffusers import DiffusionPipeline
pipe = DiffusionPipeline.from_pretrained(&quot;runwayml/stable-diffusion-v1-5&quot;).to(&quot;mps&quot;)
pipe.enable_attention_slicing()
prompt = &quot;a photo of an astronaut riding a horse on mars&quot;
# First-time &quot;warmup&quot; pass if PyTorch version is 1.13
<span class="hljs-addition">+ _ = pipe(prompt, num_inference_steps=1)</span>
# Results match those from the CPU device after the warmup pass.
image = pipe(prompt).images[0]`,wrap:!1}}),J=new ne({props:{title:"Troubleshoot",local:"troubleshoot",headingTag:"h2"}}),U=new A({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMERpZmZ1c2lvblBpcGVsaW5lJTBBJTBBcGlwZWxpbmUlMjAlM0QlMjBEaWZmdXNpb25QaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoJTIycnVud2F5bWwlMkZzdGFibGUtZGlmZnVzaW9uLXYxLTUlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMkMlMjB2YXJpYW50JTNEJTIyZnAxNiUyMiUyQyUyMHVzZV9zYWZldGVuc29ycyUzRFRydWUpLnRvKCUyMm1wcyUyMiklMEFwaXBlbGluZS5lbmFibGVfYXR0ZW50aW9uX3NsaWNpbmcoKQ==",highlighted:`<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, variant=<span class="hljs-string">&quot;fp16&quot;</span>, use_safetensors=<span class="hljs-literal">True</span>).to(<span class="hljs-string">&quot;mps&quot;</span>)
pipeline.enable_attention_slicing()`,wrap:!1}}),{c(){i=r("meta"),u=n(),o=r("p"),Z=n(),g(f.$$.fragment),X=n(),h=r("p"),h.innerHTML=Q,P=n(),d=r("ul"),d.innerHTML=F,S=n(),y=r("p"),y.innerHTML=D,H=n(),g(M.$$.fragment),R=n(),g(m.$$.fragment),Y=n(),w=r("p"),w.innerHTML=K,k=n(),g(T.$$.fragment),V=n(),g(J.$$.fragment),E=n(),b=r("p"),b.textContent=O,z=n(),v=r("p"),v.innerHTML=ee,L=n(),g(U.$$.fragment),q=n(),B=r("p"),B.innerHTML=te,x=n(),W=r("p"),this.h()},l(e){const t=ce("svelte-u9bgzb",document.head);i=p(t,"META",{name:!0,content:!0}),t.forEach(s),u=a(e),o=p(e,"P",{}),le(o).forEach(s),Z=a(e),G(f.$$.fragment,e),X=a(e),h=p(e,"P",{"data-svelte-h":!0}),c(h)!=="svelte-j79ol3"&&(h.innerHTML=Q),P=a(e),d=p(e,"UL",{"data-svelte-h":!0}),c(d)!=="svelte-1rb0nsv"&&(d.innerHTML=F),S=a(e),y=p(e,"P",{"data-svelte-h":!0}),c(y)!=="svelte-n7utwp"&&(y.innerHTML=D),H=a(e),G(M.$$.fragment,e),R=a(e),G(m.$$.fragment,e),Y=a(e),w=p(e,"P",{"data-svelte-h":!0}),c(w)!=="svelte-1sliuep"&&(w.innerHTML=K),k=a(e),G(T.$$.fragment,e),V=a(e),G(J.$$.fragment,e),E=a(e),b=p(e,"P",{"data-svelte-h":!0}),c(b)!=="svelte-1oew7wr"&&(b.textContent=O),z=a(e),v=p(e,"P",{"data-svelte-h":!0}),c(v)!=="svelte-gre1qu"&&(v.innerHTML=ee),L=a(e),G(U.$$.fragment,e),q=a(e),B=p(e,"P",{"data-svelte-h":!0}),c(B)!=="svelte-xihi2j"&&(B.innerHTML=te),x=a(e),W=p(e,"P",{}),le(W).forEach(s),this.h()},h(){ie(i,"name","hf:doc:metadata"),ie(i,"content",ye)},m(e,t){ue(document.head,i),l(e,u,t),l(e,o,t),l(e,Z,t),j(f,e,t),l(e,X,t),l(e,h,t),l(e,P,t),l(e,d,t),l(e,S,t),l(e,y,t),l(e,H,t),j(M,e,t),l(e,R,t),j(m,e,t),l(e,Y,t),l(e,w,t),l(e,k,t),j(T,e,t),l(e,V,t),j(J,e,t),l(e,E,t),l(e,b,t),l(e,z,t),l(e,v,t),l(e,L,t),j(U,e,t),l(e,q,t),l(e,B,t),l(e,x,t),l(e,W,t),N=!0},p(e,[t]){const se={};t&2&&(se.$$scope={dirty:t,ctx:e}),m.$set(se)},i(e){N||($(f.$$.fragment,e),$(M.$$.fragment,e),$(m.$$.fragment,e),$(T.$$.fragment,e),$(J.$$.fragment,e),$(U.$$.fragment,e),N=!0)},o(e){I(f.$$.fragment,e),I(M.$$.fragment,e),I(m.$$.fragment,e),I(T.$$.fragment,e),I(J.$$.fragment,e),I(U.$$.fragment,e),N=!1},d(e){e&&(s(u),s(o),s(Z),s(X),s(h),s(P),s(d),s(S),s(y),s(H),s(R),s(Y),s(w),s(k),s(V),s(E),s(b),s(z),s(v),s(L),s(q),s(B),s(x),s(W)),s(i),_(f,e),_(M,e),_(m,e),_(T,e),_(J,e),_(U,e)}}}const ye='{"title":"Metal Performance Shaders (MPS)","local":"metal-performance-shaders-mps","sections":[{"title":"Troubleshoot","local":"troubleshoot","sections":[],"depth":2}],"depth":1}';function Me(C){return oe(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ue extends pe{constructor(i){super(),me(this,i,Me,de,ae,{})}}export{Ue as component};

Xet Storage Details

Size:
9.21 kB
·
Xet hash:
e81a22a54c416ed3345ce80b7ef1076b180f5863f8570cc49345d6345149dde9

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.