非root安装lammps-gpu版本(NVIDIA)

#################################################################
写在前面的话,需要会一些基本的linux指令
仅供参考https://www.quanxiaoha.com/linux-command/linux-shutdown.html
下面改一些文件需要会vim指令
仅供参考https://www.bilibili.com/video/BV1hy4y1z7tA/?spm_id_from=333.999.0.0&vd_source=c0e81733aa62a85725522f0de27627e4
#################################################################

一、加载intel编译器的环境

1、在bashrc里加入(一劳永逸)
if [ "$SSH_TTY" ]
then
   source /opt/intel/oneapi/setvars.sh 
fi
2、命令行(每次打开新的ssh/终端都得输入一次)
source /opt/intel/oneapi/setvars.sh
注:上述两种方式都可,正常显示

二、检查cuda-driver和cuda-toolkit环境

1、检查cuda-driver
nvidia-smi
正常显示如下(此处需要看一下显卡型号,后面步骤需要用到)
非正常显示
bash: nvidia-smi: command not found...
注:这是driver未安装或未正确安装,此时联系管理员(driver安装需root权限)

2、检查cuda-toolkit

bashrc加入或者命令行输入

export PATH=/usr/local/cuda/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH

检查路径是否正确,输入

nvcc -V
正确显示

非正常显示
bash: nvcc: command not found...
注:这是cuda-toolkit未安装或未正确安装,此时联系管理员(toolkit安装需root权限)

三、lammps-gpu安装

1、确保nvidia-smi和nvcc -V均正常
2、下载lammps
https://download.lammps.org/tars/index.html(建议年份比较新的版本)
3、解压(这里以lammps-23Jun2022.tar.gz为例)
tar -zxvf lammps-23Jun2022.tar.gz
4、编译lammps的gpu库

(1)cd lammps-23Jun2022/lib/gpu
(2)修改Makefile.linux主要两个地方

    /usr/local/cuda替换成你的cuda-toolkit位置
    arch=sm_75数字替换成你的显卡的算力值(75=7.5*10)

    算力查询地址:https://developer.nvidia.com/cuda-gpus
(3)make -f Makefile.linux(重新编译需要先make -f Makefile.linux clean)
    编译成功显示

5、修改lammps的编译文件

cd lammps-23Jun2022/src/MAKE
vim Makefile.mpi

    -L/usr/local/cuda/lib64替换成你自己的位置

6、编译安装lammps
cd lammps-23Jun2022/src

安装必要的库,例如:make yes-gpu代表安装;make no-gpu代表卸载(库根据自己需要的任务自行安装)
注:可以使用make package-status检查自己安装的库(YES代表安装,NO代表未安装)

make mpi(重新编译需要make clean-all)
注:前一步中安装的库越多,make mpi时间越长,可以采用make mpi -j 4(4核同时编译,数字可改)
7、ll lmp_mpi正常显示

 

四、测试

cd lammps-23Jun2022/examples/shear

修改in.shear里的run的步数;随便改10000

###  纯cpu指令
mpirun -np 1 ../../src/lmp_mpi -in in.shear
###  加gpu指令
mpirun -np 1 ../../src/lmp_mpi -in in.shear -sf gpu -pk gpu 1

对比运行的时间

注:提交任务的指令有很多,建议到lammps官网(https://www.lammps.org/)或者手册查找(lammps-23Jun2022/doc/Manual.pdf)

学习笔记(如有侵权,联系必删)

五、参考文本

1、Linux编译LAMMPS-GPU - 知乎 (zhihu.com)

2、Ubuntu下的lammps GPU加速(真的香)-CSDN博客

  • 11
    点赞
  • 27
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
To run LAMMPS with GPU acceleration on Ubuntu using NVIDIA GPUs, you need to follow these steps: 1. Install NVIDIA driver: Ensure that you have the latest NVIDIA driver installed on your system. You can use the instructions provided earlier to install or update the NVIDIA driver on Ubuntu. 2. Install CUDA Toolkit: LAMMPS requires CUDA to run on GPUs. Install the CUDA Toolkit, which includes the necessary libraries and tools for GPU computing. You can download the CUDA Toolkit from the NVIDIA website and follow their installation instructions. 3. Download and compile LAMMPS: Obtain the LAMMPS source code from the official LAMMPS website or GitHub repository. Extract the source code to a directory of your choice. 4. Set up Makefile: Navigate to the LAMMPS source code directory and locate the Makefile. Open the Makefile and modify it to include GPU support. Uncomment or add the appropriate lines for GPU acceleration using CUDA. For example, you may need to set `GPU` to `yes`, specify the CUDA path, and select the appropriate CUDA architecture. 5. Compile LAMMPS: In the terminal, navigate to the LAMMPS source code directory and run `make mpi` or `make serial` depending on your desired configuration. This will compile LAMMPS with GPU support enabled. 6. Run LAMMPS with GPU acceleration: Once the compilation is complete, you can run LAMMPS with GPU acceleration by using the `lmp_mpi` or `lmp_serial` executable generated during the compilation process. Be sure to specify the appropriate input script and any necessary command-line options. For example, to run a LAMMPS input file named "input.lammps" using multiple GPUs, you can use the following command: ``` mpirun -np <number of MPI processes> lmp_mpi -sf gpu -pk gpu <number of GPUs> -in input.lammps ``` Replace `<number of MPI processes>` with the desired number of MPI processes, and `<number of GPUs>` with the number of GPUs you want to use. Please note that the specific steps and commands may vary depending on your LAMMPS version, GPU configuration, and system setup. Refer to the LAMMPS documentation and CUDA Toolkit documentation for more detailed instructions and troubleshooting information.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值