搭建MPI/CUDA开发环境
本文记录MPI/CUDA开发环境搭建过程。
一、Linux
2.1 环境
操作系统 | Ubuntu 22.04.4 LTS |
VS Code | 1.92.1 |
Git | 2.34.1 |
GCC | 11.4.0 |
CMake | 3.22.1 |
2.2 VS Code
下载VS Code,然后安装以下插件,
Task Explorer Output Colorizer Git Extension Pack Git Graph Remote Developement Remote X11 | |
C/C++ Extension Pack C++ TestMate | |
Modern Fortran FORTRAN InstelliSense Fortran Breakpoint Support | |
Python Extension Pack | |
C# Dev Kit | |
Extension Pack for Intel Software Developer Tools | |
Nsight Visual Studio Code Edition |
2.3 oneAPI
# download the key to system keyring
wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
| gpg --dearmor | sudo tee /usr/share/keyrings/oneapi-archive-keyring.gpg > /dev/nullecho "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.listsudo apt updatesudo apt install intel-oneapi-base-toolkit
sudo apt install intel-oneapi-hpc-toolkit
2.4 CUDA
lspci | grep -i nvidia
uname -m && cat /etc/*release
gcc --versionwget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb
sudo dpkg -i cuda-keyring_1.1-1_all.deb
sudo apt-get update
sudo apt-get install cuda-toolkit
sudo reboot
运行以下命令测试CUDA安装成功,
root@youquan:~# nvidia-smi
Mon Dec 21 09:22:19 2024
+---------------------------------------------------------------------------------------+
| NVIDIA-SMI 535.183.01 Driver Version: 535.183.01 CUDA Version: 12.2 |
|-----------------------------------------+----------------------+----------------------+
| GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|=========================================+======================+======================|
| 0 NVIDIA GeForce RTX 4090 Off | 00000000:65:00.0 Off | Off |
| 30% 25C P8 11W / 450W | 30MiB / 24564MiB | 0% Default |
| | | N/A |
+-----------------------------------------+----------------------+----------------------++---------------------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=======================================================================================|
| 0 N/A N/A 2217 G /usr/lib/xorg/Xorg 9MiB |
| 0 N/A N/A 2657 G /usr/bin/gnome-shell 10MiB |
+---------------------------------------------------------------------------------------+
2.5 环境变量配置
添加以下环境变量到~/.bashrc文件,
# oneAPI
source /opt/intel/oneapi/setvars.sh --force# cuda
export C_INCLUDE_PATH=/usr/local/cuda/include:$C_INCLUDE_PATH
export CPLUS_INCLUDE_PATH=/usr/local/cuda/include:$CPLUS_INCLUDE_PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
export PATH=/usr/local/cuda/bin:$PATH# sepcify configurations for CMake
export CC=icc
export CFLAGS=
export CXXFLAGS=
export FC=ifort
#export FFLAGS=
export CUDACXX=nvcc
export CUDAFLAGS=' -x cu -Xcompiler -march=native,-mavx '
export CUDAFLAGS=
export CUDAHOSTCXX=icpc
#export LDFLAGS=
二、Windows
2.1 环境
操作系统 | Windows 11 |
VS Code | 1.92.1 |
Git | 2.34.1 |
Visual Studio | Visual Studio Community 2022 |
CMake | 3.22.1 |
2.2 oneAPI
从Intel官网下载并安装oneAPI Base Toolkit 与oneAPI HPC Toolkit
2.3 CUDA Toolkit
从NVIDIA官网下载并安装CUDA Toolki。
网络资料
oneAPIhttps://www.intel.com/content/www/us/en/developer/tools/oneapi/overview.html
CUDA Zonehttps://developer.nvidia.com/cuda-zone/
NVIDIA CUDA Installation Guide for Linuxhttps://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html