<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: CloudGPU</title>
    <description>The latest articles on DEV Community by CloudGPU (@cloudgpu_app).</description>
    <link>https://dev.to/cloudgpu_app</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4202377%2F0d175f44-703f-4bbe-9f65-e81aa5b0ae28.png</url>
      <title>DEV Community: CloudGPU</title>
      <link>https://dev.to/cloudgpu_app</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/cloudgpu_app"/>
    <language>en</language>
    <item>
      <title>You can run AI without buying a GPU — first tell a local small model, on-demand cloud GPUs, and an existing model API apart</title>
      <dc:creator>CloudGPU</dc:creator>
      <pubDate>Mon, 23 Nov 2026 02:03:23 +0000</pubDate>
      <link>https://dev.to/cloudgpu_app/you-can-run-ai-without-buying-a-gpu-first-tell-a-local-small-model-on-demand-cloud-gpus-and-an-5991</link>
      <guid>https://dev.to/cloudgpu_app/you-can-run-ai-without-buying-a-gpu-first-tell-a-local-small-model-on-demand-cloud-gpus-and-an-5991</guid>
      <description>&lt;h1&gt;
  
  
  You can run AI without buying a GPU — first tell a local small model, on-demand cloud GPUs, and an existing model API apart
&lt;/h1&gt;

&lt;p&gt;You can use AI without buying a discrete graphics card. But “complete a task with a ready-made model” and “deploy a specific model yourself” are different requirements. Write the task down clearly first, then compare a local small model on the computer you already have, on-demand cloud GPUs, and an existing model API, so you can see what you are actually missing.&lt;/p&gt;

&lt;p&gt;This article was prepared with AI assistance, based on official public documentation. It is an English edition of the same brief as the Chinese original; the facts are unchanged. Chinese original: &lt;a href="https://cloudgpu.hashnode.dev/ai-gpu-api" rel="noopener noreferrer"&gt;https://cloudgpu.hashnode.dev/ai-gpu-api&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  First write the task as an acceptance sheet
&lt;/h2&gt;

&lt;p&gt;Fix one shared input, and write down what output you need and what counts as a pass. For example: turn a piece of public technical text that you are allowed to process into three key points. Work in three steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Save the source text, and require the model to extract only information that is already there — it must not add numbers that are not in the source.&lt;/li&gt;
&lt;li&gt;Save the full output, and check each point against the source: is there a basis in the original, and are the numbers the same?&lt;/li&gt;
&lt;li&gt;Record omissions, errors, and anything that needed a human edit. Count the result as a pass only when it meets the requirements you wrote in advance.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If the work is image or video, list the input, the output format, and the workflow you will use as a separate case. A text task that works does not prove that an image or video workflow will work.&lt;/p&gt;

&lt;h2&gt;
  
  
  Three paths, and the problem each one actually solves
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;A local small model on the computer you already have.&lt;/strong&gt; This fits when you want the run to stay on the machine, and the task can start from a relatively small text model. Before you choose it, check the model license, the size of the weights, system memory, context length, and whether your current runtime can support it.&lt;/p&gt;

&lt;p&gt;Parameter count is not the same thing as a minimum memory requirement. Weight format, quantization, context, and concurrency all affect resources. Being able to load a model, and whether the wait is acceptable, should also be judged separately. After a local run, record whether you actually used the CPU or an accelerator; do not infer the runtime from the fact that you did not buy a discrete GPU yourself.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;On-demand cloud GPUs.&lt;/strong&gt; This fits when you need to configure the model, dependencies, and a specific workflow yourself, and the equipment you already have cannot meet the resource requirements. Before you choose it, check the configuration you can actually get, software compatibility, how data will move in and out, and how compute and storage are billed. Renting the hardware does not automatically mean the workflow is already usable. When you finish, confirm separately whether compute has stopped, whether files have been retrieved, and whether storage or other resources are still being billed — follow the terms of the service you chose at that time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;An existing model API.&lt;/strong&gt; This fits when the point is to obtain a given kind of model output, and you are willing to use the models and interfaces the provider offers. Before you choose it, check whether the model and modality support your task, input limits, rate limits, data-processing terms, how usage is metered, and the account balance. It is not the same as holding the model weights, and it does not mean you can deploy an arbitrary custom model. First confirm that the interface can accept your input and return the output you need, then decide whether it is a fit. Existing credits should not be read as permanently free.&lt;/p&gt;

&lt;h2&gt;
  
  
  Decide item by item: scale, latency, privacy, and total cost
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Scale.&lt;/strong&gt; Start with how large the model and the input are: whether the model type, weights, and context are enough, and whether the input exceeds limits. A small text task can be evaluated on equipment you already have; a specified image or video workflow needs its own resource check, not just the parameter name.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Latency.&lt;/strong&gt; Compare the total time for the same task from submit to a usable result. For a local run, record load time and generation time; for a remote environment, also count setup and transfer; for an API, also count request waiting and retries. If you have no record for the same task, which path is faster is unknown.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Privacy.&lt;/strong&gt; Whether the material can leave your environment decides which paths you can try directly. A local run still needs a check of whether the software phones home, how logs are stored, and file permissions. For a cloud environment or an API, first check the scope of uploads, retention rules, and access. If the material should not go out, do not trial it on real data; use public text you are allowed to process to validate the flow first.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Total cost.&lt;/strong&gt; Local runs should count equipment, power, and maintenance; cloud GPUs should count the billed items that actually apply, such as compute, storage, and transfer; APIs should be counted in the units the specific model uses. Failures, retries, and human review should also be included in the cost of each accepted result. Without bills and a count of accepted results, do not fill in a savings percentage, and do not treat numbers from a historical page as a current promise.&lt;/p&gt;

&lt;h2&gt;
  
  
  Next step: try one path first, then decide whether to add hardware
&lt;/h2&gt;

&lt;p&gt;Pick one concrete task, and work in this order:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Fix the input, the output format, and the pass conditions, and list requirements for model scale, wait time, data handling, and budget.&lt;/li&gt;
&lt;li&gt;From the conditions you already have, choose one feasible path. If you need to download, pay, or upload data, confirm the license, the budget, and the data boundary first.&lt;/li&gt;
&lt;li&gt;After the run, keep the full output, the time spent, the cost, and the human-check result; keep a record of failures as well.&lt;/li&gt;
&lt;li&gt;If you change paths, compare them on the same input and the same pass conditions. Only after quality and wait time are both acceptable, calculate the total cost per accepted result.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Get one result you can check, then decide whether you need more hardware.&lt;/p&gt;

&lt;p&gt;References:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.ollama.com/faq" rel="noopener noreferrer"&gt;Running local models and resource notes&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.runpod.io/pods/overview" rel="noopener noreferrer"&gt;Cloud runtime overview&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.runpod.io/pods/pricing" rel="noopener noreferrer"&gt;Compute and storage billing notes&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>ai</category>
    </item>
    <item>
      <title>不买显卡也能跑 AI？先分清本地小模型、云 GPU 和已有 API</title>
      <dc:creator>CloudGPU</dc:creator>
      <pubDate>Sun, 22 Nov 2026 16:47:48 +0000</pubDate>
      <link>https://dev.to/cloudgpu_app/bu-mai-xian-qia-ye-neng-pao-aixian-fen-qing-ben-di-xiao-mo-xing-yun-gpu-he-yi-you-api-1g9g</link>
      <guid>https://dev.to/cloudgpu_app/bu-mai-xian-qia-ye-neng-pao-aixian-fen-qing-ben-di-xiao-mo-xing-yun-gpu-he-yi-you-api-1g9g</guid>
      <description>&lt;h1&gt;
  
  
  不买显卡也能跑 AI？先分清本地小模型、云 GPU 和已有 API
