Intel 编译器安装步骤
一 概述
在Intel的CPU上,Intel oneAPI编译器相比于其他编译器,如mpicc,gcc等,具有更好的优化效果,本文介绍如何安装oneAPI进行安装,其实只需要一直按照提示走就可以
二 安装 Intel 编译器
Intel oneAPI编译器下载:
Intel oneAPI Base Toolkit:https://registrationcenter-download.intel.com/akdlm/irc_nas/18970/l_BaseKit_p_2022.3.1.17310_offline.sh
Intel oneAPI HPC Toolkit: https://registrationcenter-download.intel.com/akdlm/irc_nas/18975/l_HPCKit_p_2022.3.1.16997_offline.sh
将这两个安装包下载好然后放到机器上任意目录
先安装Base Toolkit,再安装 HPC Toolkit
建议全程使用使用命令行安装,可以提高一点安装速度(终端执行 init 3 关闭图形化界面)
2.1 安装 Base Toolkit
执行 sh l_BaseKit_p_2022.3.1.17310_offline.sh
开始安装Base Toolkit
进入安装页面后,通过上下键选择 Accept & customer
( 接受并自定义安装)
然后进入以下页面,选择Next
然后就进入到选择安装目录的页面,按住Ctrl键再按退格才可以删除,默认是 /opt/intel/oneapi目录,但如果后面会装多个Intel编译器的话,还是应该规范一下安装路径。
注意:安装路径在指定时,最后一级目录必须是oneapi,不能修改,否则后面在使用时可能会报错
指定完路径后选中Next
然后进入以下页面:
点击Install
选择 skip,然后选中 Next
这里是用户体验计划,选择是否参加,我一般选择不参加,然后选中Begin Installation开始安装
这个安装过程大概要十来分钟,根据硬件性能的不同安装速度也会有些许不同
安装完毕:
点击close关闭页面,Base Toolkit 安装完毕
2.2 安装 HPC ToolKit
然后执行 sh l_HPCKit_p_2022.3.1.16997_offline.sh 安装 HPC ToolKit,大致过程与 Base toolkit相同,
相比于Base Toolkit,HPC Toolkit的安装要快很多
安装完毕后,使用 source /public/compiler/intel/2022u2/oneapi/setvars.sh intel64 命令来启用 intel编译器
三 安装module
module是一个用来管理环境变量的工具,通过编写modulefile,可以轻松的对不同软件或者同一个软件的不同版本进行切换。
下载module的安装脚本:
wget https://mirrors.aheadai.cn/script/install_module5.0.1.sh
使用sh执行该脚本即可,默认安装位置为/public/tool/module/5.4.0
然后新建一个modulefiles目录专门用来访modulefile文件,可以将该目录新建到 /public/modulefiles 目录下:
mkdir -p /public/modulefiles
安装完毕后,将
source /public/tool/module/5.4.0/init/profile.sh
export MODULEPATH=/public/modulefiles
写入到 ~/.bashrc
文件中去
然后执行 source ~/.bashrc
以使配置文件生效
然后输入 which module
,如果输出了路径,说明没啥问题了
四 编写 modulefile
新开一个会话(注意:一定要新开一个会话,确保环境是干净的!),然后新建一个文本文件,比如source_intel2022u2.of,里面输入以下内容:
source /public/compiler/intel/2022u2/oneapi/setvars.sh intel64
下载env2工具,该工具可以自动编写复杂环境的modulefile
wget https://mirrors.aheadai.cn/pkgs/env2
下载好后,为其赋予可执行权限:
chmod +x env2
然后执行:
./env2 -from bash -to modulecmd source_intel2022u2.of
此时终端会输出一段内容,将其复制下来
进入到 modulefiles 的目录:
cd /public/modulefiles
新建一个Intel目录并进入:
mkdir -p intel && cd intel
新建一个文本,文件名为2022u2,第一行写:#%Module
然后敲回车到第二行,将刚才复制的内容粘贴进去
然后保存退出即可
此时,在终端中执行 module load Intel/20022u2
就可以直接加载Intel编译器了
如果想卸载这个编译器,执行:module unload intel/2022u2
评论