npbench icon indicating copy to clipboard operation
npbench copied to clipboard

AttributeError: 'numpy.random._generator.Generator' object has no attribute 'rand'

Open SuhasSrinivasan opened this issue 2 years ago • 1 comments

This issue occurred when running python run_framework.py -f numpy -p L

OS: Ubuntu 20.04.4 LTS Python: 3.7.13 numpy: 1.19.5

***** Testing NumPy with spmv on the L dataset *****
Process Process-46:
Traceback (most recent call last):
  File "/opt/miniconda3/envs/chrombpnet/lib/python3.7/multiprocessing/process.py", line 297, in _bootstrap
    self.run()
  File "/opt/miniconda3/envs/chrombpnet/lib/python3.7/multiprocessing/process.py", line 99, in run
    self._target(*self._args, **self._kwargs)
  File "run_framework.py", line 18, in run_benchmark
    test.run(preset, validate, repeat, timeout)
  File "/root/npbench/npbench/infrastructure/test.py", line 66, in run
    bdata = self.bench.get_data(preset)
  File "/root/npbench/npbench/infrastructure/benchmark.py", line 68, in get_data
    exec(init_str, data)
  File "<string>", line 1, in <module>
  File "/root/npbench/npbench/benchmarks/spmv/spmv.py", line 19, in initialize
    random_state=rng)
  File "/opt/miniconda3/envs/chrombpnet/lib/python3.7/site-packages/scipy/sparse/construct.py", line 786, in random
    data_rvs = random_state.rand
AttributeError: 'numpy.random._generator.Generator' object has no attribute 'rand'

SuhasSrinivasan avatar May 29 '22 21:05 SuhasSrinivasan

@SuhasSrinivasan thank you for reporting. The issue is caused by a mismatch between the scipy version and numpy version. I was able to reproduce the issue when using scipy 1.3 with numpy 1.19.5. The issue does not occur with scipy 1.7.3, and can be resolved by running pip install --upgrade scipy.

tbennun avatar Jun 06 '22 21:06 tbennun