&lt;/h1&gt;

&lt;p&gt;不买独立显卡，也有使用 AI 的路径。但“用现成模型完成任务”和“自己部署指定模型”是不同的要求。先把任务写清楚，再比较手头电脑上的本地小模型、按需云 GPU 和已有模型 API，才能知道自己到底缺什么。&lt;/p&gt;

&lt;p&gt;本文由 AI 辅助整理，依据官方公开文档编写。&lt;/p&gt;

&lt;h2&gt;
  
  
  先把任务写成一张验收单
&lt;/h2&gt;

&lt;p&gt;先固定同一份输入，写清要得到什么输出、怎样才算合格。例如：把一段允许处理的公开技术说明整理成三条要点。操作时分三步：&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;保存原文，要求模型只提取已有信息，不补充原文没有的数字。&lt;/li&gt;
&lt;li&gt;保存完整输出，逐条核对要点是否有原文依据，数字是否一致。&lt;/li&gt;
&lt;li&gt;将遗漏、错误和需要人工修改的地方记下来。只有符合事先写好的要求，才计作合格结果。&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;如果你要做的是图像或视频，就把输入、输出格式和所用工作流另列出来。文本任务能走通，不能证明图像或视频工作流也能走通。&lt;/p&gt;

&lt;h2&gt;
  
  
  三条路径，分别解决什么问题
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;手头电脑上的本地小模型。&lt;/strong&gt; 适合希望把运行过程留在本机、任务可以从较小的文本模型起步的情况。选择前要核：模型许可、权重体积、系统内存、上下文长度，以及当前运行环境是否支持。&lt;/p&gt;

&lt;p&gt;参数规模不能直接当成最低内存要求；权重格式、量化、上下文和并发都会影响资源。能加载模型，和等待时间是否可接受，也要分开看。本机运行后，应记下当时实际是用处理器还是加速卡，不能凭“没有自购独立显卡”直接推断运行方式。&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;按需云 GPU。&lt;/strong&gt; 适合需要自己配置模型、依赖和特定工作流，而现有设备又达不到资源要求的情况。选择前要核：实际可用配置、软件兼容、数据怎么进出，以及计算和存储怎么计费。租到硬件，并不自动等于工作流已经可用。结束时，分别确认计算是否停止、文件是否取回、存储等资源是否仍在计费，具体以所选服务当时的条款为准。&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;已有模型 API。&lt;/strong&gt; 适合重点是取得指定类型的模型输出，并愿意使用服务方提供的模型和接口。选择前要核：模型与模态是否支持你的任务、输入限制、速率、数据处理条款、计量方式和账户余额。它不等于持有模型权重，也不意味着可以部署任意自定义模型。先确认接口能处理你的输入并返回需要的输出，再决定是否适合。已有额度也不应被理解成永久免费。&lt;/p&gt;

&lt;h2&gt;
  
  
  按体量、延迟、隐私和总成本逐项决定
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;体量。&lt;/strong&gt; 先看模型和输入有多大：模型类型、权重和上下文够不够，输入是否超限。小文本任务可以先评估已有设备；指定的图像或视频工作流要单独核资源，不能只看参数名称。&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;延迟。&lt;/strong&gt; 比较同一任务从提交到拿到可用结果的总时间。本地记下加载和生成时间；远程环境还要算准备和传输；接口还要算请求等待和重试。没有同一任务的记录时，谁更快就是未知。&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;隐私。&lt;/strong&gt; 资料能不能外传，决定了哪些路径能直接试。本地运行也要核软件是否联网、日志怎么保存、文件权限如何。云环境和接口则要先核上传范围、保留规则和访问权限。资料不适合外传时，不要直接用真实资料试跑，可以先用允许处理的公开文本验证流程。&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;总成本。&lt;/strong&gt; 本地要算设备、电力和维护；云 GPU 要算计算、存储和传输等实际计费项目；接口要看具体模型按什么单位计量。失败、重试和人工校对也应记入每个合格结果的成本。没有账单和合格结果数量时，不要填写节省比例，也不要用历史页面上的数字当作现行承诺。&lt;/p&gt;

&lt;h2&gt;
  
  
  下一步：先试一条，再决定要不要加硬件
&lt;/h2&gt;

&lt;p&gt;先选一项具体任务，按以下顺序做：&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;固定输入、输出格式和合格条件，列出模型体量、等待时间、数据处理和预算要求。&lt;/li&gt;
&lt;li&gt;从已有条件中选一条可行路径。需要下载、付费或上传数据时，先确认许可、预算和数据边界。&lt;/li&gt;
&lt;li&gt;运行后保留完整输出、耗时、费用和人工核对结果；失败也保留记录。&lt;/li&gt;
&lt;li&gt;若要换路径，用同一份输入和合格条件比较。确认质量与等待时间都能接受，再计算每个合格结果的总成本。&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;先拿到一份能核对的结果，再决定是否需要增加硬件。&lt;/p&gt;

&lt;p&gt;参考资料：&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.ollama.com/faq" rel="noopener noreferrer"&gt;本地模型运行与资源说明&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.runpod.io/pods/overview" rel="noopener noreferrer"&gt;云端运行环境说明&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.runpod.io/pods/pricing" rel="noopener noreferrer"&gt;计算与存储计费说明&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>ai</category>
    </item>
    <item>
      <title>Check the saved PNG before you scale a ComfyUI batch</title>
      <dc:creator>CloudGPU</dc:creator>
      <pubDate>Sat, 21 Nov 2026 05:15:23 +0000</pubDate>
      <link>https://dev.to/cloudgpu_app/check-the-saved-png-before-you-scale-a-comfyui-batch-1j12</link>
      <guid>https://dev.to/cloudgpu_app/check-the-saved-png-before-you-scale-a-comfyui-batch-1j12</guid>
      <description>&lt;p&gt;A green queue status tells you the graph finished. Your editor still needs a file that opens, fits the shot, and leaves room for the subject. If you're using ComfyUI to make background plates for a short drama, test that handoff with one frame before asking for four.&lt;/p&gt;

&lt;p&gt;A historical &lt;a href="https://github.com/Comfy-Org/ComfyUI/issues/16490" rel="noopener noreferrer"&gt;ComfyUI issue report&lt;/a&gt;, now closed, describes a different workflow that completed while producing wrong or black images. The two runs below are a way to check your own files. The workflow structure was checked offline. The settings below are a test plan, with GPU output and timings still to be measured.&lt;/p&gt;

&lt;h2&gt;
  
  
  Build one repeatable run
&lt;/h2&gt;

&lt;p&gt;Start from the &lt;a href="https://docs.comfy.org/tutorials/basic/text-to-image" rel="noopener noreferrer"&gt;official ComfyUI text-to-image example&lt;/a&gt;. That introductory example uses SD1.5. For the test plan here, replace its checkpoint with SDXL Base 1.0, connect its CLIP output to both prompt encoders, pass an empty latent through KSampler, and decode with the checkpoint's VAE. Connect the decoded IMAGE output to Save Image. Record the ComfyUI version, checkpoint filename and SHA-256, VAE choice, GPU, and any offload settings alongside the exported workflow JSON.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Setting&lt;/th&gt;
&lt;th&gt;Example value&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Canvas&lt;/td&gt;
&lt;td&gt;1024 × 1024&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Seed&lt;/td&gt;
&lt;td&gt;42117, fixed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Sampler and scheduler&lt;/td&gt;
&lt;td&gt;Euler / normal&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Steps, CFG, denoise&lt;/td&gt;
&lt;td&gt;20, 7, 1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;First run&lt;/td&gt;
&lt;td&gt;Batch size 1, filename prefix &lt;code&gt;plate-single&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Second run&lt;/td&gt;
&lt;td&gt;Batch size 4, filename prefix &lt;code&gt;plate-batch&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Try an empty hallway with soft light from the upper left and a clear center for a character. In the negative prompt, ask to exclude people, lettering, logos, and watermarks. Keep the prompts and other generation settings fixed across runs. Use a fresh output folder or a unique prefix per attempt so the file counts come from the current job.&lt;/p&gt;

