SDV
SDV copied to clipboard
Confusing warning when using GANs that suggests that CUDA isn't being used
Environment Details
- SDV version: 1.13
- Python version: 3.10.12
- Operating System: Colab (using T4 GPU)
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
- We've ruled out CUDA not being available by running
torch.cuda.is_available(), which returnsTrue. - This warning might be displayed because the CUDA state / context isn't initialized. But we do end up initializing the CUDA context in our code somewhere (which is why running it twice doesn't throw this warning).
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)