import{s as Qt,o as St,n as ft}from"../chunks/scheduler.b9285784.js";import{S as qt,i as Ot,e as p,s as n,c as h,h as Dt,a as u,d as l,b as a,f as Rt,g as f,j as m,k as Pt,l as Kt,m as s,n as y,t as M,o as g,p as b}from"../chunks/index.26bc89a1.js";import{T as el}from"../chunks/Tip.e4eba3d6.js";import{C as tl,H as J,E as ll}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.7242ff19.js";import{C as v}from"../chunks/CodeBlock.c8ee1711.js";import{H as sl,a as yt}from"../chunks/HfOption.76c7ca3e.js";function nl(U){let i,$;return i=new v({props:{code:"YWNjZWxlcmF0ZSUyMGxhdW5jaCUyMC0tZGVidWclMjAlN0JteV9zY3JpcHQucHklN0QlMjAtLWFyZzElMjAtLWFyZzI=",highlighted:"accelerate launch --debug {my_script.py} --arg1 --arg2",wrap:!1}}),{c(){h(i.$$.fragment)},l(r){f(i.$$.fragment,r)},m(r,d){y(i,r,d),$=!0},p:ft,i(r){$||(M(i.$$.fragment,r),$=!0)},o(r){g(i.$$.fragment,r),$=!1},d(r){b(i,r)}}}function al(U){let i,$="If enabling debug mode as an environment variable, you don’t need to call <code>accelerate launch</code>.",r,d,w;return d=new v({props:{code:"QUNDRUxFUkFURV9ERUJVR19NT0RFJTNEJTIyMSUyMiUyMHRvcmNocnVuJTIwJTdCbXlfc2NyaXB0LnB5JTdEJTIwLS1hcmcxJTIwLS1hcmcy",highlighted:'ACCELERATE_DEBUG_MODE=<span class="hljs-string">&quot;1&quot;</span> torchrun {my_script.py} --arg1 --arg2',wrap:!1}}),{c(){i=p("p"),i.innerHTML=$,r=n(),h(d.$$.fragment)},l(c){i=u(c,"P",{"data-svelte-h":!0}),m(i)!=="svelte-onfw6c"&&(i.innerHTML=$),r=a(c),f(d.$$.fragment,c)},m(c,o){s(c,i,o),s(c,r,o),y(d,c,o),w=!0},p:ft,i(c){w||(M(d.$$.fragment,c),w=!0)},o(c){g(d.$$.fragment,c),w=!1},d(c){c&&(l(i),l(r)),b(d,c)}}}function il(U){let i,$="Add <code>debug: true</code> to your <code>config.yaml</code> file.",r,d,w;return d=new v({props:{code:"Y29tcHV0ZV9lbnZpcm9ubWVudCUzQSUyMExPQ0FMX01BQ0hJTkUlMEFkZWJ1ZyUzQSUyMHRydWU=",highlighted:`<span class="hljs-attr">compute_environment:</span> <span class="hljs-string">LOCAL_MACHINE</span>
<span class="hljs-attr">debug:</span> <span class="hljs-literal">true</span>`,wrap:!1}}),{c(){i=p("p"),i.innerHTML=$,r=n(),h(d.$$.fragment)},l(c){i=u(c,"P",{"data-svelte-h":!0}),m(i)!=="svelte-10693yl"&&(i.innerHTML=$),r=a(c),f(d.$$.fragment,c)},m(c,o){s(c,i,o),s(c,r,o),y(d,c,o),w=!0},p:ft,i(c){w||(M(d.$$.fragment,c),w=!0)},o(c){g(d.$$.fragment,c),w=!1},d(c){c&&(l(i),l(r)),b(d,c)}}}function ol(U){let i,$,r,d,w,c;return i=new yt({props:{id:"mismatch",option:"CLI",$$slots:{default:[nl]},$$scope:{ctx:U}}}),r=new yt({props:{id:"mismatch",option:"environment variable",$$slots:{default:[al]},$$scope:{ctx:U}}}),w=new yt({props:{id:"mismatch",option:"config.yaml",$$slots:{default:[il]},$$scope:{ctx:U}}}),{c(){h(i.$$.fragment),$=n(),h(r.$$.fragment),d=n(),h(w.$$.fragment)},l(o){f(i.$$.fragment,o),$=a(o),f(r.$$.fragment,o),d=a(o),f(w.$$.fragment,o)},m(o,T){y(i,o,T),s(o,$,T),y(r,o,T),s(o,d,T),y(w,o,T),c=!0},p(o,T){const j={};T&2&&(j.$$scope={dirty:T,ctx:o}),i.$set(j);const we={};T&2&&(we.$$scope={dirty:T,ctx:o}),r.$set(we);const I={};T&2&&(I.$$scope={dirty:T,ctx:o}),w.$set(I)},i(o){c||(M(i.$$.fragment,o),M(r.$$.fragment,o),M(w.$$.fragment,o),c=!0)},o(o){g(i.$$.fragment,o),g(r.$$.fragment,o),g(w.$$.fragment,o),c=!1},d(o){o&&(l($),l(d)),b(i,o),b(r,o),b(w,o)}}}function rl(U){let i,$='The inner function <strong>must</strong> take batch size as the first parameter, but we do not pass one to it when called. The wrapper will handle this for you. Any object (models, optimizers) that consumes device memory and is passed to the <a href="/docs/accelerate/main/en/package_reference/accelerator#accelerate.Accelerator">Accelerator</a> also <strong>must</strong> be declared inside the inner function.';return{c(){i=p("p"),i.innerHTML=$},l(r){i=u(r,"P",{"data-svelte-h":!0}),m(i)!=="svelte-1wj4aqf"&&(i.innerHTML=$)},m(r,d){s(r,i,d)},p:ft,d(r){r&&l(i)}}}function cl(U){let i,$,r,d,w,c,o,T,j,we='This guide provides solutions to some issues you might encounter when using Accelerate. Not all errors are covered because Accelerate is an active library that is continuously evolving and there are many different use cases and distributed training setups. If the solutions described here don’t help with your specific error, please take a look at the <a href="#ask-for-help">Ask for help</a> section to learn where and how to get help.',I,G,Te,k,Mt="Logging can help you identify where an error is coming from. In a distributed setup with multiple processes, logging can be a challenge, but Accelerate provides the <code>logging()</code> utility to ensure logs are synchronized.",Ue,Z,gt='To troubleshoot an issue, use <code>logging()</code> instead of the standard Python <a href="https://docs.python.org/3/library/logging.html#module-logging" rel="nofollow"><code>logging</code></a> module. Set the verbosity level (<code>INFO</code>, <code>DEBUG</code>, <code>WARNING</code>, <code>ERROR</code>, <code>CRITICAL</code>) with the <code>log_level</code> parameter, and then you can either:',Je,x,bt="<li>Export the <code>log_level</code> as the <code>ACCELERATE_LOG_LEVEL</code> environment variable.</li> <li>Pass the <code>log_level</code> directly to <code>get_logger</code>.</li>",je,A,wt="For example, to set <code>log_level=&quot;INFO&quot;</code>:",ve,W,_e,V,$t=`By default, the log is called on main processes only. To call it on all processes, pass <code>main_process_only=False</code>.
If a log should be called on all processes and in order, also pass <code>in_order=True</code>.`,Ce,B,Ie,F,Ge,H,Tt="There can be many reasons why your code is hanging. Let’s take a look at how to solve some of the most common issues that can cause your code to hang.",ke,X,Ze,Y,Ut="Mismatched tensor shapes is a common issue that can cause your code to hang for a significant amount of time on a distributed setup.",xe,z,Jt='When running scripts in a distributed setup, functions such as <a href="/docs/accelerate/main/en/package_reference/accelerator#accelerate.Accelerator.gather">Accelerator.gather()</a> and <a href="/docs/accelerate/main/en/package_reference/accelerator#accelerate.Accelerator.reduce">Accelerator.reduce()</a> are necessary to grab tensors across devices to collectively perform operations on them. These (and other) functions rely on <code>torch.distributed</code> to perform a <code>gather</code> operation, which requires tensors to have the <strong>exact same shape</strong> across all processes. When the tensor shapes don’t match, your code hangs and you’ll eventually hit a timeout exception.',Ae,E,jt="You can use Accelerate’s operational debug mode to immediately catch this issue. We recommend enabling this mode during the <code>accelerate config</code> setup, but you can also enable it from the CLI, as an environment variable, or by manually editing the <code>config.yaml</code> file.",We,_,Ve,L,vt="Once you enable debug mode, you should get a traceback that points to the tensor shape mismatch issue.",Be,N,Fe,R,He,P,_t="For early stopping in distributed training, if each process has a specific stopping condition (e.g. validation loss), it may not be synchronized across all processes. As a result, a break can happen on process 0 but not on process 1 which will cause your code to hang indefinitely until a timeout occurs.",Xe,Q,Ct=`If you have early stopping conditionals, use the <code>set_trigger</code> and <code>check_trigger</code> methods to make sure all the processes
are ended correctly.`,Ye,S,ze,q,Ee,O,It="On Linux with kernel version < 5.5, hanging processes have been reported. To avoid this problem, upgrade your system to a later kernel version.",Le,D,Ne,K,Gt=`If your distributed CPU training job using MPI is hanging, ensure that you have
<a href="https://www.open-mpi.org/faq/?category=rsh#ssh-keys" rel="nofollow">passwordless SSH</a> setup (using keys) between the nodes. This means
that for all nodes in your hostfile, you should to be able to SSH from one node to another without being prompted for a password.`,Re,ee,kt=`Next, try to run the <code>mpirun</code> command as a sanity check. For example, the command below should print out the
hostnames for each of the nodes.`,Pe,te,Qe,le,Se,se,Zt="One of the most frustrating errors when it comes to running training scripts is hitting “Out-of-Memory” on devices like CUDA, XPU or CPU. The entire script needs to be restarted and any progress is lost.",qe,ne,xt=`To address this problem, Accelerate provides the <a href="/docs/accelerate/main/en/package_reference/utilities#accelerate.find_executable_batch_size">find_executable_batch_size()</a> utility that is heavily based on <a href="https://github.com/BlackHC/toma" rel="nofollow">toma</a>.
This utility retries code that fails due to OOM (out-of-memory) conditions and automatically lowers batch sizes. For each OOM condition, the algorithm decreases the batch size by half and retries the code until it succeeds.`,Oe,ae,At='To use <a href="/docs/accelerate/main/en/package_reference/utilities#accelerate.find_executable_batch_size">find_executable_batch_size()</a>, restructure your training function to include an inner function with <code>find_executable_batch_size</code> and build your dataloaders inside it. At a minimum, this only takes 4 new lines of code.',De,C,Ke,ie,et,oe,tt,re,Wt="If you changed the device setup and observe different model performance, it is likely you didn’t update your script when moving from one setup to another. Even if you’re using the same script with the same batch size, the results will still be different on a TPU, multi-GPU, and single GPU.",lt,ce,Vt="For example, if you were training on a single GPU with a batch size of 16 and you move to a dual GPU setup, you need to change the batch size to 8 to have the same effective batch size. This is because when training with Accelerate, the batch size passed to the dataloader is the <strong>batch size per GPU</strong>.",st,pe,Bt="To make sure you can reproduce the results between the setups, make sure to use the same seed, adjust the batch size accordingly, and consider scaling the learning rate.",nt,ue,Ft='For more details and a quick reference for batch sizes, check out the <a href="../concept_guides/performance">Comparing performance between different device setups</a> guide.',at,me,it,de,Ht="If your multi-GPU setup consists of different GPUs, you may encounter some performance issues:",ot,he,Xt="<li>There may be an imbalance in GPU memory between the GPUs. In this case, the GPU with the smaller memory will limit the batch size or the size of the model that can be loaded onto the GPUs.</li> <li>If you are using GPUs with different performance profiles, the performance will be driven by the slowest GPU you are using because the other GPUs will have to wait for it to complete its workload.</li>",rt,fe,Yt="Vastly different GPUs within the same setup can lead to performance bottlenecks.",ct,ye,pt,Me,zt="If none of the solutions and advice here helped resolve your issue, you can always reach out to the community and Accelerate team for help.",ut,ge,Et='<li><p>Ask for help on the Hugging Face forums by posting your question in the <a href="https://discuss.huggingface.co/c/accelerate/18" rel="nofollow">Accelerate category</a>. Make sure to write a descriptive post with relevant context about your setup and reproducible code to maximize the likelihood that your problem is solved!</p></li> <li><p>Post a question on <a href="http://hf.co/join/discord" rel="nofollow">Discord</a>, and let the team and the community help you.</p></li> <li><p>Create an Issue on the Accelerate <a href="https://github.com/huggingface/accelerate/issues" rel="nofollow">GitHub repository</a> if you think you’ve found a bug related to the library. Include context regarding the bug and details about your distributed setup to help us better figure out what’s wrong and how we can fix it.</p></li>',mt,be,dt,$e,ht;return w=new tl({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),o=new J({props:{title:"Troubleshoot",local:"troubleshoot",headingTag:"h1"}}),G=new J({props:{title:"Logging",local:"logging",headingTag:"h2"}}),W=new v({props:{code:"ZnJvbSUyMGFjY2VsZXJhdGUubG9nZ2luZyUyMGltcG9ydCUyMGdldF9sb2dnZXIlMEElMEFsb2dnZXIlMjAlM0QlMjBnZXRfbG9nZ2VyKF9fbmFtZV9fJTJDJTIwbG9nX2xldmVsJTNEJTIyREVCVUclMjIp",highlighted:`<span class="hljs-keyword">from</span> accelerate.logging <span class="hljs-keyword">import</span> get_logger

