install_nccl2.sh 2.4 KB
Newer Older
T
tianshuo78520a 已提交
1
#!/bin/bash
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
# 
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# 
#     http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

T
tianshuo78520a 已提交
17 18 19
VERSION=$(nvcc --version | grep release | grep -oEi "release ([0-9]+)\.([0-9])"| sed "s/release //")
if [ "$VERSION" == "10.0" ]; then
  DEB="nccl-repo-ubuntu1604-2.4.7-ga-cuda10.0_1-1_amd64.deb"
20
elif [ "$VERSION" == "10.2" ] || [ "$VERSION" == "10.1" ] || [ "$VERSION" == "11.0" ] || [ "$VERSION" == "11.2" ] || [ "$VERSION" == "11.3" ] || [ "$VERSION" == "11.4" ] || [ "$VERSION" == "11.5" ] || [ "$VERSION" == "11.6" ]; then
T
tianshuo78520a 已提交
21
  if [ -f "/etc/redhat-release" ];then
22 23 24 25 26 27
    rm -f /usr/local/lib/libnccl.so 
    wget --no-check-certificate -q https://nccl2-deb.cdn.bcebos.com/libnccl-2.7.8-1+cuda10.2.x86_64.rpm
    wget --no-check-certificate -q https://nccl2-deb.cdn.bcebos.com/libnccl-devel-2.7.8-1+cuda10.2.x86_64.rpm
    wget --no-check-certificate -q https://nccl2-deb.cdn.bcebos.com/libnccl-static-2.7.8-1+cuda10.2.x86_64.rpm
    rpm -ivh libnccl-2.7.8-1+cuda10.2.x86_64.rpm
    rpm -ivh libnccl-devel-2.7.8-1+cuda10.2.x86_64.rpm
T
tianshuo78520a 已提交
28
    rpm -ivh libnccl-static-2.7.8-1+cuda10.2.x86_64.rpm && rm -f libnccl-*
29 30 31
    exit 0
  fi
  DEB="nccl-repo-ubuntu1604-2.7.8-ga-cuda10.2_1-1_amd64.deb"
T
tianshuo78520a 已提交
32 33 34
elif [ "$VERSION" == "9.0" ]; then
  DEB="nccl-repo-ubuntu1604-2.3.7-ga-cuda9.0_1-1_amd64.deb"
else
T
tianshuo78520a 已提交
35 36
  echo "nccl not found"
  exit 2
T
tianshuo78520a 已提交
37 38
fi

T
tianshuo78520a 已提交
39
URL="http://nccl2-deb.cdn.bcebos.com/$DEB"
T
tianshuo78520a 已提交
40 41 42 43 44

DIR="/nccl2"
mkdir -p $DIR
# we cached the nccl2 deb package in BOS, so we can download it with wget
# install nccl2: http://docs.nvidia.com/deeplearning/sdk/nccl-install-guide/index.html#down
T
tianshuo78520a 已提交
45
wget -q -O $DIR/$DEB $URL
T
tianshuo78520a 已提交
46 47 48 49

cd $DIR && ar x $DEB && tar xf data.tar.xz
DEBS=$(find ./var/ -name "*.deb")
for sub_deb in $DEBS; do
I
iducn 已提交
50 51
  echo $sub_deb
  ar x $sub_deb && tar xf data.tar.xz
T
tianshuo78520a 已提交
52 53 54
done
mv -f usr/include/nccl.h /usr/local/include/
mv -f usr/lib/x86_64-linux-gnu/libnccl* /usr/local/lib/
T
tianshuo78520a 已提交
55
rm /usr/include/nccl.h
T
tianshuo78520a 已提交
56
rm -rf $DIR