OSError: libnccl.so.2: cannot open shared object file: No such file or directory

Package is installed as follow

!python3 -m pip install -U pip
!python3 -m pip install -U setuptools wheel
!python3 -m pip install -U "mxnet_cu110<2.0.0"

nvcc --version output

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2020 NVIDIA Corporation
Built on Wed_Jul_22_19:09:09_PDT_2020
Cuda compilation tools, release 11.0, V11.0.221
Build cuda_11.0_bu.TC445_37.28845127_0

Ubunto version

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.5 LTS"
NAME="Ubuntu"
VERSION="18.04.5 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.5 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic

Error

    OSErrorTraceback (most recent call last)
    <ipython-input-1-1eadd2d362f9> in <module>
    ----> 1 import mxnet

    /usr/local/lib/python3.6/dist-packages/mxnet/__init__.py in <module>
         21 """MXNet: a concise, fast and flexible framework for deep learning."""
         22 
    ---> 23 from .context import Context, current_context, cpu, gpu, cpu_pinned
         24 from . import engine, error
         25 from .base import MXNetError

    /usr/local/lib/python3.6/dist-packages/mxnet/context.py in <module>
         21 import warnings
         22 import ctypes
    ---> 23 from .base import classproperty, with_metaclass, _MXClassPropertyMetaClass
         24 from .base import _LIB
         25 from .base import check_call

    /usr/local/lib/python3.6/dist-packages/mxnet/base.py in <module>
        349 __version__ = libinfo.__version__
        350 # library instance of mxnet
    --> 351 _LIB = _load_lib()
        352 
        353 # type definitions

    /usr/local/lib/python3.6/dist-packages/mxnet/base.py in _load_lib()
        340     """Load library by searching possible path."""
        341     lib_path = libinfo.find_lib_path()
    --> 342     lib = ctypes.CDLL(lib_path[0], ctypes.RTLD_LOCAL)
        343     # DMatrix functions
        344     lib.MXGetLastError.restype = ctypes.c_char_p

    /usr/lib/python3.6/ctypes/__init__.py in __init__(self, name, mode, handle, use_errno, use_last_error)
        346 
        347         if handle is None:
    --> 348             self._handle = _dlopen(self._name, mode)
        349         else:
        350             self._handle = handle

    OSError: libnccl.so.2: cannot open shared object file: No such file or directory

I also installed nccl as follow

    * $ wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-ubuntu1804.pin
    * $ sudo mv cuda-ubuntu1804.pin /etc/apt/preferences.d/cuda-repository-pin-600
    * $ sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub
    * $ sudo add-apt-repository "deb http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/ /"
    * $ sudo apt-get update

Did you install NCCL?

sudo apt install libnccl2

After installing nccl as talhaanwarch did, and then doing sudo apt install libnccl2, this solved the issue for me.

1 Like

Glad to hear that it worked for you. Thanks for the feedback.

The same issue on Ubuntu 22.04, apt install cannot locate libnccl2