logger = get_logger(__name__, log_level=<span class="hljs-string">&quot;DEBUG&quot;</span>)`,wrap:!1}}),B=new v({props:{code:"ZnJvbSUyMGFjY2VsZXJhdGUubG9nZ2luZyUyMGltcG9ydCUyMGdldF9sb2dnZXIlMEElMEFsb2dnZXIlMjAlM0QlMjBnZXRfbG9nZ2VyKF9fbmFtZV9fJTJDJTIwbG9nX2xldmVsJTNEJTIyREVCVUclMjIpJTBBJTIzJTIwbG9nJTIwYWxsJTIwcHJvY2Vzc2VzJTBBbG9nZ2VyLmRlYnVnKCUyMnRoaW5nX3RvX2xvZyUyMiUyQyUyMG1haW5fcHJvY2Vzc19vbmx5JTNERmFsc2UpJTBBJTIzJTIwbG9nJTIwYWxsJTIwcHJvY2Vzc2VzJTIwaW4lMjBvcmRlciUwQWxvZ2dlci5kZWJ1ZyglMjJ0aGluZ190b19sb2clMjIlMkMlMjBtYWluX3Byb2Nlc3Nfb25seSUzREZhbHNlJTJDJTIwaW5fb3JkZXIlM0RUcnVlKQ==",highlighted:`<span class="hljs-keyword">from</span> accelerate.logging <span class="hljs-keyword">import</span> get_logger

