---
title: 编译和安装
description: "1. 使用PuTTY工具，以root用户登录服务器。"
url: https://www.hikunpeng.com/document/detail/zh/kunpenghpcs/hpcindapp/prtg-osc/kunpenglammps_02_0031.html
sourcePath: /source/zh/kunpenghpcs/hpcindapp/prtg-osc/kunpenglammps_02_0031.html
indexId: 41fa7c8300a1bebd185486d758bbacf346c5f050a0669978cad41a5b4c24710a68
---
# 编译和安装

#### 操作步骤

1. 使用PuTTY工具，以root用户登录服务器。
2. 执行以下命令进入主程序安装目录。

```
cd
/path/to/LAMMPS
```


3. 执行以下命令解压安装包。

```
tar -xvf lammps-10Feb2021.tar.gz
```


4. 执行以下命令进入解压后路径。

```
cd lammps-10Feb21
```


5. 编辑GPU模块，执行以下命令修改配置文件“Makefile.linux”。

  a. 打开配置文件“Makefile.linux”。

```
cd lib/gpu
vi Makefile.linux
```


  b. 按“i”进入编辑模式，修改如下内容。

```
CUDA_HOME = /usr/local/cuda-11.4
NVCC=nvcc
CUDA_ARCH=-arch=sm_80  #显卡对应的型号，当前环境使用A100（Ampere架构）
CUDA_PRECISION=-D_DOUBLE_DOUBLE  #计算精度
```


  c. 按“Esc”键，输入:wq!，按“Enter”保存并退出编辑。
6. 执行以下命令编译Lammps GPU模块。

```
make -f Makefile.linux -j 16
```


7. 执行以下命令查看GPU信息。

```
./nvc_get_devices
```


  回显显示如下内容，表示编译成功。

```
Found 1 platform(s).
Using platform: NVIDIA Corporation NVIDIA CUDA Driver
CUDA Driver Version:                           11.40
Device 0: "NVIDIA A100-PCIE-40GB"
Type of device:                                GPU
Compute capability:                             8
Double precision support:                        Yes
Total amount of global memory:                   39.5861 GB
Number of compute units/multiprocessors:           108
Number of cores:                               20736
Total amount of constant memory:                 65536 bytes
Total amount of local/shared memory per block:      49152 bytes
Total number of registers available per block: 65536
Warp size:                                     32
Maximum number of threads per block:             1024
Maximum group size (# of threads per block)         1024 x 1024 x 64
Maximum item sizes (# threads for each dim)         2147483647 x 65535 x 65535
Maximum memory pitch:                         2147483647 bytes
Texture alignment:                              512 bytes
Clock rate:                                    1.41 GHz
Run time limit on kernels:                        No
Integrated:                                    No
Support host page-locked memory mapping:         Yes
Compute mode:                                Default
Concurrent kernel execution:                     Yes
Device has ECC support enabled:                 Yes
```


8. 执行以下命令进入“src”目录。

```
cd ../../src
```


9. 执行以下命令修改“MAKE/OPTIONS/Makefile.g++_openmpi”文件。

  a. 打开“MAKE/OPTIONS/Makefile.g++_openmpi”文件。

```
vi
MAKE/OPTIONS/Makefile.g++_openmpi
```


  b. 按“i”进入编辑模式，修改第54、55和56行的内容。

```
FFT_INC =    -DFFT_FFTW -I/path/to/FFTW/include
FFT_PATH =  -L/path/to/FFTW/lib
FFT_LIB =    -lfftw3
```


    执行9.a之后，按“Esc”键，输入“:set nu”，按“Enter”即可显示出行号。

  c. 按“Esc”键，输入:wq!，按“Enter”保存并退出编辑。
10. 执行以下命令开始编译。

```
make yes-std
make no-lib
make yes-gpu
make -j 96 g++_openmpi
```
