GPU driver and CUDA Toolkit
Install GPU driver using GUI
GPU driver can be installed via other methods too but this is the easiest.
- Go to “Software & Updates”, go to “Additional Drivers” tab.
- Select the latest driver. In this case, nvidia-driver-470(proprietary, tested)
- “Apply changes” and Reboot.
- Open the terminal application and type
nvidia-smi
to see GPU info:
Here, as you can see the recommended CUDA version is 11.4. Download it from https://developer.nvidia.com/cuda-toolkit-archive.
- For installation in Ubuntu: select Linux > x86_64 > Ubuntu
Then you’ll see that it’s only available for Ubuntu 18.04 and 20.04. If the you’ve installed some other version of ubuntu, reinstall one of this, and repeat the whole process.
Installation instructions are given there. Just run those commands.
1
2
wget https://developer.download.nvidia.com/compute/cuda/11.4.0/local_installers/cuda_11.4.0_470.42.01_linux.run
sudo sh cuda_11.4.0_470.42.01_linux.run
- During the installation of the CUDA toolkit, it will tell that you have already installed a driver, bla bla bla. Select “continue”.
- Untick the driver. and continue with the installation.
- Open the terminal application and type
nvcc -V
- It will show some error and recommend a command
sudo apt install cuda-toolkit
or something like that. Run that command. retype
nvcc -V
. And you’ll see that CUDA toolkit is now installed.
And voila, it’s done. (If not, just reboot)
LAMMPS with GPU
Everything is almost the same as regular installation. While building the lammps just change this command.
1
cmake -D PKG_GPU=on -D CUDA_ARCH=sm_30 -D CMAKE_CXX_COMPILER=g++ -D CMAKE_C_COMPILER=gcc -D CMAKE_INSTALL_PREFIX=/home/'computer_name'/lammps/lammps-install ../cmake
run the input file:
1
lmp -sf gpu -pk gpu 0 omp 40 -in in.lammps
where, 40 = number of processors
in.lammps = input file
gpu 0 will use all the available gpus
You’ll also need to make some change in the input script. For that, read the lammps manual.