MIDASverse / MIDASpy

Python package for missing-data imputation with deep learning
Apache License 2.0
128 stars 36 forks source link

Error with multiple GPUs: Do not use tf.reset_default_graph() to clear nested graphs #19

Open neuro30 opened 2 years ago

neuro30 commented 2 years ago

I am trying to utilize two GPUs with MIDASpy. However, I get the following error during set-up:


from sklearn.preprocessing import MinMaxScaler
import numpy as np
import pandas as pd
import tensorflow as tf
import MIDASpy as md

data_0 = pd.read_csv('/home/comp/Documents/file.txt', sep = "\t")
data_0.columns.str.strip()

data_0 = data_0.set_index('Unnamed: 0')
data_0.index.names = [None]

np.random.seed(441)

na_loc = data_0.isnull()
data_0[na_loc] = np.nan

imputer = md.Midas(layer_structure= [256, 256, 256],
                   learn_rate= 1e-4,
                   input_drop= 0.9,
                   train_batch = 50,
                   savepath= '/home/comp/Documents/save',
                   seed= 89)

strategy = tf.distribute.MirroredStrategy()

with strategy.scope():
imputer.build_model(data_0)

AssertionError: Do not use tf.reset_default_graph() to clear nested graphs. If you need a cleared graph, exit the nesting and create a new graph.
tsrobinson commented 2 years ago

Hi @neuro30, thanks for sharing this. Multi-GPU support is not currently available for MIDASpy unfortunately. You should be able to get single-GPU support working if CUDA is properly configured for tensorflow.

We are considering ways of adding multi-GPU support in the future.