Building CTranslate2 From Source

Hello!

I’m trying to build CTranslate2 from source after customising the code in python/translator.cc file.
I’m using the guide here: https://opennmt.net/CTranslate2/installation.html
When I install the python package on the same computer where I built it, it works. But when I install the python package on a different computer from my private artifactory, it doesn’t work - when I’m running the following code:

from ctranslate2 import Translator

I get the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/conda/envs/arty_env/lib/python3.9/site-packages/ctranslate2/__init__.py", line 21, in <module>
    from ctranslate2._ext import (
ImportError: libctranslate2.so.4: cannot open shared object file: No such file or directory

I suspect that the C++ stuff is not included in the python package build (the resulting .whl file is just ~500kb).
I did pay attention to the “Attention” section in the install guide. It looks like the install directory of CTranslate2 in the computer that builds it is in “/home/ubuntu/my_ctranslate2”, so I did: export CTRANSLATE2_ROOT=/home/ubuntu/my_ctranslate2, but it didn’t help.

More Info:
This is my cmake command:

make -DWITH_CUDA=ON -DWITH_CUDNN=ON -DWITH_DNNL=ON -DCUDA_DYNAMIC_LOADING=ON -DCMAKE_INSTALL_PREFIX=/home/ubuntu/my_ctranslate2 ..

and I also ran sudo ldconfig

I would be happy if you can help me with this problem :slight_smile:

1 Like

Hello!

Maybe try to add the path as in here:

If this does not work, feel free to open an issue at GitHub.

1 Like

Hi @ymoslem, thank you for your reply.

I also followed this suggestion.
I edited the LD_LIBRARY_PATH environment variable like this:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CTRANSLATE2_ROOT/lib

then I ran:

python setup.py bdist_wheel --dist-dir $CTRANSLATE2_ROOT

but the resulting .whl file is still small and doesn’t contain the libctranslate2.so file.
I will keep trying to make it work, I will open an issue in Github if I won’t make any progress.

1 Like

I opened an issue in GitHub:
https://github.com/OpenNMT/CTranslate2/issues/1654