环境
虚拟机VMware® Workstation 16 Pro 16.2.5
CentOS7.9
AMD 5500U 处理器 分配2核4线程
内存分配4G
下载
这里离线安装 Download the Intel® HPC Toolkit
单独附加一个MKL安装包 Intel® oneAPI standalone component installation files
安装
将文件解压到想安装的文件夹,按指示正常安装即可
chmod +x l_HPCKit_p_2024.1.0.560_offline.sh
chmod +x l_onemkl_p_2024.1.0.695_offline.sh
./l_HPCKit_p_2024.1.0.560_offline.sh
./l_onemkl_p_2024.1.0.695_offline.sh
设置环境变量
个人用户需在~/.bashrc文件里写环境变量,而root用户可以在/etc/profile.d/目录下新建一个文件,例如intel_compiler.sh,在里面写自己的环境变量:
. /share/intel/oneapi/setvars.sh
重新登陆使其生效,或source /etc/profile.d/intel_compiler.sh使单个shell生效
重新登陆
:: initializing oneAPI environment ...
-bash: BASH_VERSION = 4.2.46(2)-release
args: Using "$@" for setvars.sh arguments:
:: compiler -- latest
:: debugger -- latest
:: dev-utilities -- latest
:: dpl -- latest
:: mkl -- latest
:: mpi -- latest
:: tbb -- latest
:: oneAPI environment initialized ::
检查
icx --version
icpx --version
ifort --version
mpirun --version
# ifort --version
ifort: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by ifort)
更新GCC
参考如何升级linux的libstdc++.so - 知乎 (zhihu.com)
1. 检查当前 libstdc++
的版本
使用 locate
命令查找当前系统中安装的 libstdc++.so.6
的具体版本。
locate libstdc++.so.6
使用 strings
和 grep
命令确认当前 libstdc++
的 GLIBCXX 支持版本:
strings /usr/lib64/libstdc++.so.6 | grep GLIBCXX
2. 下载 GCC 源代码
选择与所需 libstdc++
版本匹配的 GCC 版本,并下载其源代码。如下是下载 GCC 5.5.0 版本:
wget http://ftp.gnu.org/gnu/gcc/gcc-7.3.0/gcc-7.3.0.tar.gz
tar -xvf gcc-5.5.0.tar.gz
3. 编译 GCC / libstdc++
3.1 在 GCC 源代码根目录执行以下命令下载所需的依赖。
cd gcc-5.5.0
./contrib/download_prerequisites
3.2 创建一个构建目录并配置生成 Makefile。
mkdir build && cd build
../configure --enable-checking=release --enable-languages=c,c++ --disable-multilib
3.3 编译并安装 GCC。
make -j 4 #核心数
make install
4. 更新软连接
将新编译生成的 libstdc++.so.6.0.21
拷贝到 /usr/lib64
,并更新 /usr/lib64/libstdc++.so.6
的软连接。
cp /usr/local/lib64/libstdc++.so.6.0.21 /usr/lib64/
cd /usr/lib64
ln -sf libstdc++.so.6.0.21 libstdc++.so.6
5. 确认升级
通过 strings
命令检查 libstdc++.so.6
支持的 GLIBCXX 版本,以确认升级成功。
strings libstdc++.so.6 | grep GLIBCXX
注意:
- 编译 GCC 会消耗相当的系统资源,并且可能需要一些时间。
- 需要保证有足够磁盘空间来进行编译过程。
- 对于生产环境的升级,推荐在测试环境中先行进行,并做好充分的测试。
- 如果系统使用了特殊的包管理器(如 Red Hat Software Collections),也可考虑通过包管理器安装较新版本的 GCC。
再次检查
[root@mgt lib64]# ifort --version
ifort: remark #10448: Intel(R) Fortran Compiler Classic (ifort) is now deprecated and will be discontinued late 2024. Intel recommends that customers transition now to using the LLVM-based Intel(R) Fortran Compiler (ifx) for continued Windows* and Linux* support, new language support, new language features, and optimizations. Use '-diag-disable=10448' to disable this message.
ifort (IFORT) 2021.12.0 20240222
Copyright (C) 1985-2024 Intel Corporation. All rights reserved.
检查MKL
echo $MKLROOT
[root@mgt lib64]# echo $MKLROOT
/share/intel/oneapi/mkl/2024.1