NCCL+Ubuntu20.04安装

目录

1、下载deb包

2、Install the repository

(1)For a local NCCL repository

(2)For the network repository

3、Update the APT database

4、Install the libnccl2 package with APT

5、添加环境变量


NVIDIA Collective Communications Library (NCCL) Legacy Download Page:

https://developer.nvidia.com/nccl/nccl-legacy-downloads

Installation Guide:

Installation Guide :: NVIDIA Deep Learning NCCL Documentation

3. Installing NCCL

In order to download NCCL, ensure you are registered for the NVIDIA Developer Program.

  1. Go to: NVIDIA NCCL home page.
  2. Click Download.
  3. Complete the short survey and click Submit.
  4. Accept the Terms and Conditions. A list of available download versions of NCCL displays.
  5. Select the NCCL version you want to install. A list of available resources displays. Refer to the following sections to choose the correct package depending on the Linux distribution you are using.

3.1. Ubuntu

Installing NCCL on Ubuntu requires you to first add a repository to the APT system containing the NCCL packages, then installing the NCCL packages through APT. There are two repositories available; a local repository and a network repository. Choosing the latter is recommended to easily retrieve upgrades when newer versions are posted.

In the following commands, please replace <architecture> with your CPU architecture: x86_64, ppc64le, or sbsa, and replace <distro> with the Ubuntu version, for example ubuntu1604, ubuntu1804, or ubuntu2004.

  1. Install the repository.
    • For a local NCCL repository:
      sudo dpkg -i nccl-repo-<version>.deb
      Note:

      The local repository installation will prompt you to install the local key it embeds and with which packages are signed. Make sure to follow the instructions to install the local key, or the install phase will fail later.

    • For the network repository:
      wget https://developer.download.nvidia.com/compute/cuda/repos/<distro>/<architecture>/cuda-keyring_1.0-1_all.deb
      sudo dpkg -i cuda-keyring_1.0-1_all.deb
  2. Update the APT database:
    sudo apt update
  3. Install the libnccl2 package with APT. Additionally, if you need to compile applications with NCCL, you can install the libnccl-dev package as well:

    Note: If you are using the network repository, the following command will upgrade CUDA to the latest version.

    sudo apt install libnccl2 libnccl-dev
    If you prefer to keep an older version of CUDA, specify a specific version, for example:
    sudo apt install libnccl2=2.4.8-1+cuda10.0 libnccl-dev=2.4.8-1+cuda10.0
    Refer to the download page for exact package versions.

1、下载deb包

本次选择安装Local installer for Ubuntu 20.04

 下载后获得的文件:nccl-local-repo-ubuntu2004-2.8.4-cuda11.2_1.0-1_amd64.deb

2、Install the repository

(1)For a local NCCL repository

sudo dpkg -i nccl-repo-<version>.deb

根据实际文件名修改命令,此处为:

$ sudo dpkg -i nccl-local-repo-ubuntu2004-2.8.4-cuda11.2_1.0-1_amd64.deb
Selecting previously unselected package nccl-local-repo-ubuntu2004-2.8.4-cuda11.2.
(Reading database ... 230937 files and directories currently installed.)
Preparing to unpack nccl-local-repo-ubuntu2004-2.8.4-cuda11.2_1.0-1_amd64.deb ...
Unpacking nccl-local-repo-ubuntu2004-2.8.4-cuda11.2 (1.0-1) ...
Setting up nccl-local-repo-ubuntu2004-2.8.4-cuda11.2 (1.0-1) ...

The public CUDA GPG key does not appear to be installed.
To install the key, run this command:
sudo apt-key add /var/nccl-local-repo-ubuntu2004-2.8.4-cuda11.2/7fa2af80.pu

(2)For the network repository

wget https://developer.download.nvidia.com/compute/cuda/repos/<distro>/<architecture>/cuda-keyring_1.0-1_all.deb

sudo dpkg -i cuda-keyring_1.0-1_all.deb

其中,

<architecture> 根据CPU架构修改:x86_64, ppc64le, or sbsa

<distro>根据ubuntu版本修改:ubuntu1604, ubuntu1804, or ubuntu2004

