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

Hello, I had the fbgemm.dll or one of its dependencies is missing error, and I just fixed it. I tried the vc_redist reinstallation, downloading vscommunity, and nothing worked.

What worked for me is this:

  1. Install miniconda
  2. Add the folder miniconda and miniconda/Scripts to the user PATH
  3. Check your python version // In my case 3.12.2
  4. conda create -n my_environment python=3.12.2
  5. conda activate my_environment
  6. conda install pytorch torchvision torchaudio pytorch-cuda=11.8 -c pytorch -c nvidia //Because previusly I had installed CUDA Toolkit 11.8 Downloads | NVIDIA Developer
  7. conda install -c conda-forge librosa pandas numpy

And then I tried the following code:
// testTorch.py

import torch

def verificar_torch():
try:
print(“Torch importado exitosamente”)
# Crear un tensor simple para verificar funcionalidad básica
tensor = torch.tensor([1.0, 2.0, 3.0])
print(f"Tensor creado: {tensor}“)
return True
except Exception as e:
print(f"Error al importar torch o al crear un tensor: {e}”)
return False

if name == “main”:
verificar_torch()

And it worked. I hope this helps you.

4 Likes