&lt;h2&gt;
  
  
  Inspect the file your editor will receive
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Queue the single-image run. Open its new PNG from disk in an image viewer, check that it decodes at 1024 × 1024, and inspect it for an unexpectedly black frame or other visible corruption. If it fails, keep the job log, workflow and failing file. Record any settings change in a new attempt.&lt;/li&gt;
&lt;li&gt;Put a rough character cutout over the plate in your editor. Check that the framing and lighting work for the shot and that the intended subject area stays clear. If the delivery is vertical, check the actual 9:16 crop in the editor. The square test image is the source plate.&lt;/li&gt;
&lt;li&gt;Once the first plate passes, try the four-image batch. Open every new PNG and apply the same checks. If the batch fails on memory, record the failure and try four single-image runs as a separate case. Record the elapsed time for the entire four-image job so you can compare the two approaches.&lt;/li&gt;
&lt;li&gt;Copy the accepted PNGs and workflow to storage outside the render machine. Open the copies in the destination environment and count the files that pass there. Keep that count with the run settings so the next person can tell which files cleared the handoff.&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Run&lt;/th&gt;
&lt;th&gt;Expected files&lt;/th&gt;
&lt;th&gt;New PNGs saved&lt;/th&gt;
&lt;th&gt;Passed after export&lt;/th&gt;
&lt;th&gt;Queue-to-save time&lt;/th&gt;
&lt;th&gt;Failure or framing note&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Single&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Batch&lt;/td&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Copy the two rows into your project notes and fill in the single-image row first. If you're handing off a short-drama plate, include one screenshot showing where the character will sit in the final crop. If you're debugging the graph, save the workflow JSON and the failing PNG together before changing settings.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Prepared by the CloudGPU team with AI assistance. This is an unrun test plan, not a GPU benchmark.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>comfyui</category>
      <category>ai</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Round each bill before comparing AI-video costs</title>
      <dc:creator>CloudGPU</dc:creator>
      <pubDate>Thu, 19 Nov 2026 05:55:30 +0000</pubDate>
      <link>https://dev.to/cloudgpu_app/round-each-bill-before-comparing-ai-video-costs-f9n</link>
      <guid>https://dev.to/cloudgpu_app/round-each-bill-before-comparing-ai-video-costs-f9n</guid>
      <description>&lt;p&gt;AI-generated article. All prices are fictional USD inputs, and the code was verified offline. This is not a GPU benchmark.&lt;/p&gt;

&lt;p&gt;A video generator can look cheap per second and still be expensive per second you actually keep. Three numbers answer different questions: generated duration, accepted duration, and billable allocation time. Keep all three.&lt;/p&gt;

&lt;p&gt;Suppose a fictional session produces 120 seconds, but the edit uses only 60. The GPU is allocated for 4,764 seconds, including preparation. At an assumed $0.69 per hour, minute rounding produces an 80-minute bill: $0.92. Whole-hour rounding produces a two-hour bill: $1.38. Neither number is a current provider quote or a promise about picture quality.&lt;/p&gt;

&lt;p&gt;The important detail is where rounding happens. Two independently billed 30-second sessions with a one-minute minimum cost two minutes, even though their combined allocation is one minute. Aggregate the actual bills after rounding each billing event. A provider may instead round an account-wide interval; model its actual contract rather than imposing this example.&lt;/p&gt;

&lt;p&gt;The script assumes a minimum of one minute for minute billing and one hour for hour billing. A zero-duration event still incurs that minimum. Change the formula if your contract uses different terms.&lt;/p&gt;

&lt;p&gt;Use one CSV row per independently billed event:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;event_id,billing,allocation_seconds,unit_price,generated_seconds,accepted_seconds,extra_usd
hypothetical-session-1,minute,4764,0.69,120,60,310
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here unit_price is USD per hour for minute/hour billing, or USD per generated output second for output_second billing. The $310 is a fictional shared production budget, not a measured labour cost. Record it once, not once per generation.&lt;/p&gt;

&lt;p&gt;Save the CSV above as &lt;code&gt;example.csv&lt;/code&gt; and the following code as &lt;code&gt;accepted_cost.py&lt;/code&gt;, then run &lt;code&gt;python3 accepted_cost.py example.csv&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="s2"&gt;"""Offline USD ledger; one CSV row per billed session/request, not per retry summary."""&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;csv&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;sys&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;decimal&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;Decimal&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;ROUND_CEILING&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;money&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;kind&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'billing'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nc"&gt;Decimal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'allocation_seconds'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nc"&gt;Decimal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'unit_price'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;gen&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nc"&gt;Decimal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'generated_seconds'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;used&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nc"&gt;Decimal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'accepted_seconds'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;extra&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nc"&gt;Decimal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'extra_usd'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;gen&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;used&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;extra&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;used&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;gen&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'invalid negative amount or accepted &amp;gt; generated'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;kind&lt;/span&gt;&lt;span class="o"&gt;==&lt;/span&gt;&lt;span class="s1"&gt;'minute'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;cost&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Decimal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;to_integral_value&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rounding&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="no"&gt;ROUND_CEILING&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;60&lt;/span&gt;
    &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;kind&lt;/span&gt;&lt;span class="o"&gt;==&lt;/span&gt;&lt;span class="s1"&gt;'hour'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;cost&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Decimal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;3600&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;to_integral_value&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rounding&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="no"&gt;ROUND_CEILING&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;
    &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;kind&lt;/span&gt;&lt;span class="o"&gt;==&lt;/span&gt;&lt;span class="s1"&gt;'output_second'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;cost&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;gen&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'unknown billing unit'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;cost&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="n"&gt;extra&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;used&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;summarize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rows&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;ids&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kt"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;total&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nc"&gt;Decimal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;used&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nc"&gt;Decimal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;rows&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'event_id'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;ids&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'duplicate billed event'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;ids&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'event_id'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nf"&gt;money&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="n"&gt;total&lt;/span&gt;&lt;span class="o"&gt;+=&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="n"&gt;used&lt;/span&gt;&lt;span class="o"&gt;+=&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kt"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;total_usd&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;total&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;accepted_seconds&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;used&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;usd_per_accepted_second&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;total&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;used&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;used&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;__name__&lt;/span&gt;&lt;span class="o"&gt;==&lt;/span&gt;&lt;span class="s1"&gt;'__main__'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;argv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;newline&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dumps&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;summarize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;csv&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;DictReader&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;indent&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It returns total_usd 310.92, accepted_seconds 60, and usd_per_accepted_second 5.182. It uses Decimal arithmetic, rejects duplicate event IDs, rejects negative values and accepted duration greater than generated duration, and returns null for unit cost if nothing is accepted.&lt;/p&gt;

&lt;p&gt;There is a useful limitation: generated_seconds means billable output seconds in this simplified ledger. A failed request may cost money while returning no video. Record that charge in extra_usd or extend the schema with a separate charge field; do not invent output duration. Input references, storage, tax, minimum spend and currency conversion also need explicit treatment when they apply. Multiple currencies must be converted using a recorded rate before aggregation.&lt;/p&gt;

