Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some beginner problems #248

Open
steto123 opened this issue Nov 14, 2024 · 6 comments
Open

Some beginner problems #248

steto123 opened this issue Nov 14, 2024 · 6 comments

Comments

@steto123
Copy link

steto123 commented Nov 14, 2024

After succesfully installing cuda, gpu4pscf und cutensor in my jupyter environment on my university hpc cluster i have problems running examples:

/home/sthomas/.conda/envs/myjupyter/lib/python3.10/site-packages/cupy/_environment.py:370: UserWarning: CuPy failed to preload library (/home/sthomas/.conda/envs/myjupyter/lib/python3.10/site-packages/cutensor/lib/libcutensor.so.2): OSError (libcublasLt.so.12: cannot open shared object file: No such file or directory)
warnings.warn(msg)
/home/sthomas/.conda/envs/myjupyter/lib/python3.10/site-packages/gpu4pyscf/lib/cutensor.py:138: UserWarning: using cupy as the tensor contraction engine.
warnings.warn(f'using {contract_engine} as the tensor contraction engine.')

NVRTCError Traceback (most recent call last)
File ~/.conda/envs/myjupyter/lib/python3.10/site-packages/cupy/cuda/compiler.py:692, in _NVRTCProgram.compile(self, options, log_stream)
691 nvrtc.addNameExpression(self.ptr, ker)
--> 692 nvrtc.compileProgram(self.ptr, options)
693 mapping = None

File cupy_backends/cuda/libs/nvrtc.pyx:125, in cupy_backends.cuda.libs.nvrtc.compileProgram()

File cupy_backends/cuda/libs/nvrtc.pyx:138, in cupy_backends.cuda.libs.nvrtc.compileProgram()

File cupy_backends/cuda/libs/nvrtc.pyx:53, in cupy_backends.cuda.libs.nvrtc.check_status()

NVRTCError: NVRTC_ERROR_COMPILATION (6)

During handling of the above exception, another exception occurred:

CompileException Traceback (most recent call last)

... (the full error listing is attached)

pip show cutensor-cu12 shows only one version of cutensor installed


alternatively i have started compiling gpu4pyscf.

After solving some little problems compiling stops:

[ 63%] Completed 'libxc'
[ 66%] Built target libxc
gmake: *** [Makefile:91: all] Error 2

Does anyone have some good ideas for me?

Thank you

errors.txt

@wxj6000
Copy link
Collaborator

wxj6000 commented Nov 15, 2024

It seems that nvrtc is missing in your CUDA environment. You can try to add it when you install cuda-toolkit (it is a part of cuda-toolkit).

@steto123
Copy link
Author

steto123 commented Nov 19, 2024

Many thanks for your help.

I was able to use the precompiled cuda11x versions in a clean environment on our HPC Cluster without greater problems.

Many thanks

And another question:

Is there an example for calculating shieldings? I found test_shielding.py but i do not have an ide how to integrate this in a optimisation run. (for pyscf i found a simple example and i will inspect this in the next days more intense)

@sunqm
Copy link
Collaborator

sunqm commented Nov 20, 2024

In current version, you can run

from gpu4pyscf.properties.shielding import eval_shielding
mf = mol.RKS().to_gpu().run()
eval_shielding(mf)

@steto123
Copy link
Author

Many thanks for your time to answer me.
I have used this in the following example:

`
xyzin="propanol-g_opt1.xyz" # funktioniert
logfile="test_g.log"

import gpu4pyscf
from gpu4pyscf.properties.shielding import eval_shielding
mol = pyscf.M(atom=xyzin, basis='6-31g*', output=logfile)

#mf = dft.RKS(mol)
#mf.xc = 'b3lyp'

mf = mol.RKS().to_gpu().run()
eval_shielding(mf)

`

i have uncommented the two lines alone and both at the same time. In all cases the error was the following:


ValueError Traceback (most recent call last)
Cell In[8], line 21
17 mf.xc = 'b3lyp'
20 mf = mol.RKS().to_gpu().run()
---> 21 eval_shielding(mf)

File ~/miniconda3/lib/python3.12/site-packages/gpu4pyscf/properties/shielding.py:205, in eval_shielding(mf)
202 dm0 = mf.make_rdm1()
203 natom = mf.mol.natm
--> 205 h1ao = get_h1ao(mf)
206 tmp = contract('xuv,ua->xav', s1ao, mvir)
207 s1ai = contract('xav,vi->xai', tmp, mocc)

File ~/miniconda3/lib/python3.12/site-packages/gpu4pyscf/properties/shielding.py:180, in get_h1ao(mf)
178 h1ao += -mf.mol.intor('int1e_ignuc')
179 h1ao = cupy.array(h1ao)
--> 180 h1ao += get_vxc(mf, dm0)
182 return h1ao

File ~/miniconda3/lib/python3.12/site-packages/gpu4pyscf/properties/shielding.py:160, in get_vxc(mf, dm0)
159 def get_vxc(mf, dm0):
--> 160 vxc = nr_rks(mf._numint, mf.mol, mf.grids, mf.xc, mf.make_rdm1())
161 # ! imaginary part
162 vj, vk = get_jk(mf.mol, dm0)

File ~/miniconda3/lib/python3.12/site-packages/gpu4pyscf/properties/shielding.py:100, in nr_rks(ni, mol, grids, xc_code, dms)
98 giao_aux = giao[:,:,index]
99 for idirect in range(3):
--> 100 vtmp = contract('pu,p,vp->uv', giao_aux[idirect], wv, ao)
101 vtmp = cupy.ascontiguousarray(vtmp)
102 add_sparse(vmat[idirect], vtmp, index)

File ~/miniconda3/lib/python3.12/site-packages/gpu4pyscf/lib/cutensor.py:151, in contract(pattern, a, b, alpha, beta, out)
146 def contract(pattern, a, b, alpha=1.0, beta=0.0, out=None):
147 '''
148 a wrapper for general tensor contraction
149 pattern has to be a standard einsum notation
150 '''
--> 151 return contraction(pattern, a, b, alpha, beta, out=out)

File ~/miniconda3/lib/python3.12/site-packages/gpu4pyscf/lib/cutensor.py:73, in contraction(pattern, a, b, alpha, beta, out, op_a, op_b, op_c, algo, jit_mode, compute_desc, ws_pref)
60 def contraction(
61 pattern, a, b, alpha, beta,
62 out=None,
(...)
69 ws_pref=WORKSPACE_RECOMMENDED
70 ):
72 pattern = pattern.replace(" ", "")
---> 73 str_a, rest = pattern.split(',')
74 str_b, str_c = rest.split('->')
75 key = str_a + str_b

ValueError: too many values to unpack (expected 2)

This makes me unhappy. Can you help me again?

Many thanks for your work and help.

@wxj6000
Copy link
Collaborator

wxj6000 commented Nov 21, 2024

This is a bug when you use LDA functional for NMR shielding calculation. It has been fixed in #256

Just a reminder. These modules (Polarizability, IR, and NMR shielding) are still experimental. They probably are not as efficient as SCF module.

@steto123
Copy link
Author

steto123 commented Nov 21, 2024

Many thanks for your help and this reminder. I have editited shielding.py in the same way and now it works.

Steffen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants