本文介绍openmpi的非root安装,并且在cmake中使用它。
目录
安装openmpi
wget https://download.open-mpi.org/release/open-mpi/v4.0/openmpi-4.0.7.tar.gz
tar xf openmpi-4.0.7.tar.gz
cd openmpi-4.0.7
非root安装:
./configure --prefix=/home/lili/localinstall
make
make install
设置环境变量,以便mpirun使用我们自己安装的版本:
export PATH="/home/lili/localinstall/bin:$PATH"
在cmake里使用
这里用的是Parallel and High Performance Computing的简单例子。
CMakeLists.txt:
cmake_minimum_required (VERSION 3.0)
project (TimeIt)
# Enables CTest functionality in CMake
enable_testing()
# CMake has a built-in routine to find most MPI packages
# Defines MPI_FOUND if found
# MPI_INCLUDE_PATH (being replaced by MPI_<lang>_INCLUDE_PATH)
# MPI_LIBRARIES (being replaced by MPI_<lang>_LIBRARIES)
find_package(MPI)
# Adds build targets of TimeIt and MPITimeIt with source code file(s) TimeIt.c and MPITimeIt.c
add_executable(TimeIt TimeIt.c)
add_executable(MPITimeIt MPITimeIt.c)
# Need an include path to the mpi.h file and to the MPI library
target_include_directories(MPITimeIt PUBLIC ${MPI_INCLUDE_PATH})
target_link_libraries(MPITimeIt ${MPI_LIBRARIES})
# This gets all files with the extension 'ctest' and adds it to the test list for CTest
# The ctest file needs to be executable or explicitly launched with the 'sh' command as below
file(GLOB TESTFILES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "*.ctest")
foreach(TESTFILE ${TESTFILES})
add_test(NAME ${TESTFILE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/${TESTFILE})
endforeach()
# A custom command, distclean, to remove files that are created
add_custom_target(distclean COMMAND rm -rf CMakeCache.txt CMakeFiles
CTestTestfile.cmake Makefile Testing cmake_install.cmake)
为了让CMake使用我们安装的openmpi,我们需要设置CMAKE_PREFIX_PATH:
cmake -Bbuild -DCMAKE_PREFIX_PATH=/home/lili/localinstall
- 显示Disqus评论(需要科学上网)
FEATURED TAGS
人工智能
深度学习
chatbot
PyTorch
Java
BERT
git
编程
OCR
汪曾祺
语音识别
Kaldi
Linux
XLNet
情感分析
sentiment analysis
语法纠错
Transformer
Tensorflow
Huggingface
Ubuntu
TensorFlow
深度学习框架
Tensor2Tensor
机器翻译
微信
wechat
automation
selenium
webdriver
pywinauto
CentOS
GPU
Appium
t2t
代码阅读
中英翻译
公众号
爬虫
ocr
tesseract
pytesseract
python
默认参数
位置参数
VPN
JSON
Jackson
huggingface
PagedAttention
vLLM
Pre-training
LLM
CPT
weather
forecasting
graph neural networks
qlora
quantization
transformers
cmake
pip
pipenv
conda
padding
vscode
debug
source code
build
deep learning
Speech
ASR
linux
pytorch
extension
Deep Learning