&lt;p&gt;For a fair comparison, run the same shot list with a fixed resolution, frame rate, duration and acceptance rubric. Log every attempt, including rejected clips. Ask a reviewer to assess continuity, faces, hands and motion without seeing the provider name. Report the accepted fraction and total elapsed work alongside the bill. Equal output duration alone is not equal quality.&lt;/p&gt;

&lt;p&gt;Finally, test the zero case. If all clips are rejected, there is no meaningful cost per accepted second. Showing zero would turn a complete failure into an apparently free result. Keep the cost, show the denominator as zero, and display the rate as unavailable.&lt;/p&gt;

</description>
      <category>python</category>
      <category>video</category>
      <category>ai</category>
      <category>abotwrotethis</category>
    </item>
    <item>
      <title>“Runs on 6GB” is a starting point, not a GPU buying decision</title>
      <dc:creator>CloudGPU</dc:creator>
      <pubDate>Wed, 18 Nov 2026 23:18:27 +0000</pubDate>
      <link>https://dev.to/cloudgpu_app/runs-on-6gb-is-a-starting-point-not-a-gpu-buying-decision-3f54</link>
      <guid>https://dev.to/cloudgpu_app/runs-on-6gb-is-a-starting-point-not-a-gpu-buying-decision-3f54</guid>
      <description>&lt;p&gt;A low-VRAM workflow can be useful evidence, but its title leaves out the workload. Before buying hardware, write down the exact model files, precision, workflow revision, input dimensions or duration, software versions, and the result you need to deliver.&lt;/p&gt;

&lt;p&gt;Start with one real task. Keep the workflow and input fixed. Measure loading, encoding, sampling, decoding, and saving separately where the tools expose those stages. A saved file is not automatically a successful result: check that a video plays, audio is audible, and the output meets your quality requirements.&lt;/p&gt;

&lt;p&gt;Separate the first run from later runs. Downloads, model loading, compilation, and caching can dominate the first attempt. Record end-to-end time, peak device memory, host memory, success or failure, and whether the result is acceptable. Change one condition at a time.&lt;/p&gt;

&lt;p&gt;Only then compare smaller models, local configuration changes, a hardware upgrade, or a paid cloud comparison where the service is available. Run the same task and compare usable output, waiting time, reliability, and total cost. A faster VAE stage does not establish the same speedup for the whole workflow.&lt;/p&gt;

&lt;p&gt;Before renting, check the quote, billing interval, and minimum charge for the configuration you select.&lt;/p&gt;

&lt;p&gt;This article was prepared with AI assistance. It describes a measurement method. No GPU benchmark was performed.&lt;/p&gt;

</description>
      <category>comfyui</category>
      <category>gpu</category>
    </item>
    <item>
      <title>Run a restore test before shutting down a cloud ComfyUI instance</title>
      <dc:creator>CloudGPU</dc:creator>
      <pubDate>Wed, 18 Nov 2026 06:50:36 +0000</pubDate>
      <link>https://dev.to/cloudgpu_app/run-a-restore-test-before-shutting-down-a-cloud-comfyui-instance-50kg</link>
      <guid>https://dev.to/cloudgpu_app/run-a-restore-test-before-shutting-down-a-cloud-comfyui-instance-50kg</guid>
      <description>&lt;p&gt;Before shutting down a cloud ComfyUI instance, restore a copy of your workflow somewhere else and render one sample.&lt;/p&gt;

&lt;p&gt;Pack the workflow JSON, inputs and masks, and record model and custom-node versions. If the sample runs and lands in the expected output folder, write that down in the handoff.&lt;/p&gt;

&lt;p&gt;On CloudGPU, check the billing period and minimum charge shown for the selected configuration before renting.&lt;/p&gt;

</description>
      <category>comfyui</category>
      <category>devops</category>
    </item>
    <item>
      <title>Keep timeouts in your inference benchmark denominator</title>
      <dc:creator>CloudGPU</dc:creator>
      <pubDate>Tue, 17 Nov 2026 11:29:09 +0000</pubDate>
      <link>https://dev.to/cloudgpu_app/keep-timeouts-in-your-inference-benchmark-denominator-26e4</link>
      <guid>https://dev.to/cloudgpu_app/keep-timeouts-in-your-inference-benchmark-denominator-26e4</guid>
      <description>&lt;p&gt;A latency report can be mathematically correct and still answer the wrong question. If you retain only completed inference requests, the median describes those completions, not what happened to everyone who sent a request.&lt;/p&gt;

&lt;p&gt;This is a small, provider-neutral reporting exercise from CloudGPU. All numbers below are synthetic. The aggregation code was tested locally on Python 3.9.6; no model endpoint or GPU was benchmarked. &lt;strong&gt;Disclosure: an autonomous AI agent drafted and checked this tutorial and ran the local code tests on behalf of CloudGPU. This is not a firsthand human production-performance report.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Four requests, two different answers
&lt;/h2&gt;

&lt;p&gt;Imagine a fixed cohort of four logical requests. Two finish in 1 and 3 seconds. Two time out after 10 seconds. The median of successful completions is 2 seconds. The fraction completed by a 10-second deadline is 2/4, or 50%.&lt;/p&gt;

&lt;p&gt;Neither number cancels the other. A reader deciding whether an interactive feature meets its deadline needs both. Reporting only the median hides the two unsuccessful requests. Replacing their durations with zero is worse: it rewards failure. Replacing them with 10-second &lt;em&gt;successful&lt;/em&gt; completions is also wrong. The client stopped waiting; it did not observe completion.&lt;/p&gt;

&lt;p&gt;This example is not evidence that any service has a 50% failure rate. It is deliberately tiny arithmetic, not a statistically useful performance study.&lt;/p&gt;

&lt;h2&gt;
  
  
  Define the row before calculating anything
&lt;/h2&gt;

&lt;p&gt;Use one row per logical user request, measured from its initial start to completion or terminal client failure. If it retries, elapsed time includes those retries and waiting periods. Keep individual HTTP attempts in a separate dataset. Mixing requests and attempts silently changes the denominator.&lt;/p&gt;

&lt;p&gt;For this exercise, &lt;code&gt;ok&lt;/code&gt; means the complete response arrived and passed your protocol-level checks. It does not mean the answer was factually correct. &lt;code&gt;timeout&lt;/code&gt; means the client reached its configured waiting limit; &lt;code&gt;error&lt;/code&gt; covers other terminal failures. Record finer error categories separately in a real harness.&lt;/p&gt;

&lt;p&gt;The cohort must include every started request. Reconcile its IDs with your start log after the run. A summary function cannot discover requests your logger silently dropped. Do not summarize while some rows are still in flight; otherwise the denominator is incomplete.&lt;/p&gt;

&lt;h2&gt;
  
  
  A standard-library summary
&lt;/h2&gt;

&lt;p&gt;Save this as &lt;code&gt;report.py&lt;/code&gt;. It accepts numeric elapsed seconds, rejects duplicate IDs and invalid measurements, and returns &lt;code&gt;None&lt;/code&gt; for the success-only median when nothing succeeded. Every row must contain the three fields shown in the synthetic example.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;math&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;statistics&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;median&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;summarize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rows&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;deadline_s&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;deadline_s&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;float&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isfinite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;deadline_s&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;deadline_s&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'deadline_s must be positive and finite'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;rows&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rows&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;rows&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'empty cohort'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;seen&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;successes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;rows&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;request_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'id'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="n"&gt;elapsed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'elapsed_s'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="nb"&gt;isinstance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;request_id&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;request_id&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;seen&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'missing or duplicate id'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;seen&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;elapsed&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;float&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isfinite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;elapsed&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;elapsed&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'invalid elapsed_s'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'status'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'ok'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'timeout'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'error'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'unknown status'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'status'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s1"&gt;'ok'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;successes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;elapsed&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;total&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rows&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;on_time&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;deadline_s&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;successes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="s1"&gt;'requests'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;total&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s1"&gt;'completed'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;successes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s1"&gt;'timeouts'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'status'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s1"&gt;'timeout'&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;rows&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s1"&gt;'errors'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'status'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s1"&gt;'error'&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;rows&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s1"&gt;'completed_by_deadline'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;on_time&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s1"&gt;'completed_by_deadline_fraction'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;on_time&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;total&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s1"&gt;'success_only_median_s'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;median&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;successes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;successes&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;


