Failed to import pytorch fbgemm.dll or one of its dependencies is missing

Anime_Lover: <p>I have created a virtual environment using<br>
<code>python -m venv .</code><br>
I don’t have a Cuda GPU, so I selected the <code>CPU</code> option from the installation which was:<br>
<code>pip3 install torch torchvision torchaudio</code></p>
<p>when I tried to import torch I got the below error:</p>
<p>(ali) C:\Users\pc\ali&gt;python<br>
Python 3.11.5 (tags/v3.11.5:cce6ba9, Aug 24 2023, 14:38:34) [MSC v.1936 64 bit (AMD64)] on win32<br>
Type “help”, “copyright”, “credits” or “license” for more information.</p>
<blockquote>
<blockquote>
<blockquote>
<p>import torch<br>
Traceback (most recent call last):<br>
File “”, line 1, in <br>
File “C:\Users\pc\ali\Lib\site-packages\torch_<em>init</em>_.py”, line 141, in <br>
raise err<br>
OSError: [WinError 126] The specified module could not be found. Error loading “C:\Users\pc\ali\Lib\site-packages\torch\lib\fbgemm.dll” or one of its dependencies.</p>
</blockquote>
</blockquote>
</blockquote>
<p>So I did this:<br>
<code>pip uninstall torch</code><br>
and then tried from online resources the following:<br>
<code>pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cpu</code><br>
and still the same problem happens.</p>
<p>It is probably worth mentioning, I checked that <code>fbgemm.dll</code> is actually there and so it is probably one of its dependencies that is missing. I tried viewing them (on my friends machine where the installation worked with no issues) in Dependency walker and here is the photo I found on his:<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/1/e/1e987e8d44ebe66b184e306c3db70e86650e0787.png" data-download-href="https://discuss.pytorch.org/uploads/default/1e987e8d44ebe66b184e306c3db70e86650e0787" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/1/e/1e987e8d44ebe66b184e306c3db70e86650e0787_2_690x293.png" alt="image" data-base62-sha1="4mF2Ar2gQn2J2LcL7op7ZuzaM7R" width="690" height="293" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/1/e/1e987e8d44ebe66b184e306c3db70e86650e0787_2_690x293.png, https://discuss.pytorch.org/uploads/default/optimized/3X/1/e/1e987e8d44ebe66b184e306c3db70e86650e0787_2_1035x439.png 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/1/e/1e987e8d44ebe66b184e306c3db70e86650e0787_2_1380x586.png 2x" data-dominant-color="E7E5E8"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">1408×599 207 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>
<p>from googling these seems to be MSVC/C++ runtime dependencies? is it required that I install some C++ stuff?</p>

frobnicat: <p>I had the same issue with fbgemm.dll when trying to run a ComfyUI session after following <a href="https://www.comflowy.com/preparation-for-study/install" rel="noopener nofollow ugc">comflowy CLI procedure for installation</a>, when invoking   python main.py</p>
<p>Thank you for mentioning the idea of checking for fbgemm.dll with dedicated tool, this unlocked my situation but dependency walker dates back 2006, since then dll have changed and a more modern tool is required, found <a href="https://github.com/lucasg/Dependencies" rel="noopener nofollow ugc">lucasg dependencies</a>. This latest tool shows only one missing dependency to fbgemm.dll in my windows setup and that was <strong>libomp140.x86_64.dll</strong></p>
<p>Since it is distributed with visual studio (not visual studio code) I installed visual studio community edition and libomp140.x86_64.dll was now put in both the visual studio program files and in C:\Windows\System32\ ie. in the Path. Now the ComfyUI main.py script runs fine on my system. Hope this helps.</p>

farhan_karim: <p>install VC_redist.X64 - 14.29.30153 it will solve the fbgemm.dll problem.</p>

Zhiwen_Zheng: <p>Thanks, really useful!</p>

diegocr: <p>Is that specific version required? coz i do have 14.40.33810 and same issue happens, i think libomp* is (no longer) shipped with it (?) and not very keen to downgrade it.</p>

nano1: <p>thanks，it is working</p>

GKay: <p>Thank you! It worked for me.</p>

GKay: <p>The world needs guy like you! Ty</p>

Ishan_Sharma: <p>where can i download this?</p>

denglj: <p>Thanks, frobnicat! The DLL fix worked perfectly!</p>

MichaelSzczepaniak: <p><a href="https://www.microsoft.com/en-US/download/details.aspx?id=48145&amp;lt" class="onebox" target="_blank" rel="noopener nofollow ugc">https://www.microsoft.com/en-US/download/details.aspx?id=48145&amp;lt</a></p>

Forrest_Hu: <p>downloaded the latest version14.40.33810.0 from Microsoft site <a href="https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170" rel="noopener nofollow ugc">Latest supported Visual C++ Redistributable downloads | Microsoft Learn</a>. It resolves the issue. many thanks.</p>

Syr: <p>Thank you! It works!</p>

roblox_guard: <p>you are a saviour! thanks</p>

roblox_guard: <p>in case if you dont want to download visual studio. <a href="https://www.dllme.com/dll/files/libomp140_x86_64?sort=upload&amp;arch=0x8664" rel="noopener nofollow ugc">https://www.dllme.com/dll/files/libomp140_x86_64?sort=upload&amp;arch=0x8664</a> you can just download this dll and place it in windows/system32 directory. it works as well too</p>

Boran123: <p>thanks！！！u really help me</p>

xianyang_ao: <p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/2/4/242e0e5ac28c86c334d5351b2db05b649bf1c9f6.png" data-download-href="https://discuss.pytorch.org/uploads/default/242e0e5ac28c86c334d5351b2db05b649bf1c9f6" title="image"><img src="https://discuss.pytorch.org/uploads/default/original/3X/2/4/242e0e5ac28c86c334d5351b2db05b649bf1c9f6.png" alt="image" data-base62-sha1="5a3RxJUJLH76LDoK7ja8zNvcRVA" width="690" height="151" data-dominant-color="E2E2E5"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">1369×301 33 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div><br>
I have downloaded VC_redist.X64 - 14.29.30153, but the problem has not been solved. Are there any requirements for the folder?</p>

LI_LEXUN: <p>I have a better way to solve this problem, reply me if u still not solve.</p>

nlane: <p>I did this, though I got the exact same error when trying to run the code again. Is this a foolproof method or might there have been something wrong that I did?</p>

LI_LEXUN: <p>Do u still have the problem?</p>