8000 Revert "[BE] cleanup install_cuda.sh script" (#1943) · pytorch/builder@b8fcff5 · GitHub
[go: up one dir, main page]

Skip to content

Commit b8fcff5

Browse files
authored
Revert "[BE] cleanup install_cuda.sh script" (#1943)
This reverts commit e7b7315.
1 parent 7167366 commit b8fcff5

File tree

2 files changed

+253
-0
lines changed

2 files changed

+253
-0
lines changed

common/install_cuda.sh

Lines changed: 239 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,239 @@
1+
#!/bin/bash
2+
3+
set -ex
4+
5+
NCCL_VERSION=v2.21.5-1
6+
CUDNN_VERSION=9.1.0.70
7+
8+
function install_cusparselt_040 {
9+
# cuSparseLt license: https://docs.nvidia.com/cuda/cusparselt/license.html
10+
mkdir tmp_cusparselt && pushd tmp_cusparselt
11+
wget -q https://developer.download.nvidia.com/compute/cusparselt/redist/libcusparse_lt/linux-x86_64/libcusparse_lt-linux-x86_64-0.4.0.7-archive.tar.xz
12+
tar xf libcusparse_lt-linux-x86_64-0.4.0.7-archive.tar.xz
13+
cp -a libcusparse_lt-linux-x86_64-0.4.0.7-archive/include/* /usr/local/cuda/include/
14+
cp -a libcusparse_lt-linux-x86_64-0.4.0.7-archive/lib/* /usr/local/cuda/lib64/
15+
popd
16+
rm -rf tmp_cusparselt
17+
}
18+
19+
function install_cusparselt_052 {
20+
# cuSparseLt license: https://docs.nvidia.com/cuda/cusparselt/license.html
21+
mkdir tmp_cusparselt && pushd tmp_cusparselt
22+
wget -q https://developer.download.nvidia.com/compute/cusparselt/redist/libcusparse_lt/linux-x86_64/libcusparse_lt-linux-x86_64-0.5.2.1-archive.tar.xz
23+
tar xf libcusparse_lt-linux-x86_64-0.5.2.1-archive.tar.xz
24+
cp -a libcusparse_lt-linux-x86_64-0.5.2.1-archive/include/* /usr/local/cuda/include/
25+
cp -a libcusparse_lt-linux-x86_64-0.5.2.1-archive/lib/* /usr/local/cuda/lib64/
26+
popd
27+
rm -rf tmp_cusparselt
28+
}
29+
30+
function install_118 {
31+
echo "Installing CUDA 11.8 and cuDNN ${CUDNN_VERSION} and NCCL ${NCCL_VERSION} and cuSparseLt-0.4.0"
32+
rm -rf /usr/local/cuda-11.8 /usr/local/cuda
33+
# install CUDA 11.8.0 in the same container
34+
wget -q https://developer.download.nvidia.com/compute/cuda/11.8.0/local_installers/cuda_11.8.0_520.61.05_linux.run
35+
chmod +x cuda_11.8.0_520.61.05_linux.run
36+
./cuda_11.8.0_520.61.05_linux.run --toolkit --silent
37+
rm -f cuda_11.8.0_520.61.05_linux.run
38+
rm -f /usr/local/cuda && ln -s /usr/local/cuda-11.8 /usr/local/cuda
39+
40+
# cuDNN license: https://developer.nvidia.com/cudnn/license_agreement
41+
mkdir tmp_cudnn && cd tmp_cudnn
42+
wget -q https://developer.download.nvidia.com/compute/cudnn/redist/cudnn/linux-x86_64/cudnn-linux-x86_64-${CUDNN_VERSION}_cuda11-archive.tar.xz -O cudnn-linux-x86_64-${CUDNN_VERSION}_cuda11-archive.tar.xz
43+
tar xf cudnn-linux-x86_64-${CUDNN_VERSION}_cuda11-archive.tar.xz
44+
cp -a cudnn-linux-x86_64-${CUDNN_VERSION}_cuda11-archive/include/* /usr/local/cuda/include/
45+
cp -a cudnn-linux-x86_64-${CUDNN_VERSION}_cuda11-archive/lib/* /usr/local/cuda/lib64/
46+
cd ..
47+
rm -rf tmp_cudnn
48+
49+
# NCCL license: https://docs.nvidia.com/deeplearning/nccl/#licenses
50+
# Follow build: https://github.com/NVIDIA/nccl/tree/master?tab=readme-ov-file#build
51+
git clone -b $NCCL_VERSION --depth 1 https://github.com/NVIDIA/nccl.git
52+
cd nccl && make -j src.build
53+
cp -a build/include/* /usr/local/cuda/include/
54+
cp -a build/lib/* /usr/local/cuda/lib64/
55+
cd ..
56+
rm -rf nccl
57+
58+
install_cusparselt_040
59+
60+
ldconfig
61+
}
62+
63+
function install_121 {
64+
echo "Installing CUDA 12.1 and cuDNN ${CUDNN_VERSION} and NCCL ${NCCL_VERSION} and cuSparseLt-0.5.2"
65+
rm -rf /usr/local/cuda-12.1 /usr/local/cuda
66+
# install CUDA 12.1.0 in the same container
67+
wget -q https://developer.download.nvidia.com/compute/cuda/12.1.1/local_installers/cuda_12.1.1_530.30.02_linux.run
68+
chmod +x cuda_12.1.1_530.30.02_linux.run
69+
./cuda_12.1.1_530.30.02_linux.run --toolkit --silent
70+
rm -f cuda_12.1.1_530.30.02_linux.run
71+
rm -f /usr/local/cuda && ln -s /usr/local/cuda-12.1 /usr/local/cuda
72+
73+
# cuDNN license: https://developer.nvidia.com/cudnn/license_agreement
74+
mkdir tmp_cudnn && cd tmp_cudnn
75+
wget -q https://developer.download.nvidia.com/compute/cudnn/redist/cudnn/linux-x86_64/cudnn-linux-x86_64-${CUDNN_VERSION}_cuda12-archive.tar.xz -O cudnn-linux-x86_64-${CUDNN_VERSION}_cuda12-archive.tar.xz
76+
tar xf cudnn-linux-x86_64-${CUDNN_VERSION}_cuda12-archive.tar.xz
77+
cp -a cudnn-linux-x86_64-${CUDNN_VERSION}_cuda12-archive/include/* /usr/local/cuda/include/
78+
cp -a cudnn-linux-x86_64-${CUDNN_VERSION}_cuda12-archive/lib/* /usr/local/cuda/lib64/
79+
cd ..
80+
rm -rf tmp_cudnn
81+
82+
# NCCL license: https://docs.nvidia.com/deeplearning/nccl/#licenses
83+
# Follow build: https://github.com/NVIDIA/nccl/tree/master?tab=readme-ov-file#build
84+
git clone -b $NCCL_VERSION --depth 1 https://github.com/NVIDIA/nccl.git
85+
cd nccl && make -j src.build
86+
cp -a build/include/* /usr/local/cuda/include/
87+
cp -a build/lib/* /usr/local/cuda/lib64/
88+
cd ..
89+
rm -rf nccl
90+
91+
install_cusparselt_052
92+
93+
ldconfig
94+
}
95+
96+
function install_124 {
97+
echo "Installing CUDA 12.4 and cuDNN ${CUDNN_VERSION} and NCCL ${NCCL_VERSION} and cuSparseLt-0.5.2"
98+
rm -rf /usr/local/cuda-12.4 /usr/local/cuda
99+
# install CUDA 12.4.0 in the same container
100+
wget -q https://developer.download.nvidia.com/compute/cuda/12.4.0/local_installers/cuda_12.4.0_550.54.14_linux.run
101+
chmod +x cuda_12.4.0_550.54.14_linux.run
102+
./cuda_12.4.0_550.54.14_linux.run --toolkit --silent
103+
rm -f cuda_12.4.0_550.54.14_linux.run
104+
rm -f /usr/local/cuda && ln -s /usr/local/cuda-12.4 /usr/local/cuda
105+
106+
# cuDNN license: https://developer.nvidia.com/cudnn/license_agreement
107+
mkdir tmp_cudnn && cd tmp_cudnn
108+
wget -q https://developer.download.nvidia.com/compute/cudnn/redist/cudnn/linux-x86_64/cudnn-linux-x86_64-${CUDNN_VERSION}_cuda12-archive.tar.xz -O cudnn-linux-x86_64-${CUDNN_VERSION}_cuda12-archive.tar.xz
109+
tar xf cudnn-linux-x86_64-${CUDNN_VERSION}_cuda12-archive.tar.xz
110+
cp -a cudnn-linux-x86_64-${CUDNN_VERSION}_cuda12-archive/include/* /usr/local/cuda/include/
111+
cp -a cudnn-linux-x86_64-${CUDNN_VERSION}_cuda12-archive/lib/* /usr/local/cuda/lib64/
112+
cd ..
113+
rm -rf tmp_cudnn
114+
115+
# NCCL license: https://docs.nvidia.com/deeplearning/nccl/#licenses
116+
# Follow build: https://github.com/NVIDIA/nccl/tree/master?tab=readme-ov-file#build
117+
git clone -b $NCCL_VERSION --depth 1 https://github.com/NVIDIA/nccl.git
118+
cd nccl && make -j src.build
119+
cp -a build/include/* /usr/local/cuda/include/
120+
cp -a build/lib/* /usr/local/cuda/lib64/
121+
cd ..
122+
rm -rf nccl
123+
124+
install_cusparselt_052
125+
126+
ldconfig
127+
}
128+
129+
function prune_118 {
130+
echo "Pruning CUDA 11.8 and cuDNN"
131+
#####################################################################################
132+
# CUDA 11.8 prune static libs
133+
#####################################################################################
134+
export NVPRUNE="/usr/local/cuda-11.8/bin/nvprune"
135+
export CUDA_LIB_DIR="/usr/local/cuda-11.8/lib64"
136+
137+
export GENCODE="-gencode arch=compute_35,code=sm_35 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_70,code=sm_70 -gencode arch=compute_75,code=sm_75 -gencode arch=compute_80,code=sm_80 -gencode arch=compute_86,code=sm_86 -gencode arch=compute_90,code=sm_90"
138+
export GENCODE_CUDNN="-gencode arch=compute_35,code=sm_35 -gencode arch=compute_37,code=sm_37 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_61,code=sm_61 -gencode arch=compute_70,code=sm_70 -gencode arch=compute_75,code=sm_75 -gencode arch=compute_80,code=sm_80 -gencode arch=compute_86,code=sm_86 -gencode arch=compute_90,code=sm_90"
139+
140+
if [[ -n "$OVERRIDE_GENCODE" ]]; then
141+
export GENCODE=$OVERRIDE_GENCODE
142+
fi
143+
144+
# all CUDA libs except CuDNN and CuBLAS (cudnn and cublas need arch 3.7 included)
145+
ls $CUDA_LIB_DIR/ | grep "\.a" | grep -v "culibos" | grep -v "cudart" | grep -v "cudnn" | grep -v "cublas" | grep -v "metis" \
146+
| xargs -I {} bash -c \
147+
"echo {} && $NVPRUNE $GENCODE $CUDA_LIB_DIR/{} -o $CUDA_LIB_DIR/{}"
148+
149+
# prune CuDNN and CuBLAS
150+
$NVPRUNE $GENCODE_CUDNN $CUDA_LIB_DIR/libcublas_static.a -o $CUDA_LIB_DIR/libcublas_static.a
151+
$NVPRUNE $GENCODE_CUDNN $CUDA_LIB_DIR/libcublasLt_static.a -o $CUDA_LIB_DIR/libcublasLt_static.a
152+
153+
#####################################################################################
154+
# CUDA 11.8 prune visual tools
155+
#####################################################################################
156+
export CUDA_BASE="/usr/local/cuda-11.8/"
157+
rm -rf $CUDA_BASE/libnvvp $CUDA_BASE/nsightee_plugins $CUDA_BASE/nsight-compute-2022.3.0 $CUDA_BASE/nsight-systems-2022.4.2/
158+
}
159+
160+
function prune_121 {
161+
echo "Pruning CUDA 12.1"
162+
####################################################################### 10000 ##############
163+
# CUDA 12.1 prune static libs
164+
#####################################################################################
165+
export NVPRUNE="/usr/local/cuda-12.1/bin/nvprune"
166+
export CUDA_LIB_DIR="/usr/local/cuda-12.1/lib64"
167+
168+
export GENCODE="-gencode arch=compute_50,code=sm_50 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_70,code=sm_70 -gencode arch=compute_75,code=sm_75 -gencode arch=compute_80,code=sm_80 -gencode arch=compute_86,code=sm_86 -gencode arch=compute_90,code=sm_90"
169+
export GENCODE_CUDNN="-gencode arch=compute_50,code=sm_50 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_61,code=sm_61 -gencode arch=compute_70,code=sm_70 -gencode arch=compute_75,code=sm_75 -gencode arch=compute_80,code=sm_80 -gencode arch=compute_86,code=sm_86 -gencode arch=compute_90,code=sm_90"
170+
171+
if [[ -n "$OVERRIDE_GENCODE" ]]; then
172+
export GENCODE=$OVERRIDE_GENCODE
173+
fi
174+
175+
# all CUDA libs except CuDNN and CuBLAS
176+
ls $CUDA_LIB_DIR/ | grep "\.a" | grep -v "culibos" | grep -v "cudart" | grep -v "cudnn" | grep -v "cublas" | grep -v "metis" \
177+
| xargs -I {} bash -c \
178+
"echo {} && $NVPRUNE $GENCODE $CUDA_LIB_DIR/{} -o $CUDA_LIB_DIR/{}"
179+
180+
# prune CuDNN and CuBLAS
181+
$NVPRUNE $GENCODE_CUDNN $CUDA_LIB_DIR/libcublas_static.a -o $CUDA_LIB_DIR/libcublas_static.a
182+
$NVPRUNE $GENCODE_CUDNN $CUDA_LIB_DIR/libcublasLt_static.a -o $CUDA_LIB_DIR/libcublasLt_static.a
183+
184+
#####################################################################################
185+
# CUDA 12.1 prune visual tools
186+
#####################################################################################
187+
export CUDA_BASE="/usr/local/cuda-12.1/"
188+
rm -rf $CUDA_BASE/libnvvp $CUDA_BASE/nsightee_plugins $CUDA_BASE/nsight-compute-2023.1.0 $CUDA_BASE/nsight-systems-2023.1.2/
189+
}
190+
191+
function prune_124 {
192+
echo "Pruning CUDA 12.4"
193+
#####################################################################################
194+
# CUDA 12.4 prune static libs
195+
#####################################################################################
196+
export NVPRUNE="/usr/local/cuda-12.4/bin/nvprune"
197+
export CUDA_LIB_DIR="/usr/local/cuda-12.4/lib64"
198+
199+
export GENCODE="-gencode arch=compute_50,code=sm_50 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_70,code=sm_70 -gencode arch=compute_75,code=sm_75 -gencode arch=compute_80,code=sm_80 -gencode arch=compute_86,code=sm_86 -gencode arch=compute_90,code=sm_90"
200+
export GENCODE_CUDNN="-gencode arch=compute_50,code=sm_50 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_61,code=sm_61 -gencode arch=compute_70,code=sm_70 -gencode arch=compute_75,code=sm_75 -gencode arch=compute_80,code=sm_80 -gencode arch=compute_86,code=sm_86 -gencode arch=compute_90,code=sm_90"
201+
202+
if [[ -n "$OVERRIDE_GENCODE" ]]; then
203+
export GENCODE=$OVERRIDE_GENCODE
204+
fi
205+
if [[ -n "$OVERRIDE_GENCODE_CUDNN" ]]; then
206+
export GENCODE_CUDNN=$OVERRIDE_GENCODE_CUDNN
207+
fi
208+
209+
# all CUDA libs except CuDNN and CuBLAS
210+
ls $CUDA_LIB_DIR/ | grep "\.a" | grep -v "culibos" | grep -v "cudart" | grep -v "cudnn" | grep -v "cublas" | grep -v "metis" \
211+
| xargs -I {} bash -c \
212+
"echo {} && $NVPRUNE $GENCODE $CUDA_LIB_DIR/{} -o $CUDA_LIB_DIR/{}"
213+
214+
# prune CuDNN and CuBLAS
215+
$NVPRUNE $GENCODE_CUDNN $CUDA_LIB_DIR/libcublas_static.a -o $CUDA_LIB_DIR/libcublas_static.a
216+
$NVPRUNE $GENCODE_CUDNN $CUDA_LIB_DIR/libcublasLt_static.a -o $CUDA_LIB_DIR/libcublasLt_static.a
217+
218+
#####################################################################################
219+
# CUDA 12.1 prune visual tools
220+
#####################################################################################
221+
export CUDA_BASE="/usr/local/cuda-12.4/"
222+
rm -rf $CUDA_BASE/libnvvp $CUDA_BASE/nsightee_plugins $CUDA_BASE/nsight-compute-2024.1.0 $CUDA_BASE/nsight-systems-2023.4.4/
223+
}
224+
225+
# idiomatic parameter and option handling in sh
226+
while test $# -gt 0
227+
do
228+
case "$1" in
229+
11.8) install_118; prune_118
230+
;;
231+
12.1) install_121; prune_121
232+
;;
233+
12.4) install_124; prune_124
234+
;;
235+
*) echo "bad argument $1"; exit 1
236+
;;
237+
esac
238+
shift
239+
done

manywheel/build_cuda.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,20 @@ case ${CUDA_VERSION} in
8585
;;
8686
esac
8787

88+
if [[ -n "$OVERRIDE_TORCH_CUDA_ARCH_LIST" ]]; then
89+
TORCH_CUDA_ARCH_LIST="$OVERRIDE_TORCH_CUDA_ARCH_LIST"
90+
91+
# Prune CUDA again with new arch list. Unfortunately, we need to re-install CUDA to prune it again
92+
override_gencode=""
93+
for arch in ${TORCH_CUDA_ARCH_LIST//;/ } ; do
94+
arch_code=$(echo "$arch" | tr -d .)
95+
override_gencode="${override_gencode}-gencode arch=compute_$arch_code,code=sm_$arch_code "
96+
done
97+
98+
export OVERRIDE_GENCODE=$override_gencode
99+
bash "$(dirname "$SCRIPTPATH")"/common/install_cuda.sh "${CUDA_VERSION}"
100+
fi
101+
88102
export TORCH_CUDA_ARCH_LIST=${TORCH_CUDA_ARCH_LIST}
89103
echo "${TORCH_CUDA_ARCH_LIST}"
90104

0 commit comments

Comments
 (0)
0