Win10+WSL2+Ubuntu22.04安装Lammps+GPU+Python

记录自己安装的历程

Ubuntu22.04,ld版本:2.38(22.04默认),没有找到国内源,所以没有换源,但校园网的速度还可以 

目录

1. 安装WSL

2.更新Windows内核

3.安装WSL

4.修改WSL为WSL2

5.安装Ubuntu中文包  

6.安装binutils,更新ld(更新前后没有变化)

7.安装Anaconda

8.安装mpich与fftw3(gcc/g++/gfortran已经有了,安装会显示已存在)

9.安装Nvidia驱动,好像在Win10里,安装了驱动后,wsl会自动识别

10.安装cuda12.2(cuda的版本最好和nvidia-smi输出的CUDA Version相一致)

11.安装lammps

致谢:


1. 安装WSL

在Windows的设置里选择应用,然后选择程序和功能,选择启用或关闭Windows功能,开启Hyper-v,虚拟机平台以及适用于Linux的Windows子系统,全部安装完成后按提示重启。

2.更新Windows内核

在浏览器输入下列网址

wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi

会自动下载,下载完成后,按正常安装软件的流程打开,按照向导完成,很快会提示Finished,点击Finish即可。

3.安装WSL

在Miscrosoft Store里下载Ubuntu22.04.2

下载完成后打开,显示Installing, this may take a few minutes...

如果打开Ubuntu后显示如下界面,则证明内核没有更新,需要重复第2步(图片来自win10 WSL2问题解决WslRegisterDistribution failed with error: 0x800701bc-CSDN博客)。

如果正常安装,则显示如下界面,构建完成后,会显示Enter new UNIX username,此时输入用户名。注意:用户名和接下来的密码,都要输入英文,并且小写(这样会保证不出错),在输入密码时,屏幕不会显示内容,只需正常输入然后回车即可,需再输入一次(Retype new password)。密码设置不要过长或太复杂,以简单好记为主,因为在将来的使用中会经常用到密码。

密码输入完成后,显示安装完成,此时WSL已经安装成功。

4.修改WSL为WSL2

在开始菜单右击,选择Windows Powershell (管理员),输入

wsl -l -v

如果显示VERSION为2,则不用进行这一步,如果VERSION为1,则需输入

wsl.exe --set-version Ubuntu-22.04 2

再重新输入wsl -l -v,VERSION将变为2即可。

5.安装Ubuntu中文包  

sudo dpkg-reconfigure locales

选择zh_CN.UTF-8(按空格键选择,按Tab键移动到确定,按回车键确定)(来自:Win10子系统Ubuntu安装及图形桌面配置-不想用虚拟机却又要Windows下运行双系统的方法-带视频教程_教程_TKDCZ网图icon-default.png?t=N7T8https://www.tkdcz.top/post/46.html

安装好后exit退出重新进入,输入date即可看到系统语言变为中文

6.安装binutils,更新ld(更新前后没有变化)

sudo apt-get install binutils

7.安装Anaconda

下载Anaconda,网址为:Index of / (anaconda.com)

选择这一个,下载后将下载的文件复制到/home/ouyang/software

然后执行下列命令

chmod +x Anaconda3-2023.03-1-Linux-x86_64.sh

bash Anaconda3-2023.03-1-Linux-x86_64.sh

bash后要按多次回车键,直到这个页面时输入yes,然后回车

输入yes后出现下面的界面,继续按回车

出现下面的界面,输入yes,然后回车

安装完成,然后exit关闭窗口

重新进入,输入which python,显示:

/home/ouyang/anaconda3/bin/python

安装成功! 

8.安装mpich与fftw3(gcc/g++/gfortran已经有了,安装会显示已存在)

在终端输入以下命令:

sudo apt-get update

sudo apt-get upgrade

sudo apt-get install mpich

sudo apt-get install fftw3

sudo apt-get install gcc

sudo apt-get install g++

sudo apt-get install gfortran

9.安装Nvidia驱动,好像在Win10里,安装了驱动后,wsl会自动识别

在终端输入nvidia-smi后,会直接显示如下信息,并没有再单独安装驱动

Win10里的Nvidia驱动如下所示

10.安装cuda12.2(cuda的版本最好和nvidia-smi输出的CUDA Version相一致)

CUDA Zone - Library of Resources | NVIDIA Developer

wget https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/cuda-wsl-ubuntu.pin

sudo mv cuda-wsl-ubuntu.pin /etc/apt/preferences.d/cuda-repository-pin-600

wget https://developer.download.nvidia.com/compute/cuda/11.7.0/local_installers/cuda-repo-wsl-ubuntu-11-7-local_11.7.0-1_amd64.deb

sudo dpkg -i cuda-repo-wsl-ubuntu-11-7-local_11.7.0-1_amd64.deb

sudo cp /var/cuda-repo-wsl-ubuntu-11-7-local/cuda-*-keyring.gpg /usr/share/keyrings/

sudo apt-get update

sudo apt-get -y install cuda

vi .bashrc

export PATH=$PATH:/usr/local/cuda-11.7/bin

source .bashrc

nvcc -V (显示cuda版本号,安装成功)

在下图中查找自己显卡对应的Compute capability (version),在稍后的编译mpi中需要用到。

11.安装lammps

tar xzvf lammps-stable-23-June-2022.tar.gz

cd lammps-23Jun2022/lib/gpu

vi Makefile.linux

CUDA_HOME = /usr/local/cuda-11.7

# Turing hardware
CUDA_ARCH = -arch=sm_75    (GTX1650)

:wq

make -f Makefile.linux clean

make -f Makefile.linux -j 6

cd ../python

cp Makefile.lammps.python3 Makefile.lammps

cd ../../src

make yes-all no-lib no-ext yes-python yes-gpu

make mpi -j 6

cd

mkdir bin

cp /home/wwp/software/lammps/lammps-23Jun2022/src/lmp_mpi /home/wwp/bin/

vi .bashrc

export PATH=$PATH:/home/wwp/bin

:wq

source .bashrc

which lmp_mpi

到此就结束了

致谢:

这是自己第一次写博客,在安装的过程中耗费了非常多的时间和精力,因此在这里记录一下,用于以后重新安装的参考。

安装过程中参考了很多网站,包括但不限于以下列出的网址,感谢

但自己是第一次记录,不太清楚有关规定,如果侵权将主动删除

Win10子系统Ubuntu安装及图形桌面配置-不想用虚拟机却又要Windows下运行双系统的方法-带视频教程_教程_TKDCZ网图Ubuntu命令方式安装中文语言包 - MineLSG - 博客园 (cnblogs.com)

win10 WSL2问题解决WslRegisterDistribution failed with error: 0x800701bc-CSDN博客

如何在 Windows 10 上安装 WSL 2 - 知乎 (zhihu.com)

CUDA Zone - Library of Resources | NVIDIA Developer

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

CUDA Toolkit 12.2 Update 2 Downloads | NVIDIA Developer

Index of /gnu/binutils

Unbuntu卸载anaconda(最新最全亲测)_ubuntu卸载anaconda_向日葵骑士Faraday的博客-CSDN博客

Ubuntu18.04更改国内镜像源(阿里云、网易、清华、中科大)_ubuntu18.04下载国内镜像_花好约猿上王者的博客-CSDN博客

  • 4
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
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.
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值