logger = get_logger(__name__, log_level=<span class="hljs-string">&quot;DEBUG&quot;</span>)
<span class="hljs-comment"># log all processes</span>
logger.debug(<span class="hljs-string">&quot;thing_to_log&quot;</span>, main_process_only=<span class="hljs-literal">False</span>)
<span class="hljs-comment"># log all processes in order</span>
logger.debug(<span class="hljs-string">&quot;thing_to_log&quot;</span>, main_process_only=<span class="hljs-literal">False</span>, in_order=<span class="hljs-literal">True</span>)`,wrap:!1}}),F=new J({props:{title:"Hanging code and timeout errors",local:"hanging-code-and-timeout-errors",headingTag:"h2"}}),X=new J({props:{title:"Mismatched tensor shapes",local:"mismatched-tensor-shapes",headingTag:"h3"}}),_=new sl({props:{id:"mismatch",options:["CLI","environment variable","config.yaml"],$$slots:{default:[ol]},$$scope:{ctx:U}}}),N=new v({props:{code:"VHJhY2ViYWNrJTIwKG1vc3QlMjByZWNlbnQlMjBjYWxsJTIwbGFzdCklM0ElMEElMjAlMjBGaWxlJTIwJTIyJTJGaG9tZSUyRnphY2hfbXVlbGxlcl9odWdnaW5nZmFjZV9jbyUyRnRlc3QucHklMjIlMkMlMjBsaW5lJTIwMTglMkMlMjBpbiUyMCUzQ21vZHVsZSUzRSUwQSUyMCUyMCUyMCUyMG1haW4oKSUwQSUyMCUyMEZpbGUlMjAlMjIlMkZob21lJTJGemFjaF9tdWVsbGVyX2h1Z2dpbmdmYWNlX2NvJTJGdGVzdC5weSUyMiUyQyUyMGxpbmUlMjAxNSUyQyUyMGluJTIwbWFpbiUwQSUyMCUyMCUyMCUyMGJyb2FkY2FzdF90ZW5zb3IlMjAlM0QlMjBicm9hZGNhc3QodGVuc29yKSUwQSUyMCUyMEZpbGUlMjAlMjIlMkZob21lJTJGemFjaF9tdWVsbGVyX2h1Z2dpbmdmYWNlX2NvJTJGYWNjZWxlcmF0ZSUyRnNyYyUyRmFjY2VsZXJhdGUlMkZ1dGlscyUyRm9wZXJhdGlvbnMucHklMjIlMkMlMjBsaW5lJTIwMzAzJTJDJTIwaW4lMjB3cmFwcGVyJTBBYWNjZWxlcmF0ZS51dGlscy5vcGVyYXRpb25zLkRpc3RyaWJ1dGVkT3BlcmF0aW9uRXhjZXB0aW9uJTNBJTBBJTBBQ2Fubm90JTIwYXBwbHklMjBkZXNpcmVkJTIwb3BlcmF0aW9uJTIwZHVlJTIwdG8lMjBzaGFwZSUyMG1pc21hdGNoZXMuJTIwQWxsJTIwc2hhcGVzJTIwYWNyb3NzJTIwZGV2aWNlcyUyMG11c3QlMjBiZSUyMHZhbGlkLiUwQSUwQU9wZXJhdGlvbiUzQSUyMCU2MGFjY2VsZXJhdGUudXRpbHMub3BlcmF0aW9ucy5icm9hZGNhc3QlNjAlMEFJbnB1dCUyMHNoYXBlcyUzQSUwQSUyMCUyMC0lMjBQcm9jZXNzJTIwMCUzQSUyMCU1QjElMkMlMjA1JTVEJTBBJTIwJTIwLSUyMFByb2Nlc3MlMjAxJTNBJTIwJTVCMSUyQyUyMDIlMkMlMjA1JTVE",highlighted:`Traceback (most recent call last):
  File <span class="hljs-string">&quot;/home/zach_mueller_huggingface_co/test.py&quot;</span>, line <span class="hljs-number">18</span>, <span class="hljs-keyword">in</span> &lt;module&gt;
    main()
  File <span class="hljs-string">&quot;/home/zach_mueller_huggingface_co/test.py&quot;</span>, line <span class="hljs-number">15</span>, <span class="hljs-keyword">in</span> main
    broadcast_tensor = broadcast(tensor)
  File <span class="hljs-string">&quot;/home/zach_mueller_huggingface_co/accelerate/src/accelerate/utils/operations.py&quot;</span>, line <span class="hljs-number">303</span>, <span class="hljs-keyword">in</span> wrapper
