網頁

2018年10月20日 星期六

ubuntu 16.04 install lammps-gpu




1. 要移除nvidia-cuda-toolkit否則會產生Nvidia.makefile:172: recipe for target 'atom.cubin' failed
$ sudo apt-get remove nvidia-cuda-toolkit
$ sudo apt-get autoremove nvidia-cuda-toolkit
(這步在Ubuntu 18.04有可能會讓整個OS死當)

2. nvcc設定環境變數
$ sudo vim /etc/profile
$ export PATH=$PATH:/usr/local/cuda-10.0/bin
$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-10.0/lib64/
$ source /etc/profile

$ echo 'export LD_LIBRARY_PATH=/usr/local/cuda-10.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}' >> ~/.bashrc
$ source ~/.bashrc

如果出現
nvcc -I/usr/local/cuda-10.0/include -DUNIX -O3 -Xptxas -v --use_fast_math -DLAMMPS_SMALLBIG -Xcompiler -fPIC -Icudpp_mini -arch=sm_75 -D_SINGLE_SINGLE --cubin -DNV_KERNEL -o atom.cubin lal_atom.cu
make: nvcc: Command not found
Nvidia.makefile:172: recipe for target 'atom.cubin' failed
make: *** [atom.cubin] Error 127

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


2. 產生Makefile.ubuntugpu在lib/gpu資料夾
$ cd /home/chiustin/lammps-12Dec18/src
NVIDIA 1080
$ make lib-gpu args="-m mpi -h /usr/local/cuda-10.0 -a sm_61 -p single -o ubuntugpu"
NVIDIA 2080Ti
$ make lib-gpu args="-m mpi -h /usr/local/cuda-10.0 -a sm_75 -p single -o ubuntugpu"

如果設定錯會顯示
ERROR: GPU library not compiled for this accelerator (../gpu_extra.h:40) 
Cuda driver error 4 in call at file 'geryon/nvd_device.h' in line 124. 
Cuda driver error 4 in call at file 'geryon/nvd_device.h' in line 124. 
Cuda driver error 4 in call at file 'geryon/nvd_device.h' in line 124.
Cuda driver error 4 in call at file 'geryon/nvd_device.h' in line 124.

Pascal (CUDA 8 and later)
SM60 or SM_60, compute_60 – GP100/Tesla P100 – DGX-1 (Generic Pascal)
SM61 or SM_61, compute_61 – GTX 1080, GTX 1070, GTX 1060, GTX 1050, GTX 1030, Titan Xp, Tesla P40, Tesla P4, Discrete GPU on the NVIDIA Drive PX2
SM62 or SM_62, compute_62 – Integrated GPU on the NVIDIA Drive PX2, Tegra (Jetson) TX2
Volta (CUDA 9 and later)
SM70 or SM_70, compute_70 – Tesla V100, GTX 1180 (GV104)
SM71 or SM_71, compute_71 – probably not implemented
SM72 or SM_72, compute_72 – currently unknown
Turing (CUDA 10 and later)
SM75 or SM_75, compute_75 – RTX 2080, Titan RTX, Quadro R8000
查詢sm可以到
$ cd NVIDIA_CUDA-10.0_Samples/1_Utilities/deviceQuery
$ ./deviceQuery
CUDA Capability Major/Minor version number:    6.1

參考
https://lammps.sandia.gov/doc/Build_extras.html#gpu

3. 產生libgpu.a、nvc_get_devices、Makefile.lammpslib/gpu/資料夾
$ cd /home/chiustin/lammps-12Dec18/lib/gpu
$ sudo vi Makefile.ubuntugpu
NVCC = /usr/local/cuda-10.0/bin/nvcc

$ make -f Makefile.ubuntugpu clean
$ make -f Makefile.ubuntugpu

4. 變更Makefile.lammps的CUDA路徑
$ vi Makefile.lammps
CUDA_HOME=/usr/local/cuda-10.0

5. 確認裝置
$ ./nvc_get_devices

6. 更新編譯binary
$ /home/chiustin/lammps-12Dec18/src
$ make yes-asphere
$ make yes-kspace
$ make yes-gpu

$ sudo make ubuntu
$ sudo make mpi
$ sudo make serial

7. 複製到bin
$ sudo cp lmp_ubuntu /usr/local/bin

8. 執行
$ lmp_ubuntu -sf gpu -pk gpu 1 -in in.lj.titan
$ lmp_serial -sf gpu -pk gpu 1 -in in.lj.titan

# 3d Lennard-Jones melt

newton          off
#package         gpu force/neigh 0 0 1
package         gpu 1
processors      * * * grid numa

variable x index 1
variable y index 1
variable z index 1

variable xx equal 20*$x
variable yy equal 20*$y
variable zz equal 20*$z

units lj
atom_style atomic

lattice fcc 0.8442
region box block 0 ${xx} 0 ${yy} 0 ${zz}
create_box 1 box
create_atoms 1 box
mass 1 1.0

velocity all create 1.44 87287 loop geom

pair_style lj/cut/gpu 2.5
pair_coeff 1 1 1.0 1.0 2.5

neighbor 0.3 bin
neigh_modify delay 0 every 20 check no

#fix 1 all nve
fix 1 all nve gpu force 0 0 1.0

run             15
run 100

mpi+gpu
$ mpirun -np 8 lmp_ubuntu -sf gpu -pk gpu 1 -in in.lj.titan
$ mpirun -np 8 lmp_mpi -sf gpu -pk gpu 1 -in in.lj.titan

參考
https://lammps.sandia.gov/doc/Speed_gpu.html
https://github.com/lammps/lammps/tree/master/examples/accelerate

沒有留言:

張貼留言