Node2Vec Sampling - Control randomness

Hello,
I am using the method dgl.sampling.node2vec_random_walk() and I wonder if it is possible to set a random state in order to be able to reproduce the output of the method. The method uses the C++ method _CAPI_DGLSamplingNode2vec(). Since I am not familiar with C++ I am not sure if there exists a functionality to set a random state.

Thank you :slight_smile:

Please try dgl.seed to set the random state.

1 Like

Thank you for your answer! I tried using dgl.seed() but the created random walks are still different in every execution :confused:

Could you further set the environment variable OMP_NUM_THREADS=1 to have a try?

1 Like

Thank you for the hint! Setting the environment variable to OMP_NUM_THREADS=1 and using dgl.seed() worked on Windows :slight_smile:
But with Linux I get an error:
dgl._ffi.base.DGLError: [14:37:55] /opt/dgl/src/random/random.cc:36: Check failed: e == CURAND_STATUS_SUCCESS: CURAND Error: CURAND_STATUS_INITIALIZATION_FAILED at /opt/dgl/src/random/random.cc:36.

Could you provide the following information so we can reproduce and raise a bug in GitHub?

  • DGL Version (e.g., 1.0):
  • Backend Library & Version (e.g., PyTorch 0.4.1, MXNet/Gluon 1.3):
  • OS (e.g., Linux):
  • How you installed DGL (conda, pip, source):
  • Build command you used (if compiling from source):
  • Python version:
  • CUDA/cuDNN version (if applicable):
  • GPU models and configuration (e.g. V100):
  • Any other relevant information:
1 Like

These are the requested information :slight_smile: Thank you!

Enviroment:
DGL Version: 1.0.0.cu116
Backend Library & Version: PyTorch 1.13.1
OS: Linux
How you installed DGL: conda
Python Version: 3.9.15
CUDA Version: 11.6.1
GPU models and configuration: V100-SXM2

The issue is tracked here.

For a temporary workaround, please try Pytorch 1.12 (CUDA 11.3/11.6), which has been tested to work well.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.