accelerate.utils.operations.DistributedOperationException:

Cannot apply desired operation due to shape mismatches. All shapes across devices must be valid.

Operation: \`accelerate.utils.operations.broadcast\`
Input shapes:
  - Process <span class="hljs-number">0</span>: [<span class="hljs-number">1</span>, <span class="hljs-number">5</span>]
  - Process <span class="hljs-number">1</span>: [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">5</span>]`,wrap:!1}}),R=new J({props:{title:"Early stopping",local:"early-stopping",headingTag:"h3"}}),S=new v({props:{code:"JTIzJTIwQXNzdW1lJTIwJTYwc2hvdWxkX2RvX2JyZWFrcG9pbnQlNjAlMjBpcyUyMGElMjBjdXN0b20lMjBkZWZpbmVkJTIwZnVuY3Rpb24lMjB0aGF0JTIwcmV0dXJucyUyMGElMjBjb25kaXRpb25hbCUyQyUyMCUwQSUyMyUyMGFuZCUyMHRoYXQlMjBjb25kaXRpb25hbCUyMG1pZ2h0JTIwYmUlMjB0cnVlJTIwb25seSUyMG9uJTIwcHJvY2VzcyUyMDElMEFpZiUyMHNob3VsZF9kb19icmVha3BvaW50KGxvc3MpJTNBJTBBJTIwJTIwJTIwJTIwYWNjZWxlcmF0b3Iuc2V0X3RyaWdnZXIoKSUwQSUwQSUyMyUyMExhdGVyJTIwaW4lMjB0aGUlMjB0cmFpbmluZyUyMHNjcmlwdCUyMHdoZW4lMjB3ZSUyMG5lZWQlMjB0byUyMGNoZWNrJTIwZm9yJTIwdGhlJTIwYnJlYWtwb2ludCUwQWlmJTIwYWNjZWxlcmF0b3IuY2hlY2tfdHJpZ2dlcigpJTNBJTBBJTIwJTIwJTIwJTIwYnJlYWs=",highlighted:`<span class="hljs-comment"># Assume \`should_do_breakpoint\` is a custom defined function that returns a conditional, </span>
<span class="hljs-comment"># and that conditional might be true only on process 1</span>
<span class="hljs-keyword">if</span> should_do_breakpoint(loss):
    accelerator.set_trigger()

<span class="hljs-comment"># Later in the training script when we need to check for the breakpoint</span>
<span class="hljs-keyword">if</span> accelerator.check_trigger():
    <span class="hljs-keyword">break</span>`,wrap:!1}}),q=new J({props:{title:"Low kernel versions on Linux",local:"low-kernel-versions-on-linux",headingTag:"h3"}}),D=new J({props:{title:"MPI",local:"mpi",headingTag:"h3"}}),te=new v({props:{code:"bXBpcnVuJTIwLWYlMjBob3N0ZmlsZSUyMC1uJTIwJTdCbnVtYmVyJTIwb2YlMjBub2RlcyU3RCUyMC1wcG4lMjAxJTIwaG9zdG5hbWU=",highlighted:"mpirun -f hostfile -n {number of nodes} -ppn 1 hostname",wrap:!1}}),le=new J({props:{title:"Out-of-Memory",local:"out-of-memory",headingTag:"h2"}}),C=new el({props:{warning:!0,$$slots:{default:[rl]},$$scope:{ctx:U}}}),ie=new v({props:{code:"ZGVmJTIwdHJhaW5pbmdfZnVuY3Rpb24oYXJncyklM0ElMEElMjAlMjAlMjAlMjBhY2NlbGVyYXRvciUyMCUzRCUyMEFjY2VsZXJhdG9yKCklMEElMEElMkIlMjAlMjAlMjAlNDBmaW5kX2V4ZWN1dGFibGVfYmF0Y2hfc2l6ZShzdGFydGluZ19iYXRjaF9zaXplJTNEYXJncy5iYXRjaF9zaXplKSUwQSUyQiUyMCUyMCUyMGRlZiUyMGlubmVyX3RyYWluaW5nX2xvb3AoYmF0Y2hfc2l6ZSklM0ElMEElMkIlMjAlMjAlMjAlMjAlMjAlMjAlMjBub25sb2NhbCUyMGFjY2VsZXJhdG9yJTIwJTIzJTIwRW5zdXJlJTIwdGhleSUyMGNhbiUyMGJlJTIwdXNlZCUyMGluJTIwb3VyJTIwY29udGV4dCUwQSUyQiUyMCUyMCUyMCUyMCUyMCUyMCUyMGFjY2VsZXJhdG9yLmZyZWVfbWVtb3J5KCklMjAlMjMlMjBGcmVlJTIwYWxsJTIwbGluZ2VyaW5nJTIwcmVmZXJlbmNlcyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMG1vZGVsJTIwJTNEJTIwZ2V0X21vZGVsKCklMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBtb2RlbC50byhhY2NlbGVyYXRvci5kZXZpY2UpJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwb3B0aW1pemVyJTIwJTNEJTIwZ2V0X29wdGltaXplcigpJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwdHJhaW5fZGF0YWxvYWRlciUyQyUyMGV2YWxfZGF0YWxvYWRlciUyMCUzRCUyMGdldF9kYXRhbG9hZGVycyhhY2NlbGVyYXRvciUyQyUyMGJhdGNoX3NpemUpJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwbHJfc2NoZWR1bGVyJTIwJTNEJTIwZ2V0X3NjaGVkdWxlciglMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBvcHRpbWl6ZXIlMkMlMjAlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBudW1fdHJhaW5pbmdfc3RlcHMlM0RsZW4odHJhaW5fZGF0YWxvYWRlcikqbnVtX2Vwb2NocyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCklMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBtb2RlbCUyQyUyMG9wdGltaXplciUyQyUyMHRyYWluX2RhdGFsb2FkZXIlMkMlMjBldmFsX2RhdGFsb2FkZXIlMkMlMjBscl9zY2hlZHVsZXIlMjAlM0QlMjBhY2NlbGVyYXRvci5wcmVwYXJlKCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMG1vZGVsJTJDJTIwb3B0aW1pemVyJTJDJTIwdHJhaW5fZGF0YWxvYWRlciUyQyUyMGV2YWxfZGF0YWxvYWRlciUyQyUyMGxyX3NjaGVkdWxlciUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCklMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjB0cmFpbihtb2RlbCUyQyUyMG9wdGltaXplciUyQyUyMHRyYWluX2RhdGFsb2FkZXIlMkMlMjBscl9zY2hlZHVsZXIpJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwdmFsaWRhdGUobW9kZWwlMkMlMjBldmFsX2RhdGFsb2FkZXIpJTBBJTJCJTIwJTIwJTIwaW5uZXJfdHJhaW5pbmdfbG9vcCgp",highlighted:`def training_function(args):
    accelerator = Accelerator()

<span class="hljs-addition">+   @find_executable_batch_size(starting_batch_size=args.batch_size)</span>
<span class="hljs-addition">+   def inner_training_loop(batch_size):</span>
<span class="hljs-addition">+       nonlocal accelerator # Ensure they can be used in our context</span>
<span class="hljs-addition">+       accelerator.free_memory() # Free all lingering references</span>
        model = get_model()
        model.to(accelerator.device)
        optimizer = get_optimizer()
        train_dataloader, eval_dataloader = get_dataloaders(accelerator, batch_size)
        lr_scheduler = get_scheduler(
            optimizer, 
            num_training_steps=len(train_dataloader)*num_epochs
        )
        model, optimizer, train_dataloader, eval_dataloader, lr_scheduler = accelerator.prepare(
            model, optimizer, train_dataloader, eval_dataloader, lr_scheduler
        )
        train(model, optimizer, train_dataloader, lr_scheduler)
        validate(model, eval_dataloader)
<span class="hljs-addition">+   inner_training_loop()</span>`,wrap:!1}}),oe=new J({props:{title:"Non-reproducible results between device setups",local:"non-reproducible-results-between-device-setups",headingTag:"h2"}}),me=new J({props:{title:"Performance issues on different GPUs",local:"performance-issues-on-different-gpus",headingTag:"h2"}}),ye=new J({props:{title:"Ask for help",local:"ask-for-help",headingTag:"h2"}}),be=new ll({props:{source:"https://github.com/huggingface/accelerate/blob/main/docs/source/basic_tutorials/troubleshooting.md"}}),{c(){i=p("meta"),$=n(),r=p("p"),d=n(),h(w.$$.fragment),c=n(),h(o.$$.fragment),T=n(),j=p("p"),j.innerHTML=we,I=n(),h(G.$$.fragment),Te=n(),k=p("p"),k.innerHTML=Mt,Ue=n(),Z=p("p"),Z.innerHTML=gt,Je=n(),x=p("ol"),x.innerHTML=bt,je=n(),A=p("p"),A.innerHTML=wt,ve=n(),h(W.$$.fragment),_e=n(),V=p("p"),V.innerHTML=$t,Ce=n(),h(B.$$.fragment),Ie=n(),h(F.$$.fragment),Ge=n(),H=p("p"),H.textContent=Tt,ke=n(),h(X.$$.fragment),Ze=n(),Y=p("p"),Y.textContent=Ut,xe=n(),z=p("p"),z.innerHTML=Jt,Ae=n(),E=p("p"),E.innerHTML=jt,We=n(),h(_.$$.fragment),Ve=n(),L=p("p"),L.textContent=vt,Be=n(),h(N.$$.fragment),Fe=n(),h(R.$$.fragment),He=n(),P=p("p"),P.textContent=_t,Xe=n(),Q=p("p"),Q.innerHTML=Ct,Ye=n(),h(S.$$.fragment),ze=n(),h(q.$$.fragment),Ee=n(),O=p("p"),O.textContent=It,Le=n(),h(D.$$.fragment),Ne=n(),K=p("p"),K.innerHTML=Gt,Re=n(),ee=p("p"),ee.innerHTML=kt,Pe=n(),h(te.$$.fragment),Qe=n(),h(le.$$.fragment),Se=n(),se=p("p"),se.textContent=Zt,qe=n(),ne=p("p"),ne.innerHTML=xt,Oe=n(),ae=p("p"),ae.innerHTML=At,De=n(),h(C.$$.fragment),Ke=n(),h(ie.$$.fragment),et=n(),h(oe.$$.fragment),tt=n(),re=p("p"),re.textContent=Wt,lt=n(),ce=p("p"),ce.innerHTML=Vt,st=n(),pe=p("p"),pe.textContent=Bt,nt=n(),ue=p("p"),ue.innerHTML=Ft,at=n(),h(me.$$.fragment),it=n(),de=p("p"),de.textContent=Ht,ot=n(),he=p("ul"),he.innerHTML=Xt,rt=n(),fe=p("p"),fe.textContent=Yt,ct=n(),h(ye.$$.fragment),pt=n(),Me=p("p"),Me.textContent=zt,ut=n(),ge=p("ul"),ge.innerHTML=Et,mt=n(),h(be.$$.fragment),dt=n(),$e=p("p"),this.h()},l(e){const t=Dt("svelte-u9bgzb",document.head);i=u(t,"META",{name:!0,content:!0}),t.forEach(l),$=a(e),r=u(e,"P",{}),Rt(r).forEach(l),d=a(e),f(w.$$.fragment,e),c=a(e),f(o.$$.fragment,e),T=a(e),j=u(e,"P",{"data-svelte-h":!0}),m(j)!=="svelte-13d7d11"&&(j.innerHTML=we),I=a(e),f(G.$$.fragment,e),Te=a(e),k=u(e,"P",{"data-svelte-h":!0}),m(k)!=="svelte-frnlaf"&&(k.innerHTML=Mt),Ue=a(e),Z=u(e,"P",{"data-svelte-h":!0}),m(Z)!=="svelte-1dztp11"&&(Z.innerHTML=gt),Je=a(e),x=u(e,"OL",{"data-svelte-h":!0}),m(x)!=="svelte-rs010c"&&(x.innerHTML=bt),je=a(e),A=u(e,"P",{"data-svelte-h":!0}),m(A)!=="svelte-11t72px"&&(A.innerHTML=wt),ve=a(e),f(W.$$.fragment,e),_e=a(e),V=u(e,"P",{"data-svelte-h":!0}),m(V)!=="svelte-1ir4wom"&&(V.innerHTML=$t),Ce=a(e),f(B.$$.fragment,e),Ie=a(e),f(F.$$.fragment,e),Ge=a(e),H=u(e,"P",{"data-svelte-h":!0}),m(H)!=="svelte-1xeblm7"&&(H.textContent=Tt),ke=a(e),f(X.$$.fragment,e),Ze=a(e),Y=u(e,"P",{"data-svelte-h":!0}),m(Y)!=="svelte-hwr0n3"&&(Y.textContent=Ut),xe=a(e),z=u(e,"P",{"data-svelte-h":!0}),m(z)!=="svelte-byepzk"&&(z.innerHTML=Jt),Ae=a(e),E=u(e,"P",{"data-svelte-h":!0}),m(E)!=="svelte-3ggiaa"&&(E.innerHTML=jt),We=a(e),f(_.$$.fragment,e),Ve=a(e),L=u(e,"P",{"data-svelte-h":!0}),m(L)!=="svelte-73ievd"&&(L.textContent=vt),Be=a(e),f(N.$$.fragment,e),Fe=a(e),f(R.$$.fragment,e),He=a(e),P=u(e,"P",{"data-svelte-h":!0}),m(P)!=="svelte-zyub5i"&&(P.textContent=_t),Xe=a(e),Q=u(e,"P",{"data-svelte-h":!0}),m(Q)!=="svelte-6xakrz"&&(Q.innerHTML=Ct),Ye=a(e),f(S.$$.fragment,e),ze=a(e),f(q.$$.fragment,e),Ee=a(e),O=u(e,"P",{"data-svelte-h":!0}),m(O)!=="svelte-1fprc5q"&&(O.textContent=It),Le=a(e),f(D.$$.fragment,e),Ne=a(e),K=u(e,"P",{"data-svelte-h":!0}),m(K)!=="svelte-1pzvmvb"&&(K.innerHTML=Gt),Re=a(e),ee=u(e,"P",{"data-svelte-h":!0}),m(ee)!=="svelte-gpp5fn"&&(ee.innerHTML=kt),Pe=a(e),f(te.$$.fragment,e),Qe=a(e),f(le.$$.fragment,e),Se=a(e),se=u(e,"P",{"data-svelte-h":!0}),m(se)!=="svelte-1nv6p1"&&(se.textContent=Zt),qe=a(e),ne=u(e,"P",{"data-svelte-h":!0}),m(ne)!=="svelte-1n72pe5"&&(ne.innerHTML=xt),Oe=a(e),ae=u(e,"P",{"data-svelte-h":!0}),m(ae)!=="svelte-11k5gop"&&(ae.innerHTML=At),De=a(e),f(C.$$.fragment,e),Ke=a(e),f(ie.$$.fragment,e),et=a(e),f(oe.$$.fragment,e),tt=a(e),re=u(e,"P",{"data-svelte-h":!0}),m(re)!=="svelte-1voh2ow"&&(re.textContent=Wt),lt=a(e),ce=u(e,"P",{"data-svelte-h":!0}),m(ce)!=="svelte-1ud0alx"&&(ce.innerHTML=Vt),st=a(e),pe=u(e,"P",{"data-svelte-h":!0}),m(pe)!=="svelte-o0c4mt"&&(pe.textContent=Bt),nt=a(e),ue=u(e,"P",{"data-svelte-h":!0}),m(ue)!=="svelte-uhwue4"&&(ue.innerHTML=Ft),at=a(e),f(me.$$.fragment,e),it=a(e),de=u(e,"P",{"data-svelte-h":!0}),m(de)!=="svelte-yw9ss7"&&(de.textContent=Ht),ot=a(e),he=u(e,"UL",{"data-svelte-h":!0}),m(he)!=="svelte-1ci82g2"&&(he.innerHTML=Xt),rt=a(e),fe=u(e,"P",{"data-svelte-h":!0}),m(fe)!=="svelte-bc1071"&&(fe.textContent=Yt),ct=a(e),f(ye.$$.fragment,e),pt=a(e),Me=u(e,"P",{"data-svelte-h":!0}),m(Me)!=="svelte-14i3nyp"&&(Me.textContent=zt),ut=a(e),ge=u(e,"UL",{"data-svelte-h":!0}),m(ge)!=="svelte-1fb2pfu"&&(ge.innerHTML=Et),mt=a(e),f(be.$$.fragment,e),dt=a(e),$e=u(e,"P",{}),Rt($e).forEach(l),this.h()},h(){Pt(i,"name","hf:doc:metadata"),Pt(i,"content",pl)},m(e,t){Kt(document.head,i),s(e,$,t),s(e,r,t),s(e,d,t),y(w,e,t),s(e,c,t),y(o,e,t),s(e,T,t),s(e,j,t),s(e,I,t),y(G,e,t),s(e,Te,t),s(e,k,t),s(e,Ue,t),s(e,Z,t),s(e,Je,t),s(e,x,t),s(e,je,t),s(e,A,t),s(e,ve,t),y(W,e,t),s(e,_e,t),s(e,V,t),s(e,Ce,t),y(B,e,t),s(e,Ie,t),y(F,e,t),s(e,Ge,t),s(e,H,t),s(e,ke,t),y(X,e,t),s(e,Ze,t),s(e,Y,t),s(e,xe,t),s(e,z,t),s(e,Ae,t),s(e,E,t),s(e,We,t),y(_,e,t),s(e,Ve,t),s(e,L,t),s(e,Be,t),y(N,e,t),s(e,Fe,t),y(R,e,t),s(e,He,t),s(e,P,t),s(e,Xe,t),s(e,Q,t),s(e,Ye,t),y(S,e,t),s(e,ze,t),y(q,e,t),s(e,Ee,t),s(e,O,t),s(e,Le,t),y(D,e,t),s(e,Ne,t),s(e,K,t),s(e,Re,t),s(e,ee,t),s(e,Pe,t),y(te,e,t),s(e,Qe,t),y(le,e,t),s(e,Se,t),s(e,se,t),s(e,qe,t),s(e,ne,t),s(e,Oe,t),s(e,ae,t),s(e,De,t),y(C,e,t),s(e,Ke,t),y(ie,e,t),s(e,et,t),y(oe,e,t),s(e,tt,t),s(e,re,t),s(e,lt,t),s(e,ce,t),s(e,st,t),s(e,pe,t),s(e,nt,t),s(e,ue,t),s(e,at,t),y(me,e,t),s(e,it,t),s(e,de,t),s(e,ot,t),s(e,he,t),s(e,rt,t),s(e,fe,t),s(e,ct,t),y(ye,e,t),s(e,pt,t),s(e,Me,t),s(e,ut,t),s(e,ge,t),s(e,mt,t),y(be,e,t),s(e,dt,t),s(e,$e,t),ht=!0},p(e,[t]){const Lt={};t&2&&(Lt.$$scope={dirty:t,ctx:e}),_.$set(Lt);const Nt={};t&2&&(Nt.$$scope={dirty:t,ctx:e}),C.$set(Nt)},i(e){ht||(M(w.$$.fragment,e),M(o.$$.fragment,e),M(G.$$.fragment,e),M(W.$$.fragment,e),M(B.$$.fragment,e),M(F.$$.fragment,e),M(X.$$.fragment,e),M(_.$$.fragment,e),M(N.$$.fragment,e),M(R.$$.fragment,e),M(S.$$.fragment,e),M(q.$$.fragment,e),M(D.$$.fragment,e),M(te.$$.fragment,e),M(le.$$.fragment,e),M(C.$$.fragment,e),M(ie.$$.fragment,e),M(oe.$$.fragment,e),M(me.$$.fragment,e),M(ye.$$.fragment,e),M(be.$$.fragment,e),ht=!0)},o(e){g(w.$$.fragment,e),g(o.$$.fragment,e),g(G.$$.fragment,e),g(W.$$.fragment,e),g(B.$$.fragment,e),g(F.$$.fragment,e),g(X.$$.fragment,e),g(_.$$.fragment,e),g(N.$$.fragment,e),g(R.$$.fragment,e),g(S.$$.fragment,e),g(q.$$.fragment,e),g(D.$$.fragment,e),g(te.$$.fragment,e),g(le.$$.fragment,e),g(C.$$.fragment,e),g(ie.$$.fragment,e),g(oe.$$.fragment,e),g(me.$$.fragment,e),g(ye.$$.fragment,e),g(be.$$.fragment,e),ht=!1},d(e){e&&(l($),l(r),l(d),l(c),l(T),l(j),l(I),l(Te),l(k),l(Ue),l(Z),l(Je),l(x),l(je),l(A),l(ve),l(_e),l(V),l(Ce),l(Ie),l(Ge),l(H),l(ke),l(Ze),l(Y),l(xe),l(z),l(Ae),l(E),l(We),l(Ve),l(L),l(Be),l(Fe),l(He),l(P),l(Xe),l(Q),l(Ye),l(ze),l(Ee),l(O),l(Le),l(Ne),l(K),l(Re),l(ee),l(Pe),l(Qe),l(Se),l(se),l(qe),l(ne),l(Oe),l(ae),l(De),l(Ke),l(et),l(tt),l(re),l(lt),l(ce),l(st),l(pe),l(nt),l(ue),l(at),l(it),l(de),l(ot),l(he),l(rt),l(fe),l(ct),l(pt),l(Me),l(ut),l(ge),l(mt),l(dt),l($e)),l(i),b(w,e),b(o,e),b(G,e),b(W,e),b(B,e),b(F,e),b(X,e),b(_,e),b(N,e),b(R,e),b(S,e),b(q,e),b(D,e),b(te,e),b(le,e),b(C,e),b(ie,e),b(oe,e),b(me,e),b(ye,e),b(be,e)}}}const pl='{"title":"Troubleshoot","local":"troubleshoot","sections":[{"title":"Logging","local":"logging","sections":[],"depth":2},{"title":"Hanging code and timeout errors","local":"hanging-code-and-timeout-errors","sections":[{"title":"Mismatched tensor shapes","local":"mismatched-tensor-shapes","sections":[],"depth":3},{"title":"Early stopping","local":"early-stopping","sections":[],"depth":3},{"title":"Low kernel versions on Linux","local":"low-kernel-versions-on-linux","sections":[],"depth":3},{"title":"MPI","local":"mpi","sections":[],"depth":3}],"depth":2},{"title":"Out-of-Memory","local":"out-of-memory","sections":[],"depth":2},{"title":"Non-reproducible results between device setups","local":"non-reproducible-results-between-device-setups","sections":[],"depth":2},{"title":"Performance issues on different GPUs","local":"performance-issues-on-different-gpus","sections":[],"depth":2},{"title":"Ask for help","local":"ask-for-help","sections":[],"depth":2}],"depth":1}';function ul(U){return St(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class gl extends qt{constructor(i){super(),Ot(this,i,ul,cl,Qt,{})}}export{gl as component};
