question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Problem installing and loading BERTopic on colab

See original GitHub issue

Hi

I trained my models using an HPC server and then I want to explore the trained models. I realised that if a model is trained with GPU, it must be loaded using GPU powered machines (except I can load it and save it as cpu alternative, but that’s the next thing i will try).

I then tried to do this on google colab, I share a colab book here: https://colab.research.google.com/drive/1jCVH4Yy_nE2Y-teyZeNZ8TGWoINp0Xzw?usp=sharing

But I had no luck in installing BERTopic, and then loading the model.

In the part that install other libraries (flair, use, etc), I got some errors that like this

Attempting uninstall: sentence-transformers
    Found existing installation: sentence-transformers 2.2.0
    Uninstalling sentence-transformers-2.2.0:
      Successfully uninstalled sentence-transformers-2.2.0
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
torchtext 0.11.0 requires torch==1.10.0, but you have torch 1.7.0 which is incompatible.
torchaudio 0.10.0+cu111 requires torch==1.10.0, but you have torch 1.7.0 which is incompatible.
markdown 3.3.6 requires importlib-metadata>=4.4; python_version < "3.10", but you have importlib-metadata 3.10.1 which is incompatible.
google-colab 1.0.0 requires requests~=2.23.0, but you have requests 2.27.1 which is incompatible.
datascience 0.10.6 requires folium==0.2.1, but you have folium 0.8.3 which is incompatible.
Successfully installed bpemb-0.3.3 dataclasses-0.6 deprecated-1.2.13 flair-0.7 ftfy-6.1.1 importlib-metadata-3.10.1 janome-0.4.1 konoha-4.6.5 langdetect-1.0.9 mpld3-0.3 overrides-3.1.0 requests-2.27.1 segtok-1.5.11 sentence-transformers-1.2.1 sentencepiece-0.1.91 sqlitedict-1.7.0 tokenizers-0.9.3 torch-1.7.0 torchvision-0.8.1 transformers-3.5.1
WARNING: The following packages were previously imported in this runtime:
  [dataclasses]
You must restart the runtime in order to use newly installed versions.

Then in the code that loads the model, this line topic_model=BERTopic.load(model_folder+"/"+model_file) causes this error:

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
[<ipython-input-1-d0cfacde8768>](https://localhost:8080/#) in <module>()
      7 
      8 #load a trained topic model
----> 9 topic_model=BERTopic.load(model_folder+"/"+model_file)
     10 
     11 #get basic topic info

5 frames
[/usr/local/lib/python3.7/dist-packages/numba/core/serialize.py](https://localhost:8080/#) in _unpickle__CustomPickled(serialized)
    206     Uses `NumbaPickler` to load.
    207     """
--> 208     ctor, states = loads(serialized)
    209     return _CustomPickled(ctor, states)
    210 

ModuleNotFoundError: No module named 'numba.cloudpickle'

Any suggestions would be highly appreciated, thanks!

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
shoegazerstellacommented, Mar 22, 2022

Hi all, I am having this issue in a docker container when trying to load the model.

First thing I did was:

pip3 install --upgrade numba

but doesn’t seem to work. How did you solve it?

0reactions
drob-xxcommented, May 29, 2022

I have the same problem when attempting to load a model. The model in question was created months ago, so I’m wondering if it has to do with a colab/python/package config at the time which has changed and the model is no longer loadable. I’m going to start from scratch.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't load BERTopic model - Stack Overflow
I ran these codes to try in Python 3.7 version. I'm having trouble importing BERTopic. !sudo apt-get update -y !sudo apt-get install python3.7...
Read more >
BERTopic.ipynb - Colaboratory - Google Colab
Restart the Notebook. After installing BERTopic, some packages that were already loaded were updated and in order to correctly use them, we ...
Read more >
bertopic - PyPI
BERTopic. BERTopic is a topic modeling technique that leverages 🤗 transformers and c-TF-IDF to create dense clusters allowing for easily interpretable ...
Read more >
error: could not build wheels for hdbscan, which is required to ...
You can solve this problem by installing python-dev. python3 -m pip install ... Is there, any possible way to load the old BERTopic...
Read more >
Topic Modeling with Deep Learning Using Python BERTopic
Transformer-based NLP topic modeling using the Python package BERTopic: modeling, ... You can ignore the code below if you are not using Google...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found