&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s1"&gt;'__main__'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;synthetic&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s1"&gt;'id'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'a'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'status'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'ok'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'elapsed_s'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s1"&gt;'id'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'b'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'status'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'ok'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'elapsed_s'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s1"&gt;'id'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'c'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'status'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'timeout'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'elapsed_s'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s1"&gt;'id'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'d'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'status'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'timeout'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'elapsed_s'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;summarize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;synthetic&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;deadline_s&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run &lt;code&gt;python3 report.py&lt;/code&gt;. The output reports four requests, two completions, two timeouts, zero other errors, two completions by the deadline, a deadline fraction of &lt;code&gt;0.5&lt;/code&gt;, and a success-only median of &lt;code&gt;2.0&lt;/code&gt; seconds.&lt;/p&gt;

&lt;p&gt;The local checks also covered an all-timeout cohort, a successful response later than the deadline, completion exactly at the deadline, an empty cohort, duplicate IDs, NaN, negative durations, boolean durations, unknown status, and an invalid deadline. They check aggregation behavior, not a network client's logging correctness. Python documents the median and the pitfalls of NaN values in its &lt;a href="https://docs.python.org/3/library/statistics.html" rel="noopener noreferrer"&gt;statistics module&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;For elapsed timing in a real client, take a difference between two readings of an appropriate clock, such as Python's &lt;a href="https://docs.python.org/3/library/time.html#time.perf_counter" rel="noopener noreferrer"&gt;perf_counter&lt;/a&gt;. Do not subtract a server timestamp from a client timestamp and assume their clocks agree. Record your timing boundary explicitly.&lt;/p&gt;

&lt;h2&gt;
  
  
  What this deliberately does not measure
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Streaming first-token latency:&lt;/strong&gt; completion time and time to first usable token are different. A stream can start quickly and then stall. If streaming matters, record both boundaries and whether the stream completed. A connection event or an empty metadata chunk is not necessarily the first usable token.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Throughput:&lt;/strong&gt; summing request durations does not produce benchmark wall time when requests overlap. This script does not calculate requests per second or tokens per second.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Answer quality:&lt;/strong&gt; a fast, complete, wrong answer still appears as &lt;code&gt;ok&lt;/code&gt; here. Keep task-quality evaluation beside transport metrics, with its own stated criterion. Do not silently redefine success after looking at which configuration wins.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Server cancellation or billing:&lt;/strong&gt; a client timeout does not establish whether server work stopped or what was charged. Use the service's documented task status and billing records for those questions, rather than inferring them from this table.&lt;/p&gt;

&lt;h2&gt;
  
  
  Compare like with like
&lt;/h2&gt;

&lt;p&gt;For a real comparison, preserve the model revision, prompts or approved test-set identifiers, output limits, concurrency, retry policy, timeout, warm-up treatment and measurement window. Separate cold-start and already-warm cohorts instead of averaging away the distinction. Keep credentials and private prompt text out of a public results file.&lt;/p&gt;

&lt;p&gt;Choose the deadline before examining the result. Report the cohort size, counts for each terminal status, the fraction completed by that deadline, and clearly labeled successful-request latency statistics. Larger samples and uncertainty analysis are still needed before drawing broad conclusions; this four-row example cannot support a tail-latency claim.&lt;/p&gt;

&lt;p&gt;The practical change is small: keep failures in the denominator, without pretending they were successful responses with a made-up duration.&lt;/p&gt;

</description>
      <category>python</category>
      <category>testing</category>
      <category>ai</category>
      <category>performance</category>
    </item>
    <item>
      <title>The hourly GPU price is not your agent's task budget</title>
      <dc:creator>CloudGPU</dc:creator>
      <pubDate>Sun, 15 Nov 2026 12:59:50 +0000</pubDate>
      <link>https://dev.to/cloudgpu_app/the-hourly-gpu-price-is-not-your-agents-task-budget-2d8n</link>
      <guid>https://dev.to/cloudgpu_app/the-hourly-gpu-price-is-not-your-agents-task-budget-2d8n</guid>
      <description>&lt;p&gt;An agent can find a cheap GPU and still make an expensive decision. The quoted hourly rate is only one input: billing increments, environment preparation, model download time, output persistence and uncertain startup results change what a task actually costs.&lt;/p&gt;

&lt;p&gt;Here is a small, provider-neutral way to make that decision inspectable before an agent is allowed to spend.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Represent the billing increment explicitly
&lt;/h2&gt;

&lt;p&gt;Two offers can advertise the same hourly rate but bill differently. At an illustrative $0.40/hour, a 12-minute task costs $0.08 on a source that bills whole minutes, and $0.40 on one with a one-hour minimum and whole-hour increments. An early stop does not erase the agreed minimum.&lt;/p&gt;

&lt;p&gt;Use decimal arithmetic for money, and keep the minimum separate from the increment:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;decimal&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;Decimal&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;ROUND_CEILING&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;estimate_compute_fee&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;seconds&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;hourly_usd&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;minimum_seconds&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;increment_seconds&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;seconds&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;minimum_seconds&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;increment_seconds&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Durations and increments must be positive"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;rate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Decimal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;hourly_usd&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;rate&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;is_finite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;rate&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Rate must be finite and nonnegative"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;duration&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Decimal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;seconds&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;units&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;duration&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="nc"&gt;Decimal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;increment_seconds&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;to_integral_value&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;rounding&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="no"&gt;ROUND_CEILING&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;billed_seconds&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Decimal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;minimum_seconds&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;units&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;increment_seconds&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;rate&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;billed_seconds&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="nc"&gt;Decimal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3600&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;estimate_compute_fee&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;720&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"0.40"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;      &lt;span class="c1"&gt;# 0.08&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;estimate_compute_fee&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;720&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"0.40"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3600&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3600&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# 0.40&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is an estimate, not an invoice. Production integrations also need the provider's actual start condition, pricing expiry and finalized ledger. Do not round away the precision the ledger uses.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Budget for preparation and persistence
&lt;/h2&gt;

&lt;p&gt;A duration estimate should include environment setup and model loading, not just the compute kernel. Downloading several gigabytes can take longer than a small generation task.&lt;/p&gt;

&lt;p&gt;A useful planning decomposition is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;expected task cost =
  billed compute(setup + download + execution + output collection)
  + applicable storage
  + applicable transfer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each term needs a source and a timestamp. If transfer charges or storage retention are unknown, report that uncertainty instead of silently assigning zero. Record the successful attempt separately from the total cost of development retries.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Make approval a specific contract
&lt;/h2&gt;

&lt;p&gt;An account connection grants access; it is not informed approval of every future action. Before allocation, show the selected offer, minimum charge, billing increment, estimated total, hard limits, data to upload and intended output location.&lt;/p&gt;

&lt;p&gt;Bind that approval to a current quote. If an expired quote is replaced by a different source with a different minimum charge, obtain approval for the new terms. A GPU's model name does not imply a billing policy.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Reconcile uncertain allocation instead of retrying blindly
&lt;/h2&gt;

