Installing transformers library

Hello everyone,
I’m encountering an issue with PyTorch on my Windows system, and I’m hoping someone here can help me resolve it.

I tried to run a simple script using the transformers library with PyTorch, but I keep getting the following error:

OSError: [WinError 126] Das angegebene Modul wurde nicht gefunden. Error loading “C:\Users\roman.vscode\BMA\Code.env\Lib\site-packages\torch\lib\fbgemm.dll” or one of its dependencies.

Steps I’ve Tried

Reinstalled PyTorch:
I uninstalled and reinstalled PyTorch using the following command:

pip uninstall torch
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu

Administrator Mode: I ran PowerShell as an administrator and tried creating the virtual environment and reinstalling everything, but the problem persists.

System Information:

Operating System: Windows 11 64-bit
Python Version: 3.11.9
PyTorch Version: Latest CPU version from the official PyTorch website
Virtual Environment: Created using python -m venv .env

I’m stuck and not sure what else to try. Has anyone encountered this issue before, or does anyone have suggestions on how to resolve this? Any advice or troubleshooting tips would be greatly appreciated!

Thanks in advance for your help!

Try this.

python -m pip install torch==2.1.2 torchvision==0.16.2 torchaudio==2.1.2 --index-url https://download.pytorch.org/whl/cu118

Source (sorry in Japanese)

The error you’re encountering is often caused by missing system dependencies, such as the Microsoft Visual C++ Redistributable. Try installing or updating the DGME latest version of this package, restart your system, and then run your script again. Also, ensure that your Python and PyTorch versions are compatible, as version mismatches can lead to issues with loading DLLs like fbgemm.dll.