cupy / cupy

NumPy & SciPy for GPU

Home Page:https://cupy.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`cupy.show_config()` does not work when libcudart does not exist

leofang opened this issue · comments

Description

Originally reported by @adrinjalali in #8152, verified locally. show_config() tries to load the local libcudart to report the local runtime version, and it'd fail if libcudart does not exist, but it should not.

To Reproduce

$ LD_LIBRARY_PATH= CUDA_VISIBLE_DEVICES= python -c "import cupy as cp; cp.show_config()"
Traceback (most recent call last):
  File "cupy_backends/cuda/_softlink.pyx", line 25, in cupy_backends.cuda._softlink.SoftLink.__init__
    self._cdll = ctypes.CDLL(libname)
  File "/home/leof/miniforge3/envs/cupy_cuda122_dev/lib/python3.10/ctypes/__init__.py", line 374, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: libcudart.so.12: cannot open shared object file: No such file or directory

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/leof/dev/cupy_cuda122/cupy/__init__.py", line 912, in show_config
    _sys.stdout.write(str(_cupyx.get_runtime_info(full=_full)))
  File "/home/leof/dev/cupy_cuda122/cupyx/_runtime.py", line 319, in get_runtime_info
    return _RuntimeInfo(full=full)
  File "/home/leof/dev/cupy_cuda122/cupyx/_runtime.py", line 123, in __init__
    self.cuda_local_runtime_version = _eval_or_error(
  File "/home/leof/dev/cupy_cuda122/cupyx/_runtime.py", line 21, in _eval_or_error
    return func()
  File "/home/leof/dev/cupy_cuda122/cupy/cuda/__init__.py", line 113, in get_local_runtime_version
    return runtime._getLocalRuntimeVersion()
  File "cupy_backends/cuda/api/runtime.pyx", line 187, in cupy_backends.cuda.api.runtime._getLocalRuntimeVersion
    cpdef int _getLocalRuntimeVersion() except? -1:
  File "cupy_backends/cuda/api/runtime.pyx", line 189, in cupy_backends.cuda.api.runtime._getLocalRuntimeVersion
    initialize()
  File "cupy_backends/cuda/api/_runtime_softlink.pxi", line 20, in cupy_backends.cuda.api.runtime.initialize
    _initialize()
  File "cupy_backends/cuda/api/_runtime_softlink.pxi", line 25, in cupy_backends.cuda.api.runtime._initialize
    _L = _get_softlink()
  File "cupy_backends/cuda/api/_runtime_softlink.pxi", line 53, in cupy_backends.cuda.api.runtime._get_softlink
    return SoftLink(libname, prefix, mandatory=True)
  File "cupy_backends/cuda/_softlink.pyx", line 32, in cupy_backends.cuda._softlink.SoftLink.__init__
    raise RuntimeError(msg) from e
RuntimeError: CuPy failed to load libcudart.so.12: OSError: libcudart.so.12: cannot open shared object file: No such file or directory

Installation

Built from GitHub source

Environment

CuPy v13.0.0.

Additional Information

No response