Buckets:

HuggingFaceDocBuilder's picture
download
raw
9.53 kB
import"../chunks/DsnmJJEf.js";import{i as j,h as J,C as q,H as i,D as f,E as G,s as I,a as Y}from"../chunks/ClLAY5C0.js";import{p as B,o as S,s as e,f as v,a as t,b as Z,d as b,c as r,n as x,r as y}from"../chunks/BhevU81Y.js";import{T as k}from"../chunks/L24edx8-.js";import{E as W}from"../chunks/rmzMZPTI.js";const E='{"title":"Launchers","local":"launchers","sections":[{"title":"notebook_launcher","local":"accelerate.notebook_launcher","sections":[],"depth":2},{"title":"debug_launcher","local":"accelerate.debug_launcher","sections":[],"depth":2}],"depth":1}';var Q=r('<meta name="hf:doc:metadata"/>'),$=r(`<p>To use this function absolutely zero calls to a device must be made in the notebook session before calling. If any
have been made, you will need to restart the notebook and make sure no cells use any device capability.</p> <p>Setting <code>ACCELERATE_DEBUG_MODE="1"</code> in your environment will run a test before truly launching to ensure that none
of those calls have been made.</p>`,1),L=r("<p>Example:</p> <!>",1),N=r(`<p>This function is provided for internal testing and debugging, but it’s not intended for real trainings. It will
only use the CPU.</p>`),P=r(`<p></p> <!> <!> <p>Functions for launching training on distributed processes.</p> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Launches a training function, using several processes or multiple nodes if it’s possible in the current environment
(TPU with multiple cores for instance).</p> <!> <!></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Launches a training function using several processes on CPU for debugging purposes.</p> <!></div> <!> <p></p>`,1);function A(T,w){B(w,!1),S(()=>{new URLSearchParams(window.location.search).get("fw")}),j();var l=P();J("1xcqvz",o=>{var a=Q();I(a,"content",E),t(o,a)});var d=e(v(l),2);q(d,{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"});var u=e(d,2);i(u,{title:"Launchers",local:"launchers",headingTag:"h1"});var m=e(u,4);i(m,{title:"notebook_launcher",local:"accelerate.notebook_launcher",headingTag:"h2"});var s=e(m,2),p=b(s);f(p,{name:"accelerate.notebook_launcher",anchor:"accelerate.notebook_launcher",source:"https://github.com/huggingface/accelerate/blob/vr_4060/src/accelerate/launchers.py#L43",parameters:[{name:"function",val:""},{name:"args",val:" = ()"},{name:"num_processes",val:" = None"},{name:"mixed_precision",val:" = 'no'"},{name:"use_port",val:" = '29500'"},{name:"master_addr",val:" = '127.0.0.1'"},{name:"node_rank",val:" = 0"},{name:"num_nodes",val:" = 1"},{name:"rdzv_backend",val:" = 'static'"},{name:"rdzv_endpoint",val:" = ''"},{name:"rdzv_conf",val:" = None"},{name:"rdzv_id",val:" = 'none'"},{name:"max_restarts",val:" = 0"},{name:"monitor_interval",val:" = 0.1"},{name:"log_line_prefix_template",val:" = None"}],parametersDescription:[{anchor:"accelerate.notebook_launcher.function",description:`<strong>function</strong> (<code>Callable</code>) &#x2014;
The training function to execute. If it accepts arguments, the first argument should be the index of the
process run.`,name:"function"},{anchor:"accelerate.notebook_launcher.args",description:`<strong>args</strong> (<code>Tuple</code>) &#x2014;
Tuple of arguments to pass to the function (it will receive <code>*args</code>).`,name:"args"},{anchor:"accelerate.notebook_launcher.num_processes",description:`<strong>num_processes</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The number of processes to use for training. Will default to 8 in Colab/Kaggle if a TPU is available, to
the number of devices available otherwise.`,name:"num_processes"},{anchor:"accelerate.notebook_launcher.mixed_precision",description:`<strong>mixed_precision</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;no&quot;</code>) &#x2014;
If <code>fp16</code> or <code>bf16</code>, will use mixed precision training on multi-device.`,name:"mixed_precision"},{anchor:"accelerate.notebook_launcher.use_port",description:`<strong>use_port</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;29500&quot;</code>) &#x2014;
The port to use to communicate between processes when launching a multi-device training.`,name:"use_port"},{anchor:"accelerate.notebook_launcher.master_addr",description:`<strong>master_addr</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;127.0.0.1&quot;</code>) &#x2014;
The address to use for communication between processes.`,name:"master_addr"},{anchor:"accelerate.notebook_launcher.node_rank",description:`<strong>node_rank</strong> (<code>int</code>, <em>optional</em>, defaults to 0) &#x2014;
The rank of the current node.`,name:"node_rank"},{anchor:"accelerate.notebook_launcher.num_nodes",description:`<strong>num_nodes</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
The number of nodes to use for training.`,name:"num_nodes"},{anchor:"accelerate.notebook_launcher.rdzv_backend",description:`<strong>rdzv_backend</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;static&quot;</code>) &#x2014;
The rendezvous method to use, such as &#x2018;static&#x2019; (the default) or &#x2018;c10d&#x2019;`,name:"rdzv_backend"},{anchor:"accelerate.notebook_launcher.rdzv_endpoint",description:`<strong>rdzv_endpoint</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;&quot;</code>) &#x2014;
The endpoint of the rdzv sync. storage.`,name:"rdzv_endpoint"},{anchor:"accelerate.notebook_launcher.rdzv_conf",description:`<strong>rdzv_conf</strong> (<code>Dict</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
Additional rendezvous configuration.`,name:"rdzv_conf"},{anchor:"accelerate.notebook_launcher.rdzv_id",description:`<strong>rdzv_id</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;none&quot;</code>) &#x2014;
The unique run id of the job.`,name:"rdzv_id"},{anchor:"accelerate.notebook_launcher.max_restarts",description:`<strong>max_restarts</strong> (<code>int</code>, <em>optional</em>, defaults to 0) &#x2014;
The maximum amount of restarts that elastic agent will conduct on workers before failure.`,name:"max_restarts"},{anchor:"accelerate.notebook_launcher.monitor_interval",description:`<strong>monitor_interval</strong> (<code>float</code>, <em>optional</em>, defaults to 0.1) &#x2014;
The interval in seconds that is used by the elastic_agent as a period of monitoring workers.`,name:"monitor_interval"},{anchor:"accelerate.notebook_launcher.log_line_prefix_template",description:`<strong>log_line_prefix_template</strong> (<code>str</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
The prefix template for elastic launch logging. Available from PyTorch 2.2.0.`,name:"log_line_prefix_template"}]});var h=e(p,4);k(h,{warning:!0,children:(o,a)=>{var n=$();x(2),t(o,n)},$$slots:{default:!0}});var U=e(h,2);W(U,{anchor:"accelerate.notebook_launcher.example",children:(o,a)=>{var n=L(),C=e(v(n),2);Y(C,{code:"JTIzJTIwQXNzdW1lJTIwdGhpcyUyMGlzJTIwZGVmaW5lZCUyMGluJTIwYSUyMEp1cHl0ZXIlMjBOb3RlYm9vayUyMG9uJTIwYW4lMjBpbnN0YW5jZSUyMHdpdGglMjB0d28lMjBkZXZpY2VzJTBBZnJvbSUyMGFjY2VsZXJhdGUlMjBpbXBvcnQlMjBub3RlYm9va19sYXVuY2hlciUwQSUwQSUwQWRlZiUyMHRyYWluKCphcmdzKSUzQSUwQSUyMCUyMCUyMCUyMCUyMyUyMFlvdXIlMjB0cmFpbmluZyUyMGZ1bmN0aW9uJTIwaGVyZSUwQSUyMCUyMCUyMCUyMC4uLiUwQSUwQSUwQW5vdGVib29rX2xhdW5jaGVyKHRyYWluJTJDJTIwYXJncyUzRChhcmcxJTJDJTIwYXJnMiklMkMlMjBudW1fcHJvY2Vzc2VzJTNEMiUyQyUyMG1peGVkX3ByZWNpc2lvbiUzRCUyMmZwMTYlMjIp",highlighted:`<span class="hljs-comment"># Assume this is defined in a Jupyter Notebook on an instance with two devices</span>
<span class="hljs-keyword">from</span> accelerate <span class="hljs-keyword">import</span> notebook_launcher
<span class="hljs-keyword">def</span> <span class="hljs-title function_">train</span>(<span class="hljs-params">*args</span>):
<span class="hljs-comment"># Your training function here</span>
...
notebook_launcher(train, args=(arg1, arg2), num_processes=<span class="hljs-number">2</span>, mixed_precision=<span class="hljs-string">&quot;fp16&quot;</span>)`,lang:"python",wrap:!1}),t(o,n)},$$slots:{default:!0}}),y(s);var g=e(s,2);i(g,{title:"debug_launcher",local:"accelerate.debug_launcher",headingTag:"h2"});var c=e(g,2),_=b(c);f(_,{name:"accelerate.debug_launcher",anchor:"accelerate.debug_launcher",source:"https://github.com/huggingface/accelerate/blob/vr_4060/src/accelerate/launchers.py#L287",parameters:[{name:"function",val:""},{name:"args",val:" = ()"},{name:"num_processes",val:" = 2"}],parametersDescription:[{anchor:"accelerate.debug_launcher.function",description:`<strong>function</strong> (<code>Callable</code>) &#x2014;
The training function to execute.`,name:"function"},{anchor:"accelerate.debug_launcher.args",description:`<strong>args</strong> (<code>Tuple</code>) &#x2014;
Tuple of arguments to pass to the function (it will receive <code>*args</code>).`,name:"args"},{anchor:"accelerate.debug_launcher.num_processes",description:`<strong>num_processes</strong> (<code>int</code>, <em>optional</em>, defaults to 2) &#x2014;
The number of processes to use for training.`,name:"num_processes"}]});var M=e(_,4);k(M,{warning:!0,children:(o,a)=>{var n=N();t(o,n)},$$slots:{default:!0}}),y(c);var z=e(c,2);G(z,{source:"https://github.com/huggingface/accelerate/blob/main/docs/source/package_reference/launchers.md"}),x(2),t(T,l),Z()}export{A as component};

Xet Storage Details

Size:
9.53 kB
·
Xet hash:
371aac7d5bdf6289e68d70bc659c9f5cc5d1d25bff6d3c5dcec960f1bf726622

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