sdv-dev / SDV

Synthetic data generation for tabular data
https://docs.sdv.dev/sdv
Other
2.21k stars 287 forks source link

Confusing warning when using GANs that suggests that CUDA isn't being used #2052

Open srinify opened 3 weeks ago

srinify commented 3 weeks ago

Environment Details

Warning

If you try to fit CTGANSynthesizer or CopulaGANSynthesizer in Google Colab with a T4 (GPU) runtime, the following warning is displayed the first time only:

/usr/local/lib/python3.10/dist-packages/torch/autograd/graph.py:744: UserWarning: Attempting to run cuBLAS, but there was no current CUDA context! Attempting to set the primary context... (Triggered internally at ../aten/src/ATen/cuda/CublasHandlePool.cpp:135.)
  return Variable._execution_engine.run_backward(  # Calls into the C++ engine to run the backward pass

So the warning is technically true, but is confusing to users because they may think that the GPU isn't being used.

Steps to reproduce

To reproduce warning, change the Colab runtime to T4 (Runtime > Change runtime type, from Colab menu bar) then run this code:

from sdv.datasets.demo import download_demo
from sdv.single_table import CTGANSynthesizer

data, metadata = download_demo(
    modality='single_table',
    dataset_name='fake_hotel_guests'
)

c = CTGANSynthesizer(metadata, cuda=True)
c.fit(data)

To reproduce CopulaGANSynthesizer, delete / restart your runtime:

from sdv.datasets.demo import download_demo
from sdv.single_table import CopulaGANynthesizer

data, metadata = download_demo(
    modality='single_table',
    dataset_name='fake_hotel_guests'
)

c = CopulaGANynthesizer(metadata, cuda=True)
c.fit(data)

Internal Colab Notebook