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

SDV fails to load trained model #2362

Open
celsofranssa opened this issue Jan 30, 2025 · 1 comment
Open

SDV fails to load trained model #2362

celsofranssa opened this issue Jan 30, 2025 · 1 comment
Assignees
Labels
bug Something isn't working under discussion Issue is currently being discussed

Comments

@celsofranssa
Copy link

Environment Details

  • SDV version: 1.17.2
  • Python version: 3.10.12
  • Operating System: Ubuntu 22.04.1 LTS

Error Description

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[21], line 3
      1 from sdv.single_table import CTGANSynthesizer
----> 3 synthesizer = CTGANSynthesizer.load(
      4     filepath='synthesizer.pkl'
      5 )

File opt/project/venv/lib/python3.10/site-packages/sdv/single_table/base.py:568, in BaseSynthesizer.load(cls, filepath)
    566 with open(filepath, 'rb') as f:
    567     try:
--> 568         synthesizer = cloudpickle.load(f)
    569     except RuntimeError as e:
    570         err_msg = (
    571             'Attempting to deserialize object on a CUDA device but '
    572             'torch.cuda.is_available() is False. If you are running on a CPU-only machine,'
    573             " please use torch.load with map_location=torch.device('cpu') "
    574             'to map your storages to the CPU.'
    575         )

File opt/project/venv/lib/python3.10/site-packages/numpy/random/_pickle.py:34, in __bit_generator_ctor(bit_generator_name)
     32     bit_generator = BitGenerators[bit_generator_name]
     33 else:
---> 34     raise ValueError(str(bit_generator_name) + ' is not a known '
     35                                                'BitGenerator module.')
     37 return bit_generator()

ValueError: <class 'numpy.random._mt19937.MT19937'> is not a known BitGenerator module.

Steps to reproduce

from sdv.single_table import CTGANSynthesizer
synthesizer = CTGANSynthesizer.load('synthesizer .pkl'
# import torch
# torch.cuda.is_available()
# returns True
)
@celsofranssa celsofranssa added bug Something isn't working new Automatic label applied to new issues labels Jan 30, 2025
@srinify
Copy link
Contributor

srinify commented Jan 31, 2025

Hi there @celsofranssa 👋

Based on the error message, there might be something different about the environment used to train (and export) the synthesizer and the environment used to load and utilize the synthesizer. Specifically, it seems like the NumPy versions may be different in some incompatible way.

  1. First, I'm curious if the environments were in fact different or if I'm wrong :)

    • If so - do you mind sharing the differences in library versions? If you use pip, you can use pip frezee to get a list of libraries and their versions in both environments.
  2. Is there any chance the model was trained on a device with a GPU but is now being used on a device without a GPU? Some of the error output seems to suggest that might be some difference here in CUDA availability or actual hardware difference between environments.

@srinify srinify removed the new Automatic label applied to new issues label Jan 31, 2025
@srinify srinify self-assigned this Jan 31, 2025
@srinify srinify added the under discussion Issue is currently being discussed label Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working under discussion Issue is currently being discussed
Projects
None yet
Development

No branches or pull requests

2 participants