Hello,
I have an issue regarding the dataloader of dgl. First of all, I want to mentionned that I tried to fix all the seeds with :
def fix_seed(seed):
'''
Args :
seed : value of the seed
Function which allows to fix all the seed and get reproducible results
'''
torch.manual_seed(seed)
np.random.seed(seed)
random.seed(seed)
os.environ['PYTHONHASHSEED'] = str(seed)
dgl.seed(seed)
dgl.random.seed(seed)
torch.cuda.manual_seed(seed)
torch.cuda.manual_seed_all(seed)
torch.backends.cudnn.benchmark = False
torch.use_deterministic_algorithms(True)
os.environ['OMP_NUM_THREADS'] = '1'
os.environ['MKL_NUM_THREADS'] = '1'
torch.set_num_threads(1)
But it does not work.
My issue is when I am restarting my kernel, the dataloader that I create does not sample the same block. For the first time, I’ll have the following block :
And then, I restart my kernel and I have the following output:
You can see that the first block is different. This change does not appear when I do not kill my kernel before re-running it. It also seems that, sometimes when I restart my kernel, I fall back on a previous result. But it is not stable.
Could you please help me ?
Thanks
PS :Here is my full code
seed = 10
sampled_neigh = [15, 5]
batch_size = 256
fix_seed(seed)
sampler = dgl.dataloading.MultiLayerNeighborSampler(sampled_neigh)
dataloader = dgl.dataloading.DataLoader(
graph = g, # the graph
indices = train_mask, # The node IDs to iterate over in minibatches
graph_sampler = sampler, # the neighbor sampler -> how we will sample train_mask neighborhood
batch_size = batch_size, # size of the batch
shuffle = True, # wether to shuffle or not at each batch
drop_last = False, # wether to keep or to drop the last incomplete batch,
num_workers = 0
)
for batch in dataloader:
print(batch)
break