pyscf / gpu4pyscf

A plugin to use Nvidia GPU in PySCF package
GNU General Public License v3.0
106 stars 18 forks source link

TypeError: only integer scalar arrays can be converted to a scalar index #169

Closed ananthakrishnagopal closed 4 weeks ago

ananthakrishnagopal commented 4 weeks ago

Hello,

If I try to run the example codes, say for example "00-h2o.py" . I endup with an error that says

File "~/quantum_chemistry/lib/python3.10/site-packages/gpu4pyscf/dft/numint.py", line 1992, in <listcomp> ao_idx = np.hstack([ao_idx[i] for i in sorted_idx]) TypeError: only integer scalar arrays can be converted to a scalar index

The same error comes up even if I try to run scf - rhf/uhf codes as well.

I'm using gpu4pyscf-cuda11x

wxj6000 commented 4 weeks ago

I am not able to reproduce the issue. Could you please post full error message? Could you also post the gpu4pyscf, pyscf, cupy versions? Your error message seems to be for DFT only. It is pretty weird.

cvsik commented 4 weeks ago

Could be related to numpy version 2.0?

ananthakrishnagopal commented 4 weeks ago

gpu4pyscf-cuda11x==0.7.9 gpu4pyscf-libxc-cuda11x==0.4 pyscf==2.5.0 numpy==2.0.0 cupy-cuda11x==13.2.0 These are the versions of gpu4pyscf,numpy,pyscf,cupy.

Traceback (most recent call last): File "~/quantum_chemistry/src/df_gpu.py", line 1087, in <module> mf.kernel() File "~/quantum_chemistry/lib/python3.10/site-packages/gpu4pyscf/scf/hf.py", line 507, in scf _kernel(mf, mf.conv_tol, mf.conv_tol_grad, File "~/quantum_chemistry/lib/python3.10/site-packages/gpu4pyscf/scf/hf.py", line 406, in _kernel vhf = mf.get_veff(mol, dm) File "~/quantum_chemistry/lib/python3.10/site-packages/gpu4pyscf/scf/hf.py", line 312, in get_veff vj, vk = mf.get_jk(mol, dm, hermi) File "~/quantum_chemistry/lib/python3.10/site-packages/gpu4pyscf/scf/hf.py", line 272, in _get_jk vhfopt.build(mf.direct_scf_tol) File "~/quantum_chemistry/lib/python3.10/site-packages/gpu4pyscf/scf/hf.py", line 759, in build ao_idx = np.hstack([ao_idx[i] for i in sorted_idx]) File "~/quantum_chemistry/lib/python3.10/site-packages/gpu4pyscf/scf/hf.py", line 759, in <listcomp> ao_idx = np.hstack([ao_idx[i] for i in sorted_idx]) TypeError: only integer scalar arrays can be converted to a scalar index

Using a different piece of code to show the error in the scf case.

cvsik commented 4 weeks ago

My money is on numpy=2.0.0, try running with numpy<2 installed 😃

ananthakrishnagopal commented 4 weeks ago

Used numpy==1.26.4, it's working now. Thanks! @wxj6000 @cvsik .