← Back to list

Pytorch Error — fbgemm.dll failing to load

While installing and importing pytorch on Windows 11, sometimes you might get a dependency error. Now this will only happen if you are…

Piyush Shukla · 2024-10-19 09:48 · 1 claps · 2.8 min read
#python #pytorch #fbgemm #import-torch
Open on Medium ↗
Wiki topics: ML · Machine Learning

Pytorch Error — fbgemm.dll failing to load

While installing and importing pytorch on Windows 11, sometimes you might get a dependency error. Now this will only happen if you are installing a specific version of pytorch. In my case it was 2.4.0. This problem is probably fixed in the versions starting from 2.4.1, but if not, the below guide should help you a little.

In my case, the error indicated that there is a dll file — fbgemm.dll — which is failing to load.

Luckily there is a way to solve this problem within Python itself but you will need to install another package.

You will need to install a package called ‘dll-diagnostics’.

(Note — there are few other ways out there that can get the job done. I just wanted to stay with Python as long as I could).

It is available on https://pypi.org/project/dll-diagnostics/ but the latest version is updated only till 2021. However, this worked for my version of Python (3.12.6).

So install ‘dll-diagnostics’ –

pip install dll-diagnostics

Once installed, run the ‘dlldiag deps’ command pointing to the dll file which was failing to load (fbgemm.dll) in my case.

dlldiag deps .\llmenv\Lib\site-packages\torch\lib\fbgemm.dll

From the attached screenshot of the command output, you can clearly see that file fbgemm.dll has a dependency on another file libomp140.x86_64.dll which is missing.

Now to get this file, where it needs to be (C:\Windows\System32\ folder) we need to install MS Visual C++ redistributable. So, to resolve this, we will install Visual Studio community Edition.

To do that, follow the following steps —

  1. Simply go to — Download Visual Studio Tools — Install Free for Windows, Mac, Linux (microsoft.com).
  2. Download & Visual Studio Community Edition setup exe (VisualStudioSetup.exe).
  3. Once you run the setup file, it will download the Visual Studio installer.
  4. Once that is done, you will have a Visual Studio installer screen which will install the Visual Studio Core Editor by default.
  5. At this point, do not click ‘Install’ yet. Go to the Individual Component screen.
  6. Search for ‘latest’ and then look for the latest MSVC x64/x86 build tools under the ‘Compilers, build tools, and runtimes’ section, like shown in the screenshot below.

If you are looking at this article somewhere in the distant future, you could search for the latest distribution at that time.

Now go ahead and install.

OK that should do it!

Close your PowerShell/CMD and open it again. Get to your python virtual environment (if you have setup one) and then just run the dependency command again.

dlldiag deps .\llmenv\Lib\site-packages\torch\lib\fbgemm.dll

You can see that the error is resolved and the dependency now is complete.

There one other weird bit, that you may want to check before you test pytorch import. Which is the dependency of pytorch 2.4.0 on numpy which is based on version 1.x

So if you have an older numpy installed (something like pip install numpy==1.26.4), you should be good to check pytorch import.

Alright, till next time!


메타데이터
post_id
0c062da9ccd5
slug
pytorch-error-fbgemm-dll-failing-to-load-0c062da9ccd5
url
https://medium.com/@shukclaw/pytorch-error-fbgemm-dll-failing-to-load-0c062da9ccd5
canonical_url
https://medium.com/@shukclaw/pytorch-error-fbgemm-dll-failing-to-load-0c062da9ccd5
author_url
https://medium.com/@shukclaw
status
ok
fetched_at
2026-07-22 11:47:57