&lt;p&gt;A timeout is not proof that allocation failed. Creating another instance can leave two billable resources.&lt;/p&gt;

&lt;p&gt;Persist the request identity and inspect the existing resource state before retrying. Use documented idempotency semantics where supported; do not assume a create endpoint is idempotent because another endpoint accepts an idempotency key. If the result remains uncertain, surface that state for reconciliation rather than spawning a replacement.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Treat output verification and release as part of success
&lt;/h2&gt;

&lt;p&gt;A process exit code of zero is insufficient when the disk will disappear on termination. A task acceptance record should capture:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Workload and dependency revisions.&lt;/li&gt;
&lt;li&gt;Execution status and exit code.&lt;/li&gt;
&lt;li&gt;Output manifest, byte counts and checksums.&lt;/li&gt;
&lt;li&gt;Finalized compute fees and separate storage or transfer charges.&lt;/li&gt;
&lt;li&gt;Resource release confirmation, including whether that confirmation came from the upstream supplier.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It is useful to expose a read-only discovery endpoint for agents that have no credentials yet. Return capabilities, billing rules, task limitations, known issues and sample sizes. If there is too little production data for a success rate, return &lt;code&gt;null&lt;/code&gt; with an explanation. A failed discovery request should remain a failure, not be replaced with a cached green check.&lt;/p&gt;

&lt;p&gt;The practical result is a better planning boundary: the agent can explain whether a workload fits before the human grants spending authority, and the final receipt describes an actual completed task rather than just an hourly price.&lt;/p&gt;




&lt;p&gt;Disclosure: this article was prepared with AI assistance and checked against implemented billing and task-control behavior. The examples are illustrative and do not invoke a GPU or any paid service.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>python</category>
      <category>architecture</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Five short prompts for an agent that needs a GPU</title>
      <dc:creator>CloudGPU</dc:creator>
      <pubDate>Sun, 15 Nov 2026 11:59:09 +0000</pubDate>
      <link>https://dev.to/cloudgpu_app/five-short-prompts-for-an-agent-that-needs-a-gpu-4mkh</link>
      <guid>https://dev.to/cloudgpu_app/five-short-prompts-for-an-agent-that-needs-a-gpu-4mkh</guid>
      <description>&lt;h1&gt;
  
  
  Five short prompts for an agent that needs a GPU
&lt;/h1&gt;

&lt;p&gt;I work on CloudGPU. If your assistant can call GPU tools, the useful request is one short sentence: what to do, what the cap is, and when to wait. Here are five prompts you can paste, plus the short steps behind each one.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Rent a GPU
&lt;/h2&gt;

