Can't import Pipeline from Transformers

I have to work on GPT Neo model and generate text output by asking some questions (automotive related). I am doing NLP related work for first time.

I am using Jupyter notebook and have installed pytorch, and transformers. But I am unable to import Pipeline to further write prompts.

I have tried installing the latest version of pytorch and transformers as well as tried to work with older version of transformers as well

!pip install transformers

OR

!pip install transformers==4.44.1

OR

!pip install transformers==4.28.0

Here’s the error.

[WINERROR126]: The specific module could not be found.



OSError Traceback (most recent call last)
Cell In[5], line 1
----> 1 from transformers import pipeline

File ~\anaconda3\Lib\site-packages\transformers_init_.py:26
23 from typing import TYPE_CHECKING
25 # Check the dependencies satisfy the minimal versions required.
—> 26 from . import dependency_versions_check
27 from .utils import (
28 OptionalDependencyNotAvailable,
29 _LazyModule,
(…)
48 logging,
49 )
52 logger = logging.get_logger(name) # pylint: disable=invalid-name

File ~\anaconda3\Lib\site-packages\transformers\dependency_versions_check.py:16
1 # Copyright 2020 The HuggingFace Team. All rights reserved.
2 #
3 # Licensed under the Apache License, Version 2.0 (the “License”);
(…)
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 from .dependency_versions_table import deps
—> 16 from .utils.versions import require_version, require_version_core
19 # define which module versions we always want to check at run time
20 # (usually the ones defined in install_requires in setup.py)
21 #
22 # order specific notes:
23 # - tqdm must be checked before tokenizers
25 pkgs_to_check_at_runtime = [
26 “python”,
27 “tqdm”,
(…)
37 “pyyaml”,
38 ]

File ~\anaconda3\Lib\site-packages\transformers\utils_init_.py:34
25 from .constants import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD, IMAGENET_STANDARD_MEAN, IMAGENET_STANDARD_STD
26 from .doc import (
27 add_code_sample_docstrings,
28 add_end_docstrings,
(…)
32 replace_return_docstrings,
33 )
—> 34 from .generic import (
35 ContextManagers,
36 ExplicitEnum,
37 ModelOutput,
38 PaddingStrategy,
39 TensorType,
40 add_model_info_to_auto_map,
41 add_model_info_to_custom_pipelines,
42 cached_property,
43 can_return_loss,
44 expand_dims,
45 filter_out_non_signature_kwargs,
46 find_labels,
47 flatten_dict,
48 infer_framework,
49 is_jax_tensor,
50 is_numpy_array,
51 is_tensor,
52 is_tf_symbolic_tensor,
53 is_tf_tensor,
54 is_torch_device,
55 is_torch_dtype,
56 is_torch_tensor,
57 reshape,
58 squeeze,
59 strtobool,
60 tensor_size,
61 to_numpy,
62 to_py_obj,
63 torch_float,
64 torch_int,
65 transpose,
66 working_or_temp_dir,
67 )
68 from .hub import (
69 CLOUDFRONT_DISTRIB_PREFIX,
70 HF_MODULES_CACHE,
(…)
96 try_to_load_from_cache,
97 )
98 from .import_utils import (
99 ACCELERATE_MIN_VERSION,
100 ENV_VARS_TRUE_AND_AUTO_VALUES,
(…)
219 torch_only_method,
220 )

File ~\anaconda3\Lib\site-packages\transformers\utils\generic.py:462
458 return tuple(self[k] for k in self.keys())
461 if is_torch_available():
→ 462 import torch.utils._pytree as _torch_pytree
464 def _model_output_flatten(output: ModelOutput) → Tuple[List[Any], “_torch_pytree.Context”]:
465 return list(output.values()), list(output.keys())

File ~\anaconda3\Lib\site-packages\torch_init_.py:148
146 err = ctypes.WinError(ctypes.get_last_error())
147 err.strerror += f’ Error loading “{dll}” or one of its dependencies.’
→ 148 raise err
150 kernel32.SetErrorMode(prev_error_mode)
153 def _preload_cuda_deps(lib_folder, lib_name):

OSError: [WinError 126] The specified module could not be found. Error loading “C:\Users\aalek\anaconda3\Lib\site-packages\torch\lib\fbgemm.dll” or one of its dependencies.

If you haven’t seen yet, please check Failed to import pytorch fbgemm.dll or one of its dependencies is missing - windows - PyTorch Forums.