此处为:

$ wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-keyring_1.0-1_all.deb
--2022-10-26 20:44:28--  https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-keyring_1.0-1_all.deb
Resolving developer.download.nvidia.com (developer.download.nvidia.com)... 152.199.39.144
Connecting to developer.download.nvidia.com (developer.download.nvidia.com)|152.199.39.144|:443... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://developer.download.nvidia.cn/compute/cuda/repos/ubuntu2004/x86_64/cuda-keyring_1.0-1_all.deb [following]
--2022-10-26 20:44:30--  https://developer.download.nvidia.cn/compute/cuda/repos/ubuntu2004/x86_64/cuda-keyring_1.0-1_all.deb
Resolving developer.download.nvidia.cn (developer.download.nvidia.cn)... 222.243.53.99, 59.36.216.27, 59.36.216.26, ...
Connecting to developer.download.nvidia.cn (developer.download.nvidia.cn)|222.243.53.99|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 4328 (4.2K) [application/x-deb]
Saving to: ‘cuda-keyring_1.0-1_all.deb’

cuda-keyring_1.0-1_ 100%[===================>]   4.23K  --.-KB/s    in 0s      

2022-10-26 20:44:30 (437 MB/s) - ‘cuda-keyring_1.0-1_all.deb’ saved [4328/4328]

$ sudo dpkg -i cuda-keyring_1.0-1_all.deb
Selecting previously unselected package cuda-keyring.
(Reading database ... 230948 files and directories currently installed.)
Preparing to unpack cuda-keyring_1.0-1_all.deb ...
Unpacking cuda-keyring (1.0-1) ...
Setting up cuda-keyring (1.0-1) ...

3、Update the APT database

sudo apt update

否则会找不到接下来的packages

4、Install the libnccl2 package with APT

如果你需要用NCCL编译应用程序,可以安装libccl -dev包

sudo apt install libnccl2 libnccl-dev

如果需要更旧版本的CUDA,可以:

sudo apt install libnccl2=2.4.8-1+cuda10.0 libnccl-dev=2.4.8-1+cuda10.0

本次为:

$ sudo apt install libnccl2 libnccl-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  libnccl-dev libnccl2
0 upgraded, 2 newly installed, 0 to remove and 3 not upgraded.
Need to get 196 MB of archives.
After this operation, 542 MB of additional disk space will be used.
Get:1 https://developer.download.nvidia.cn/compute/cuda/repos/ubuntu2004/x86_64  libnccl2 2.15.5-1+cuda11.8 [97.5 MB]
Get:2 https://developer.download.nvidia.cn/compute/cuda/repos/ubuntu2004/x86_64  libnccl-dev 2.15.5-1+cuda11.8 [98.1 MB]
Fetched 196 MB in 2min 24s (1,356 kB/s)                                        
Selecting previously unselected package libnccl2.
(Reading database ... 230953 files and directories currently installed.)
Preparing to unpack .../libnccl2_2.15.5-1+cuda11.8_amd64.deb ...
Unpacking libnccl2 (2.15.5-1+cuda11.8) ...
Selecting previously unselected package libnccl-dev.
Preparing to unpack .../libnccl-dev_2.15.5-1+cuda11.8_amd64.deb ...
Unpacking libnccl-dev (2.15.5-1+cuda11.8) ...
Setting up libnccl2 (2.15.5-1+cuda11.8) ...
Setting up libnccl-dev (2.15.5-1+cuda11.8) ...
Processing triggers for libc-bin (2.31-0ubuntu9.9) ...

5、添加环境变量

(1)查找nccl安装位置

$ whereis nccl
nccl: /usr/include/nccl.h

修改~/.bashrc

#设置cuda库的目录
export LD_LIBRARY_PATH=/usr/local/cuda-10.0/lib64
#将nccl添加到LD_LIBRARY_PATH中
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/include/nccl.h

因为cuda库已经添加了,所以这次只把nccl添加到LD_LIBRARY_PATH中,即只添加了最后一行

使其生效

source ~/.bashrc

部分参考:ubuntu下安装nccl具体教程_TanH.blog的博客-CSDN博客_ubuntu安装nccl

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值