How to Compile QE with GPU support 🎮

Are you a gamer turned material physicist or, for some other reason, you have a nvidia GPU and you want to use the full power of your pc for Quantum ESPRESSO, then you've come to the right place!

I actually had quite the difficulty setting this up that's why I decided to create this guide so no one else has to suffer like I did

We start by downloading the cuda libraries (I know, not open source, but for me this is the "calculator" machine, not a "personal" machine). The libraries can by found on their website, download this wherever you want and follow along in the install process (1.2), which amounts to just gunzipping the file and tar -xf on the file (or equivalent tar xpfz file), going in the new folder and running the install script (./install). It will ask you what kind of setup you want, choose "network" (I know weird but that way it works), giving the dir where you want to install it (for me /media/bap , bap meaning big-ass programs) and sit around a bit as it takes ages. After this the most important part of this installation procedure: Setting the enviroment variables, put this in your .zshrc (or .bashrc if you're running bash):

# hpc_sdk
export PATH=/media/bap/Linux_x86_64/22.11/compilers/bin:$PATH
export MANPATH=$MANPATH:/media/bap/Linux_x86_64/22.11/compilers/man
export PATH=/media/bap/Linux_x86_64/22.11/comm_libs/mpi/bin:$PATH
export MANPATH=$MANPATH:/media/bap/Linux_x86_64/22.11/comm_libs/mpi/man
export LD_LIBRARY_PATH=/media/bap/Linux_x86_64/22.11/math_libs/11.8/lib64:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/media/bap/Linux_x86_64/22.11/cuda/11.8/bin:$LD_LIBRARY_PATH

For you these will of course not be in /media/bap if you chose another install directory, change accordingly

Now the final part: The compiling, we'll download the latest version of Quantum ESPRESSO from the website and go into the directory, now there's something wrong in the install file (which I painstakingly discovered), if you go into the install directory and open up the file "configure" in vim, at line at line 4341 it states

if test "$enable_openacc" == "yes"; then
This is wrong POSIX syntax haha, it should be this:
if test "$enable_openacc"=="yes"; then

(yes I almost went insane discovering this), I'll fork it on gitlab so it can be changed but for the moment it's broken. Now we'll want to know what our cuda runtime and cc's are, so just as the README_GPU says, we run

$  nvaccelinfo | grep -e 'Target' -e 'Driver'

We see the cc and Driver version (11080 would mean 11.8). After this we go into the quantum espresso downloaded folder (btw if you've already tried a bunch of times before coming here, don't forget to do a "make clean") and we run [Change the 61 and 11.8 according to what you just got]

$  ./configure --with-cuda=/media/bap/Linux_x86_64/22.11/cuda/ --with-cuda-runtime=11.8 --with-cuda-cc=61"

and after this a

$  make pw

and a

$  sudo make install

And we should be done, if you encountered an error on the way, lmk at (with all the errors I've seen I've become somewhat of an expert on this 🫠)

back button home button