&lt;p&gt;Prompt:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Use CloudGPU for this task: check my running instances, show the current quote and a $2 budget cap, and wait for my approval before creating anything.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Use an MCP-capable client with CloudGPU connected (remote endpoint &lt;code&gt;https://cloudgpu.app/mcp&lt;/code&gt;, or the local MCP server). Approving account access is not approval of this paid task.&lt;/li&gt;
&lt;li&gt;Let the agent inspect running instances and whether this task needs a GPU.&lt;/li&gt;
&lt;li&gt;Review the live quote, the $2 budget cap (a cap, not a GPU price), the time limit, the command, and the expected outputs. Treat storage charges as separate.&lt;/li&gt;
&lt;li&gt;Approve only that quote, then let the agent create the rental or submit the Job. Keep the instance or Job id; do not retry an uncertain request blindly.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Guide: &lt;a href="https://cloudgpu.app/guides/can-chatgpt-rent-and-reuse-a-cloud-gpu?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=202611_agent_answers&amp;amp;utm_content=dt1115_rent" rel="noopener noreferrer"&gt;https://cloudgpu.app/guides/can-chatgpt-rent-and-reuse-a-cloud-gpu?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=202611_agent_answers&amp;amp;utm_content=dt1115_rent&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Reuse a running instance
&lt;/h2&gt;

&lt;p&gt;Prompt:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Check whether I already have a suitable running CloudGPU instance for this task, and if it still fits, reuse it for these approved commands instead of starting a new GPU.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Have the agent list running instances and check ownership, readiness, remaining spend, time and idle limits, and available memory or disk.&lt;/li&gt;
&lt;li&gt;If a running rental fits, run only the newly approved commands on that same instance. Do not extend the original limits, and do not keep an idle GPU just to use remaining prepaid time.&lt;/li&gt;
&lt;li&gt;A saved Workspace version reuses selected project files, not the operating system or installed packages. A later Job still needs a fresh quote and approval.&lt;/li&gt;
&lt;li&gt;Separate Jobs each start and release their own GPU; they do not borrow a live rental. If applying files to an existing user-owned instance fails, do not stop that instance.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Guide: &lt;a href="https://cloudgpu.app/guides/how-to-reuse-a-running-gpu-over-remote-mcp?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=202611_agent_answers&amp;amp;utm_content=dt1115_reuse" rel="noopener noreferrer"&gt;https://cloudgpu.app/guides/how-to-reuse-a-running-gpu-over-remote-mcp?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=202611_agent_answers&amp;amp;utm_content=dt1115_reuse&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Control the budget
&lt;/h2&gt;

&lt;p&gt;Prompt:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;For this CloudGPU task, set a $2 budget cap and a 1-hour time cap, show the current quote, and do not start until I approve.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The $2 and 1-hour figures bound this request only. They are this-task caps, not a GPU price, and not approval for later tasks.&lt;/li&gt;
&lt;li&gt;Review the live quote, including the billing increment, minimum charge, and time for setup, downloads, and bringing results back.&lt;/li&gt;
&lt;li&gt;A top-up or a funded balance is not approval of this quote. Storage charges need a separate ok; they are not covered by the GPU spend cap.&lt;/li&gt;
&lt;li&gt;After the task, check the recorded cost and confirm that a GPU rented for this task was released.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Guide: &lt;a href="https://cloudgpu.app/guides/how-to-set-gpu-budget-caps-over-remote-mcp?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=202611_agent_answers&amp;amp;utm_content=dt1115_budget" rel="noopener noreferrer"&gt;https://cloudgpu.app/guides/how-to-set-gpu-budget-caps-over-remote-mcp?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=202611_agent_answers&amp;amp;utm_content=dt1115_budget&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Run ComfyUI
&lt;/h2&gt;

&lt;p&gt;Prompt:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Use CloudGPU to run this ComfyUI workflow: prefer a running instance if it already fits, keep a $2 budget cap, and download the images when it finishes.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Prefer the official ComfyUI template. First check for a suitable running instance.&lt;/li&gt;
&lt;li&gt;If a new rental is needed, review the live quote and this-task caps, then approve before creating it. The $2 figure is a budget cap, not a GPU price.&lt;/li&gt;
&lt;li&gt;The template provides ComfyUI, not model weights. Download the weights the workflow needs onto the instance, into the matching folders under &lt;code&gt;ComfyUI/models/&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;If a public HTTPS API address is shown, it is only live while the instance runs. Submit an API-format workflow with &lt;code&gt;POST /prompt&lt;/code&gt;, poll &lt;code&gt;GET /history/{prompt_id}&lt;/code&gt;, and fetch images with &lt;code&gt;GET /view&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Confirm the downloaded files first. Stop a rental only if this task created it. Do not stop an existing instance you were only reusing unless the owner asked.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Guide: &lt;a href="https://cloudgpu.app/rent-gpu-for-comfyui?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=202611_agent_answers&amp;amp;utm_content=dt1115_comfy" rel="noopener noreferrer"&gt;https://cloudgpu.app/rent-gpu-for-comfyui?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=202611_agent_answers&amp;amp;utm_content=dt1115_comfy&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Save the results
&lt;/h2&gt;

&lt;p&gt;Prompt:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Download this CloudGPU task’s results to ./outputs, confirm the files are there, and only then stop a GPU rented for this task.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Stopping a rental deletes the instance disk. Saving files and stopping billing are separate steps.&lt;/li&gt;
&lt;li&gt;Copy the results off the running machine first (a client download, rsync, or explicitly requested Job collection) and open the saved files to confirm they arrived.&lt;/li&gt;
&lt;li&gt;If you also want a Workspace version, save selected project files after they are on the client computer. Workspace is not a full-disk backup and does not keep installed packages.&lt;/li&gt;
&lt;li&gt;GPU spend caps do not approve extra paid storage. After the files are confirmed, stop only a GPU rented for this task. Do not destroy an existing user-owned instance you were only reusing unless the owner asked.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Guide: &lt;a href="https://cloudgpu.app/guides/how-to-save-gpu-results-over-remote-mcp?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=202611_agent_answers&amp;amp;utm_content=dt1115_save" rel="noopener noreferrer"&gt;https://cloudgpu.app/guides/how-to-save-gpu-results-over-remote-mcp?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=202611_agent_answers&amp;amp;utm_content=dt1115_save&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Paste one prompt per task. The agent should wait when the quote is new, reuse a running machine when it already fits, and clean up only a rental it created for this request, after the downloads are confirmed.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>mcp</category>
      <category>gpu</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>How do I stop a streaming chat client from crashing on an empty delta?</title>
      <dc:creator>CloudGPU</dc:creator>
      <pubDate>Wed, 11 Nov 2026 07:52:48 +0000</pubDate>
      <link>https://dev.to/cloudgpu_app/how-do-i-stop-a-streaming-chat-client-from-crashing-on-an-empty-delta-3mh5</link>
      <guid>https://dev.to/cloudgpu_app/how-do-i-stop-a-streaming-chat-client-from-crashing-on-an-empty-delta-3mh5</guid>
      <description>&lt;p&gt;I work on CloudGPU. Treat streamed chunks as events, not complete chat messages. A chunk can contain a role update, no text, or no choices. Check before indexing, append only text, and keep the completion's finish reason separate from the accumulated answer.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Isolate the reducer from network code
&lt;/h2&gt;

&lt;p&gt;Save this helper as &lt;code&gt;stream_text.py&lt;/code&gt;. It consumes the shape of an SDK chunk after &lt;code&gt;model_dump()&lt;/code&gt; and only follows choice index zero:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;collect_text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;chunks&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;pieces&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="n"&gt;finish&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;chunk&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;chunks&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;choice&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;chunk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"choices"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;choice&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"index"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="k"&gt;continue&lt;/span&gt;
            &lt;span class="n"&gt;delta&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;choice&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"delta"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
            &lt;span class="n"&gt;content&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;delta&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"content"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;isinstance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;pieces&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;reason&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;choice&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"finish_reason"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;reason&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;finish&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;reason&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pieces&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;finish&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The index is explicit: do not concatenate different alternatives into one answer. This helper handles text only. It does not interpret extra model-specific fields or claim they have the same meaning as answer text.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Exercise the empty cases without calling a model
&lt;/h2&gt;

&lt;p&gt;In a separate local file, use a deliberately synthetic sequence:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;stream_text&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;collect_text&lt;/span&gt;

&lt;span class="n"&gt;fixture&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"choices"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"choices"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"index"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"delta"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"role"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"assistant"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"choices"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"index"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"delta"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"content"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"hello"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"choices"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"index"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"delta"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"finish_reason"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"stop"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="nf"&gt;collect_text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fixture&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"hello"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"stop"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These events are a client-side fixture, not a captured CloudGPU response. A reducer can be tested without credentials and without inferring which optional events a particular model sends.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Attach the reducer to an authorized live stream
&lt;/h2&gt;

&lt;p&gt;Set &lt;code&gt;${CLOUDGPU_API_KEY}&lt;/code&gt; and &lt;code&gt;${CLOUDGPU_BASE_URL}&lt;/code&gt; in the process environment. Use the documented current API base including its version prefix. Add this to a separate script when you are ready for a live request:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;openai&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;OpenAI&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;stream_text&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;collect_text&lt;/span&gt;

&lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nc"&gt;OpenAI&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;api_key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"CLOUDGPU_API_KEY"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;base_url&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"CLOUDGPU_BASE_URL"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;max_retries&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;stream&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;chat&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;completions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"deepseek-v4-flash"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;messages&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"role"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"user"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"content"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Name one Python collection."&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;stream&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;finish&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;collect_text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;chunk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;model_dump&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;chunk&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;stream&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;finally&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;stream&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;close&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"finish_reason"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;finish&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;An interrupted iterator raises; do not turn a partial buffer into a successful answer. Even when the iterator ends normally, a missing finish reason should remain unresolved in your application. If the reason indicates truncation, retain that state instead of labeling the answer complete. Never infer success from a nonempty text buffer alone.&lt;/p&gt;

&lt;p&gt;Official references: &lt;a href="https://github.com/openai/openai-python" rel="noopener noreferrer"&gt;Python SDK&lt;/a&gt; and &lt;a href="https://cloudgpu.app/api/docs?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=202611_seg06_indiedev_api&amp;amp;utm_content=geoextra1111_05_stream" rel="noopener noreferrer"&gt;CloudGPU's streaming contract&lt;/a&gt;. The model identifier was checked against today's public catalog; that is not a live-stream validation.&lt;/p&gt;

&lt;p&gt;Related CloudGPU video: &lt;strong&gt;This Video Was Made by AI. Now Run AI Yourself&lt;/strong&gt;. It provides product context, not evidence that this particular streaming sequence was observed.&lt;/p&gt;

&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/lS1mz_gTIV4" width="710" height="399"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;The preparation checks cover syntax and an offline reducer fixture only. No API generation or GPU run was performed.&lt;/p&gt;

</description>
      <category>api</category>
      <category>python</category>
      <category>openai</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Where should gradient clipping go in a mixed-precision LoRA training step?</title>
      <dc:creator>CloudGPU</dc:creator>
      <pubDate>Wed, 11 Nov 2026 06:57:33 +0000</pubDate>
      <link>https://dev.to/cloudgpu_app/where-should-gradient-clipping-go-in-a-mixed-precision-lora-training-step-gan</link>
      <guid>https://dev.to/cloudgpu_app/where-should-gradient-clipping-go-in-a-mixed-precision-lora-training-step-gan</guid>
      <description>&lt;p&gt;I work on CloudGPU. When you use PyTorch gradient scaling, clip after &lt;code&gt;scaler.unscale_(optimizer)&lt;/code&gt; and before &lt;code&gt;scaler.step(optimizer)&lt;/code&gt;. Clipping scaled gradients changes the meaning of the threshold. During gradient accumulation, wait until the effective batch is complete before unscaling.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Identify who owns the training step
&lt;/h2&gt;

&lt;p&gt;The function below is for a custom, single-optimizer PyTorch loop using CUDA autocast with &lt;code&gt;float16&lt;/code&gt;. It is not an instruction to add a second scaler inside a trainer that already manages mixed precision. In a managed trainer, use its documented clipping hook instead.&lt;/p&gt;

&lt;p&gt;Construct the optimizer from the adapter parameters you actually intend to train. Frozen parameters do not become trainable just because you include them in a clipping call.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Put the operations in an explicit order
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;torch&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;adapter_step&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;optimizer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;scaler&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;inputs&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;targets&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;loss_fn&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="c1"&gt;# Inputs, targets and the prepared model already belong to CUDA.&lt;/span&gt;
    &lt;span class="n"&gt;optimizer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;zero_grad&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;set_to_none&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;trainable&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parameters&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;requires_grad&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;trainable&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"No trainable parameters"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;torch&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;autocast&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;device_type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"cuda"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;dtype&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;torch&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;float16&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;loss&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;loss_fn&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;model&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;inputs&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;targets&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;loss&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ndim&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;torch&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isfinite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;loss&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;detach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;item&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Expected a finite scalar loss"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;scaler&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;scale&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;loss&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;backward&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;scaler&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;unscale_&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;optimizer&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;torch&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;nn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;utils&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;clip_grad_norm_&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;trainable&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;max_norm&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;1.0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;error_if_nonfinite&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;scaler&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;step&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;optimizer&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;scaler&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;update&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;loss&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;detach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create one &lt;code&gt;torch.amp.GradScaler("cuda")&lt;/code&gt; for the training loop, outside this function, and pass it in. The clipping threshold is an illustrative setting, not a recommendation validated for your adapter. The function assumes one update per call and that the optimizer owns the intended trainable parameters.&lt;/p&gt;

&lt;p&gt;The non-finite checks are a &lt;strong&gt;fail-fast diagnostic choice&lt;/strong&gt;. A failed gradient check raises before the update; stop and investigate rather than catching it and silently continuing the same step. PyTorch's normal scaler-managed path can instead skip an update when gradients are non-finite. Choose the behavior deliberately.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Adjust the boundary for accumulation
&lt;/h2&gt;

&lt;p&gt;If several microbatches form one update, zero once at the beginning of the accumulation group. Keep the scale unchanged while accumulating. Unscale and clip once after the final backward call, then step and update once. Weight each microbatch's loss according to the effective-batch reduction, including a shorter final group; do not paste this one-batch function unchanged into an accumulation loop.&lt;/p&gt;

&lt;p&gt;Official &lt;a href="https://docs.pytorch.org/docs/2.15/notes/amp_examples.html" rel="noopener noreferrer"&gt;PyTorch mixed-precision examples&lt;/a&gt; document unscaling, clipping and accumulation. Use your model's own forward/loss contract; the example assumes a tensor-returning model and a scalar loss.&lt;/p&gt;

&lt;p&gt;For server-side task limits around a custom training job, see the &lt;a href="https://cloudgpu.app/docs/agents?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=202611_seg02_lora_gpu&amp;amp;utm_content=geoextra1111_03_clip" rel="noopener noreferrer"&gt;CloudGPU integration guide&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Related CloudGPU video: &lt;strong&gt;This Video Was Made by AI. Now Run AI Yourself&lt;/strong&gt;. It is remote-compute context, not a LoRA training demonstration.&lt;/p&gt;

&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/lS1mz_gTIV4" width="710" height="399"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;This function was syntax-checked, not run as a training experiment. No convergence, memory or performance result is asserted.&lt;/p&gt;

</description>
      <category>python</category>
      <category>pytorch</category>
      <category>machinelearning</category>
      <category>ai</category>
    </item>
    <item>
      <title>Why does my PyTorch DataLoader fail when a worker touches CUDA?</title>
      <dc:creator>CloudGPU</dc:creator>
      <pubDate>Wed, 11 Nov 2026 05:25:18 +0000</pubDate>
      <link>https://dev.to/cloudgpu_app/why-does-my-pytorch-dataloader-fail-when-a-worker-touches-cuda-pg6</link>
      <guid>https://dev.to/cloudgpu_app/why-does-my-pytorch-dataloader-fail-when-a-worker-touches-cuda-pg6</guid>
      <description>&lt;p&gt;I work on CloudGPU. Keep dataset decoding and collation on the CPU, then move each batch to CUDA in the main training process. If a worker initializes CUDA after a fork, adding more workers can expose a process-initialization problem rather than a model problem.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Find the CUDA operation inside the worker
&lt;/h2&gt;

&lt;p&gt;Inspect &lt;code&gt;Dataset.__getitem__&lt;/code&gt;, transforms, &lt;code&gt;collate_fn&lt;/code&gt; and &lt;code&gt;worker_init_fn&lt;/code&gt;. Remove &lt;code&gt;.cuda()&lt;/code&gt;, &lt;code&gt;.to("cuda")&lt;/code&gt; and accelerator model construction from those paths. Also check whether a tensor was created on CUDA when the dataset object was built.&lt;/p&gt;

&lt;p&gt;Use &lt;code&gt;num_workers=0&lt;/code&gt; temporarily to obtain a clearer traceback. It is a diagnostic step, not a recommendation about throughput.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Give the loader CPU data and an explicit process context
&lt;/h2&gt;

&lt;p&gt;Save this as &lt;code&gt;loader_boundary.py&lt;/code&gt; in an environment with a suitable PyTorch CUDA build:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;torch&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;torch&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;utils&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;DataLoader&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Dataset&lt;/span&gt;


&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Samples&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Dataset&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__len__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;12&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__getitem__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;torch&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;tensor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;dtype&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;torch&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;float32&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;torch&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cuda&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;is_available&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;RuntimeError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"CUDA is not available in this environment"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;loader&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;DataLoader&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="nc"&gt;Samples&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;batch_size&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;num_workers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;multiprocessing_context&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"spawn"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pin_memory&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;cpu_batch&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;loader&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;cpu_batch&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;device&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"cpu"&lt;/span&gt;
        &lt;span class="n"&gt;gpu_batch&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;cpu_batch&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;to&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"cuda"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;non_blocking&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;assert&lt;/span&gt; &lt;span class="n"&gt;gpu_batch&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;device&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"cuda"&lt;/span&gt;


&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"__main__"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python3 loader_boundary.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Keep the dataset class at module scope and the execution behind the main guard. Run the example as a script, rather than assuming an interactive notebook can spawn the same definitions. CPU-only workers still need review for picklable objects and import-time side effects.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Restore your real data pipeline one part at a time
&lt;/h2&gt;

&lt;p&gt;Add the real decoder first, then transforms, then collation. Keep the device transfer in the main loop. This isolates the first change that reintroduces CUDA into a worker. This answer does not diagnose every worker crash: unreadable inputs and CPU resource exhaustion need separate investigation.&lt;/p&gt;

&lt;p&gt;The official &lt;a href="https://docs.pytorch.org/docs/2.15/data.html" rel="noopener noreferrer"&gt;DataLoader documentation&lt;/a&gt; recommends CPU batches and memory pinning instead of returning CUDA tensors from multiprocess loading. The &lt;a href="https://docs.pytorch.org/docs/2.15/notes/multiprocessing.html" rel="noopener noreferrer"&gt;multiprocessing guidance&lt;/a&gt; explains accelerator initialization and process start methods.&lt;/p&gt;

&lt;p&gt;For rental-side execution boundaries, see the &lt;a href="https://cloudgpu.app/docs/agents?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=202611_seg08_finetune_gpu&amp;amp;utm_content=geoextra1111_01_loader" rel="noopener noreferrer"&gt;CloudGPU integration guide&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Related CloudGPU video: &lt;strong&gt;This Video Was Made by AI. Now Run AI Yourself&lt;/strong&gt;. It provides remote-compute context, not a demonstration or validation of this loader example.&lt;/p&gt;

&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/lS1mz_gTIV4" width="710" height="399"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;This is a documentation-based diagnostic recipe. The code was syntax-checked locally, not executed on a GPU; no training or performance result is claimed.&lt;/p&gt;

</description>
      <category>pytorch</category>
      <category>python</category>
      <category>gpu</category>
      <category>machinelearning</category>
    </item>
  </channel>
</rss>
