<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.9.5">Jekyll</generator><link href="/feed.xml" rel="self" type="application/atom+xml" /><link href="/" rel="alternate" type="text/html" /><updated>2024-06-03T14:54:24+00:00</updated><id>/feed.xml</id><title type="html">Pablo Andres Aguilar Sepulveda</title><subtitle></subtitle><entry><title type="html">Fixing ComfyUI with ROCm on Fedora</title><link href="/post/2024/06/02/rocm-confyui-fix.html" rel="alternate" type="text/html" title="Fixing ComfyUI with ROCm on Fedora" /><published>2024-06-02T16:00:00+00:00</published><updated>2024-06-02T16:00:00+00:00</updated><id>/post/2024/06/02/rocm-confyui-fix</id><content type="html" xml:base="/post/2024/06/02/rocm-confyui-fix.html"><![CDATA[<h2 id="the-problem">The Problem</h2>

<p>The environment variable PYTORCH_HIP_ALLOC_CONF wasn’t modifying the GPU memory allocation effectively.</p>

<h2 id="diagnostic">Diagnostic</h2>

<p>Running the command:</p>

<figure class="highlight"><pre><code class="language-bash" data-lang="bash">watch <span class="nt">-n</span> 1 rocm-smi</code></pre></figure>

<p>showed that VRAM usage was always between 60-70% when using ComfyUI with AnimateDiff after the first pass. Eventually, VRAM usage would hit 100%, causing the system to crash or become unstable.</p>

<h2 id="the-solution">The Solution</h2>

<p>Adding the following code snippet to the main.py file of ComfyUI resolved the issue:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>
import os

os.environ['PYTORCH_HIP_ALLOC_CONF']='garbage_collection_threshold:0.7,max_split_size_mb:128'

</code></pre></div></div>

<p><img src="/images/s1.png" alt="Image" /></p>

<p>Setting the PYTORCH_HIP_ALLOC_CONF environment variable in Python is crucial. Specifically, this configuration does the following:</p>

<p>garbage_collection_threshold: Sets the threshold for garbage collection to 0.7, which is a reasonable value.
max_split_size_mb: Limits the maximum size of memory splits (in megabytes) to prevent excessive fragmentation.</p>

<h2 id="the-result">The Result</h2>

<p>After setting the PYTORCH_HIP_ALLOC_CONF environment variable and restarting the Python script, ComfyUI began working smoothly. There were no more crashes or memory-related issues. The GPU was utilized efficiently, and deep learning tasks ran without hiccups.</p>]]></content><author><name></name></author><category term="post" /><summary type="html"><![CDATA[The Problem]]></summary></entry><entry><title type="html">Welcome to my jungle</title><link href="/first/post/2024/05/30/welcome-to-jekyll.html" rel="alternate" type="text/html" title="Welcome to my jungle" /><published>2024-05-30T21:55:12+00:00</published><updated>2024-05-30T21:55:12+00:00</updated><id>/first/post/2024/05/30/welcome-to-jekyll</id><content type="html" xml:base="/first/post/2024/05/30/welcome-to-jekyll.html"><![CDATA[<p>The intent of this page is to document my ongoing learning journey and experiences in software development and programming. You can think of it as a virtual post-it note where I share updates on my growth and insights gained.</p>]]></content><author><name></name></author><category term="first" /><category term="post" /><summary type="html"><![CDATA[The intent of this page is to document my ongoing learning journey and experiences in software development and programming. You can think of it as a virtual post-it note where I share updates on my growth and insights gained.]]></summary></entry></feed>