Reputation: 41
OSError: [WinError 126] The specified module could not be found. Error loading "C:\apps\python\lib\site-packages\torch\lib\fbgemm.dll" or one of its dependencies.
System information:
Operating system: Windows 11 Python version: 3.15 PyTorch version: 2.3.0 I'm not sure what else to try to resolve this issue. Any help or suggestions would be greatly appreciated. Thank you!
I've tried reinstalling PyTorch using pip uninstall and pip install commands, but the issue persists. I've checked my system environment variables and ensured that the paths to Python
Upvotes: 4
Views: 12165
Reputation: 11
Install through conda
torch torchvision torchaudio
Check this https://pytorch.org/get-started/locally/
Install it using conda according to your operating system
conda install pytorch torchvision torchaudio pytorch-cuda=11.8 -c pytorch -c nvidia
conda install pytorch torchvision torchaudio cpuonly -c pytorch
Upvotes: 1
Reputation: 41
I installed pythorch as follows and everything worked well. Installing with pip did not work.
conda install -c pytorch pytorch
Upvotes: 4
Reputation: 335
I was able to resolve this issue and it was related to a missing dependency for:
libomp140.x86_64.dll
I was setting up a clean Windows 11 Pro system and wanted to get the latest and greatest Torch with Cuda 12.4 on there for development. Until I got exactly the error you are mentioning. I tried installing and reinstalling different versions of the C++ redistributables to no avail. I also installed Visual Studio Pro 2022. Nothing would get me that file.
Remedy: Get a copy of libomp140.x86_64.dll and put it in C:\Windows\Sytem32
After I did that, everything started working. For some reason, installing the newest VS and/or C++ redistributables will no longer put that file in there. I got mine from a (slightly) older install that had Visual Studio Pro on it. So, you may need to get it yourself until there is some kind of official fix. Disclaimer: I have no idea if this fix is safe or causes conflicts. Please note those here if you have issues.
Upvotes: 8
Reputation: 21
I've tried several things, including getting the latest MS Visual C++ 2015-2022 Redistributable (x64) - it was the 14.40.33810 at this moment. I'm using CPU - not GPU, so I found an string to use to force the CPU installation of torch (and torchvision):
pip3 install torch==2.3.1+cpu torchvision==0.18.1+cpu -f https://download.pytorch.org/whl/torch_stable.html
No special reason for that torch version, just wanted one compatible with CPU. The one for torchvision is compatible with torch.
Importing torch later worked.
Upvotes: 2