LieTorch - "OSError: libtorch_cuda_cpp.so: cannot open shared object file: No such file or directory"

Hello everyone,

I am trying to use Lietorch within a docker container with the following Dockerfile:

FROM nvidia/cuda:11.8.0-devel-ubuntu22.04

WORKDIR /app

COPY . .

SHELL ["/bin/bash", "-c"]

RUN apt-get update && apt-get install -y python3 python3-pip nano
RUN pip install --no-cache-dir numpy==2.0
RUN pip install --no-cache-dir torch==2.0.0+cu118 \
    --index-url https://download.pytorch.org/whl/cu118 && \
    pip cache purge
RUN pip install --no-cache-dir lietorch==0.6 && \
    pip cache purge
RUN pip install torchvision==0.15.0+cu118 \
    --index-url https://download.pytorch.org/whl/cu118 && pip cache purge

I have selected these versions to avoid conflicts and errors (after many trials), but I still get this error:

>>> import lietorch
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.10/dist-packages/lietorch/__init__.py", line 75, in <module>
    _init_backend()
  File "/usr/local/lib/python3.10/dist-packages/lietorch/__init__.py", line 55, in _init_backend
    torch.ops.load_library(libpath)
  File "/usr/local/lib/python3.10/dist-packages/torch/_ops.py", line 643, in load_library
    ctypes.CDLL(path)
  File "/usr/lib/python3.10/ctypes/__init__.py", line 374, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: libtorch_cuda_cpp.so: cannot open shared object file: No such file or directory

I have checked related posts, such as “https://discuss.pytorch.org/t/oserror-libtorch-cuda-so-cannot-open-shared-object-file-no-such-file-or-directory/223006“, but nothing helped.

Thanks in advance!

libtorch_cuda was split into the _cu and _cpp sublibs a while ago as we were otherwise running into size limitations and linker errors. These sublibs do not exist for a long time already (unsure when exactly they were merged) and you should thus open libtorch_cuda.so only if really needed.

Based on this it seems your package expects an older PyTorch build where these sublibs existed.