最近在安装 Nvidia Rapids 用于更为高效的科学计算。

安装代码如下:

1
conda create -n rapids-25.04 -c rapidsai -c conda-forge -c nvidia rapids=25.04 python=3.12 'cuda-version>=12.0,<=12.8'

但是发现 rapids-25.04 需要 GLIBC 的版本 在 2.28 及之上, 2.30 之下,但是我使用的是 CenOS 7, 默认的 GLIBC 版本相对较低,故需要对 GLIBC 进行升级。

经过阅读相关的博客,如 CSND, STACK_OVERFLOW,大概了解了 GLIBC 如何升级。

包含有 gmp, mpfr, mpc, isl的安装, gcc 的安装,binutils, bison, make 的安装,最后我安装的是 GLIBC-2.29 版本的。以下是我安装的 shell 脚本,部分的安装包更换为了 aliyun 的镜像,会有更快的下载速度。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
mkdir -p ~/miniconda3
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda3/miniconda.sh
bash ~/miniconda3/miniconda.sh -b -u -p ~/miniconda3
rm -rf ~/miniconda3/miniconda.sh
~/miniconda3/bin/conda init bash
sed -i '13d' ~/.bashrc
source ~/.bashrc
strings /lib64/libc.so.6 |grep GLIBC
# 查看系统名称
uname -a
# 查看系统centos的版本
cat /etc/redhat-release
# 查看系统版本
cat /proc/version
# 查看系统内核
rpm -qa | grep kernel
# 升级glibc需要的依赖
wget https://mirrors.aliyun.com/gnu/binutils/binutils-2.32.tar.gz
wget https://mirrors.aliyun.com/gnu/bison/bison-3.2.1.tar.gz
wget https://mirrors.aliyun.com/gnu/make/make-4.3.tar.gz

# gcc-8.2.0安装包
wget https://mirrors.aliyun.com/gnu/gcc/gcc-8.2.0/gcc-8.2.0.tar.gz
# glibc-2.28安装包
wget https://mirrors.aliyun.com/gnu/glibc/glibc-2.28.tar.gz
wget https://mirrors.aliyun.com/gnu/gmp/gmp-6.1.0.tar.bz2
wget https://mirrors.aliyun.com/gnu/mpfr/mpfr-3.1.4.tar.bz2
wget https://mirrors.aliyun.com/gnu/mpc/mpc-1.0.3.tar.gz
wget https://gcc.gnu.org/pub/gcc/infrastructure/isl-0.18.tar.bz2
# 解压
tar -jxvf gmp-6.1.0.tar.bz2
# 安装
cd gmp-6.1.0
./configure --prefix=/usr/local/gmp
make && make install
cd ~
# 解压
tar -jxvf mpfr-3.1.4.tar.bz2
# 安装
cd mpfr-3.1.4
./configure --prefix=/usr/local/mpfr --with-gmp=/usr/local/gmp
make && make install
cd ~
# 解压
tar -zxvf mpc-1.0.3.tar.gz
# 安装
cd mpc-1.0.3
./configure --prefix=/usr/local/mpc --with-gmp=/usr/local/gmp --with-mpfr=/usr/local/mpfr
make && make install

cd ~
# 解压
tar -jxvf isl-0.18.tar.bz2
# 安装
cd isl-0.18
./configure --prefix=/usr/local/isl --with-gmp=/usr/local/gmp --with-mpfr=/usr/local/mpfr --with-mpc=/usr/local/mpc
make && make install
cd ~
# 解压
tar -zxvf gcc-8.2.0.tar.gz
# 安装
cd gcc-8.2.0
# 安装gcc不能直接在安装包中执行configure,需要创建build文件夹
# 升级gcc需要的依赖
wget https://gcc.gnu.org/pub/gcc/infrastructure/isl-0.18.tar.bz2
wget https://mirrors.aliyun.com/gnu/gmp/gmp-6.1.0.tar.bz2
wget https://mirrors.aliyun.com/gnu/mpfr/mpfr-3.1.4.tar.bz2
wget https://mirrors.aliyun.com/gnu/mpc/mpc-1.0.3.tar.gz
./contrib/download_prerequisites
mkdir build
cd build
# 执行
../configure --prefix=/usr/local/gcc-8.2.0 --enable-bootstrap --enable-checking=release --enable-languages=c,c++ --disable-multilib
make -j 2
make install
# 备份原有的gcc
mv /bin/gcc /bin/gcc_bak

# 将新的软链接方式写入
ln -s /usr/local/gcc-8.2.0/bin/gcc /bin/gcc
cd ~
# 解压
tar -xzvf binutils-2.32.tar.gz
# 安装
cd binutils-2.32/
./configure --prefix=/usr/local/binutils-2.32
make
make install

#进入binutils ,并查看 安装版本是否可用
cd /usr/local/binutils-2.32/bin
./ld --version
./as --version

#备份原有的binutils
mv /usr/bin/ld /usr/bin/ld_bak
mv /usr/bin/as /usr/bin/as_bak

#将新的软链接方式写入
ln -s /usr/local/binutils-2.32/bin/ld /usr/bin/ld
ln -s /usr/local/binutils-2.32/bin/as /usr/bin/as

cd ~
# 解压
tar -xf bison-3.2.1.tar.gz
# 安装
cd bison-3.2.1
./configure --prefix=/usr/local/bison-3.2.1
make
make install

# 将新的软链接方式写入
ln -s /usr/local/bison-3.2.1/bin/bison /bin/bison
cd ~
# 解压
tar -zxvf make-4.3.tar.gz
# 安装
cd make-4.3
./configure --prefix=/usr/local/make-4.3
make
make install

# 备份原有的make
mv /usr/bin/make /usr/bin/make_bak

# 将新的软链接方式写入
ln -s /usr/local/make-4.3/bin/make /usr/bin/make

cd ~
wget https://mirrors.aliyun.com/gnu/glibc/glibc-2.29.tar.gz
tar -zxvf glibc-2.29.tar.gz
cd glibc-2.29
mkdir build_dir
cd build_dir
../configure --prefix=/opt/glibc
../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin
# 时间较长,使用 -j4
make -j4
make install
cd ~
strings /lib64/libc.so.6 |grep GLIBC
rm -rf binutils-2.32.tar.gz
rm -rf binutils-2.32
rm -rf bison-3.2.1.tar.gz
rm -rf bison-3.2.1
rm -rf make-4.3.tar.gz
rm -rf make-4.3
rm -rf gmp-6.1.0.tar.bz2
rm -rf gmp-6.1.0
rm -rf mpfr-3.1.4.tar.bz2
rm -rf mpfr-3.1.4
rm -rf mpc-1.0.3.tar.gz
rm -rf mpc-1.0.3
rm -rf isl-0.18_0.18.orig.tar.xz
rm -rf isl-0.18
rm -rf gcc-8.2.0.tar.gz
rm -rf gcc-8.2.0
rm -rf glibc-2.28.tar.gz
rm -rf glibc-2.29.tar.gz
rm -rf glibc-2.29