Cannot load models with miniconda installation

Hello everybody,
I have Windows 10, 32 Gb of memory and 8 CPUs. I’m using Miniconda3.
I have tensorflow and pytorch, and installed huggingface transformers using the following lines:

conda install -c huggingface transformers
conda update --all

It went without a glitch.
But when I tried to import some methods I got an error message.

from transformers import BertTokenizer, TFBertForSequenceClassification

OSError Traceback (most recent call last)
~\miniconda3\lib\site-packages\transformers\utils\import_utils.py in _get_module(self, module_name)
1075 try:
→ 1076 return importlib.import_module(“.” + module_name, self.name)
1077 except Exception as e:

~\miniconda3\lib\importlib_init_.py in import_module(name, package)
126 level += 1
→ 127 return _bootstrap._gcd_import(name[level:], package, level)
128

~\miniconda3\lib\importlib_bootstrap.py in _gcd_import(name, package, level)

~\miniconda3\lib\importlib_bootstrap.py in find_and_load(name, import)

~\miniconda3\lib\importlib_bootstrap.py in find_and_load_unlocked(name, import)

~\miniconda3\lib\importlib_bootstrap.py in _load_unlocked(spec)

~\miniconda3\lib\importlib_bootstrap_external.py in exec_module(self, module)

~\miniconda3\lib\importlib_bootstrap.py in _call_with_frames_removed(f, *args, **kwds)

~\miniconda3\lib\site-packages\transformers\models\bert\modeling_bert.py in
24
—> 25 import torch
26 import torch.utils.checkpoint

~\miniconda3\lib\site-packages\torch_init_.py in
123 err.strerror += f’ Error loading “{dll}” or one of its dependencies.’
→ 124 raise err
125 elif res is not None:

OSError: [WinError 182] The operating system cannot run %1. Error loading “C:\Users\mathe\miniconda3\lib\site-packages\torch\lib\caffe2_detectron_ops.dll” or one of its dependencies.

The above exception was the direct cause of the following exception:

RuntimeError Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_15348\3250769049.py in
1 import tensorflow as tf
2 import pandas as pd
----> 3 from transformers import BertConfig, BertModel

~\miniconda3\lib\importlib_bootstrap.py in handle_fromlist(module, fromlist, import, recursive)

~\miniconda3\lib\site-packages\transformers\utils\import_utils.py in getattr(self, name)
1065 elif name in self._class_to_module.keys():
1066 module = self._get_module(self._class_to_module[name])
→ 1067 value = getattr(module, name)
1068 else:
1069 raise AttributeError(f"module {self.name} has no attribute {name}")

~\miniconda3\lib\site-packages\transformers\utils\import_utils.py in getattr(self, name)
1064 value = self._get_module(name)
1065 elif name in self._class_to_module.keys():
→ 1066 module = self._get_module(self._class_to_module[name])
1067 value = getattr(module, name)
1068 else:

~\miniconda3\lib\site-packages\transformers\utils\import_utils.py in _get_module(self, module_name)
1076 return importlib.import_module(“.” + module_name, self.name)
1077 except Exception as e:
→ 1078 raise RuntimeError(
1079 f"Failed to import {self.name}.{module_name} because of the following error (look up to see its"
1080 f" traceback):\n{e}"

RuntimeError: Failed to import transformers.models.bert.modeling_bert because of the following error (look up to see its traceback):
[WinError 182] The operating system cannot run %1. Error loading “C:\Users\my_name\miniconda3\lib\site-packages\torch\lib\caffe2_detectron_ops.dll” or one of its dependencies.

Something appears to be missing.
I will appreciate your help,
Mya

1 Like