Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: DLL load failed while importing segmented_maxsim_cpp: The specified module could not be found. #128

Closed
niyaz006 opened this issue Feb 11, 2024 · 1 comment
Labels

Comments

@niyaz006
Copy link

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[4], line 3
      1 from ragatouille import RAGPretrainedModel
----> 3 RAG = RAGPretrainedModel.from_pretrained("colbert-ir/colbertv2.0")

File d:\Users\<User>\Anaconda3\envs\rag2\lib\site-packages\ragatouille\RAGPretrainedModel.py:71, in RAGPretrainedModel.from_pretrained(cls, pretrained_model_name_or_path, n_gpu, verbose, index_root)
     59 """Load a ColBERT model from a pre-trained checkpoint.
     60 
     61 Parameters:
   (...)
     68     cls (RAGPretrainedModel): The current instance of RAGPretrainedModel, with the model initialised.
     69 """
     70 instance = cls()
---> 71 instance.model = ColBERT(
     72     pretrained_model_name_or_path, n_gpu, index_root=index_root, verbose=verbose
     73 )
     74 return instance

File d:\Users\<User>\Anaconda3\envs\rag2\lib\site-packages\ragatouille\models\colbert.py:101, in ColBERT.__init__(self, pretrained_model_name_or_path, n_gpu, index_name, verbose, load_from_index, training_mode, index_root, **kwargs)
     98     self.config.root = ".ragatouille/"
    100 if not training_mode:
--> 101     self.inference_ckpt = Checkpoint(
    102         self.checkpoint, colbert_config=self.config
    103     )
    105 self.run_context = Run().context(self.run_config)
    106 self.run_context.__enter__()  # Manually enter the context

File d:\Users\<User>\Anaconda3\envs\rag2\lib\site-packages\colbert\modeling\checkpoint.py:19, in Checkpoint.__init__(self, name, colbert_config, verbose)
     18 def __init__(self, name, colbert_config=None, verbose:int = 3):
---> 19     super().__init__(name, colbert_config)
     20     assert self.training is False
     22     self.verbose = verbose

File d:\Users\<User>\Anaconda3\envs\rag2\lib\site-packages\colbert\modeling\colbert.py:24, in ColBERT.__init__(self, name, colbert_config)
     21 super().__init__(name, colbert_config)
     22 self.use_gpu = colbert_config.total_visible_gpus > 0
---> 24 ColBERT.try_load_torch_extensions(self.use_gpu)
     26 if self.colbert_config.mask_punctuation:
     27     self.skiplist = {w: True
     28                      for symbol in string.punctuation
     29                      for w in [symbol, self.raw_tokenizer.encode(symbol, add_special_tokens=False)[0]]}

File d:\Users\<User>\Anaconda3\envs\rag2\lib\site-packages\colbert\modeling\colbert.py:39, in ColBERT.try_load_torch_extensions(cls, use_gpu)
     36     return
     38 print_message(f"Loading segmented_maxsim_cpp extension (set COLBERT_LOAD_TORCH_EXTENSION_VERBOSE=True for more info)...")
---> 39 segmented_maxsim_cpp = load(
     40     name="segmented_maxsim_cpp",
     41     sources=[
     42         os.path.join(
     43             pathlib.Path(__file__).parent.resolve(), "segmented_maxsim.cpp"
     44         ),
     45     ],
     46     extra_cflags=["-O3"],
     47     verbose=os.getenv("COLBERT_LOAD_TORCH_EXTENSION_VERBOSE", "False") == "True",
     48 )
     49 cls.segmented_maxsim = segmented_maxsim_cpp.segmented_maxsim_cpp
     51 cls.loaded_extensions = True

File d:\Users\<User>\Anaconda3\envs\rag2\lib\site-packages\torch\utils\cpp_extension.py:1306, in load(name, sources, extra_cflags, extra_cuda_cflags, extra_ldflags, extra_include_paths, build_directory, verbose, with_cuda, is_python_module, is_standalone, keep_intermediates)
   1214 def load(name,
   1215          sources: Union[str, List[str]],
   1216          extra_cflags=None,
   (...)
   1224          is_standalone=False,
   1225          keep_intermediates=True):
   1226     """
   1227     Load a PyTorch C++ extension just-in-time (JIT).
   1228 
   (...)
   1304         ...     verbose=True)
   1305     """
-> 1306     return _jit_compile(
   1307         name,
   1308         [sources] if isinstance(sources, str) else sources,
   1309         extra_cflags,
   1310         extra_cuda_cflags,
   1311         extra_ldflags,
   1312         extra_include_paths,
   1313         build_directory or _get_build_directory(name, verbose),
   1314         verbose,
   1315         with_cuda,
   1316         is_python_module,
   1317         is_standalone,
   1318         keep_intermediates=keep_intermediates)

File d:\Users\<User>\Anaconda3\envs\rag2\lib\site-packages\torch\utils\cpp_extension.py:1736, in _jit_compile(name, sources, extra_cflags, extra_cuda_cflags, extra_ldflags, extra_include_paths, build_directory, verbose, with_cuda, is_python_module, is_standalone, keep_intermediates)
   1733 if is_standalone:
   1734     return _get_exec_path(name, build_directory)
-> 1736 return _import_module_from_library(name, build_directory, is_python_module)

File d:\Users\<User>\Anaconda3\envs\rag2\lib\site-packages\torch\utils\cpp_extension.py:2132, in _import_module_from_library(module_name, path, is_python_module)
   2130 spec = importlib.util.spec_from_file_location(module_name, filepath)
   2131 assert spec is not None
-> 2132 module = importlib.util.module_from_spec(spec)
   2133 assert isinstance(spec.loader, importlib.abc.Loader)
   2134 spec.loader.exec_module(module)

File <frozen importlib._bootstrap>:565, in module_from_spec(spec)

File <frozen importlib._bootstrap_external>:1173, in create_module(self, spec)

File <frozen importlib._bootstrap>:228, in _call_with_frames_removed(f, *args, **kwds)

ImportError: DLL load failed while importing segmented_maxsim_cpp: The specified module could not be found.
@bclavie
Copy link
Owner

bclavie commented Feb 11, 2024

Hey, this is a Windows-related issue. We don't currently guarantee Windows support but users are reporting that it runs fine in WSL2 in most cases! This specific error seems to be some sort of C++-related problem where it can't properly load what it needs to import the custom C++ code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants