Error running CTranslate2 conversion

Hi

I installed & ran the conversion as directed in the quick start section
pip install --upgrade pip
pip install ctranslate2
pip install OpenNMT-py
I get this error:
Traceback (most recent call last):
File “/home/hihoan/.local/bin/ct2-opennmt-py-converter”, line 8, in
sys.exit(main())
File “/home/hihoan/.local/lib/python3.8/site-packages/ctranslate2/bin/opennmt_py_converter.py”, line 13, in main
converters.OpenNMTPyConverter(args.model_path).convert_from_args(args)
File “/home/hihoan/.local/lib/python3.8/site-packages/ctranslate2/converters/converter.py”, line 31, in convert_from_args
return self.convert(
File “/home/hihoan/.local/lib/python3.8/site-packages/ctranslate2/converters/converter.py”, line 45, in convert
model_spec = self._load()
File “/home/hihoan/.local/lib/python3.8/site-packages/ctranslate2/converters/opennmt_py.py”, line 60, in _load
checkpoint = torch.load(self._model_path, map_location=“cpu”)
File “/usr/local/lib/python3.8/dist-packages/torch/serialization.py”, line 584, in load
return _load(opened_zipfile, map_location, pickle_module, **pickle_load_args)
File “/usr/local/lib/python3.8/dist-packages/torch/serialization.py”, line 842, in _load
result = unpickler.load()
ModuleNotFoundError: No module named ‘onmt’

Just wondering what OS, python version this was tested on and how I can fix the issue? Mine is Ubuntu 20.04, python 3.8.5

Hello,

The error indicates that Python can’t find the OpenNMT-py installation. Can you check it is correctly installed and the version is recent?

pip install --upgrade OpenNMT-py

I confirm we expect the conversion to work fine on Ubuntu 20.04 + Python 3.8. I just converted the quickstart model yesterday in these settings.

ah thanks guillaume

All good now.

This and other issues FYI. None of these are showstoppers for me but if you want more info just howl:

  1. I think I was mixing my conda & python env. Straightened it out and made sure those things are installed and it works as expected.
    OpenNMT-py 2.1.2
    OpenNMT-tf 2.19.0

  2. The ct2 converter needed the following args to run, (line 74 & 88 in the README.md):
    –model_spec TransformerBase

  3. there is a link error when compiling ctranslate2

    /usr/bin/ld: …/libctranslate2.so: undefined reference to `cblas_sgemm_batch_strided’

    My mkl is installed via apt install

      # apt list | grep mkl
     intel-mkl-cluster/focal 2020.0.166-1 amd64
     intel-mkl-doc/focal,now 2020.0.166-1 all [installed,automatic].....
    
  4. cmake isn’t successful on my WIndows/WSL laptop (Ubuntu 20.04), either using either

    cmake -DWITH_MKL=ON  ..
    
    cmake   ..
    

    Maybe because I installed mkl differently.

Thanks for raising these points!

This argument was removed recently, in the latest major version. Make sure you have the latest source or package.

This function was added in Intel MKL 2020.2 but we check for that in the code:

Do you have multiple versions of Intel MKL installed on your system? I just installed the package intel-mkl-64bit-2020.0-088 in a fresh Ubuntu 20.04 Docker container and compilation works fine.

What is the error in this case?

  1. righto. I have the following latest versions installed. Will remember when it gets updated
    OpenNMT-py 2.1.2
    OpenNMT-tf 2.19.0

  2. ah yes, there’s a older mkl installed in /opt. However, on Linux or WSL where it isn’t installed, then a cmake error. I remember mkl ask whether to install it as the default blas. I said yes and I can’t seem to be able to change it. Guess this is the reason why cmake can’t see it. Output below:

    cmake -DWITH_MKL=ON …
    – The C compiler identification is GNU 9.3.0
    – The CXX compiler identification is GNU 9.3.0
    – Check for working C compiler: /usr/bin/cc
    – Check for working C compiler: /usr/bin/cc – works
    – Detecting C compiler ABI info
    – Detecting C compiler ABI info - done
    – Detecting C compile features
    – Detecting C compile features - done
    – Check for working CXX compiler: /usr/bin/c++
    – Check for working CXX compiler: /usr/bin/c++ – works
    – Detecting CXX compiler ABI info
    – Detecting CXX compiler ABI info - done
    – Detecting CXX compile features
    – Detecting CXX compile features - done
    – Looking for pthread.h
    – Looking for pthread.h - found
    – Performing Test CMAKE_HAVE_LIBC_PTHREAD
    – Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
    – Looking for pthread_create in pthreads
    – Looking for pthread_create in pthreads - not found
    – Looking for pthread_create in pthread
    – Looking for pthread_create in pthread - found
    – Found Threads: TRUE
    – Looking for dlfcn.h
    – Looking for dlfcn.h - found
    – Looking for getauxval
    – Looking for getauxval - found
    – Compiling for multiple CPU ISA and enabling runtime dispatch
    – Found OpenMP_C: -fopenmp (found version “4.5”)
    – Found OpenMP_CXX: -fopenmp (found version “4.5”)
    – Found OpenMP: TRUE (found version “4.5”)
    – Using OpenMP: /usr/lib/x86_64-linux-gnu/libiomp5.so
    CMake Error at CMakeLists.txt:229 (message):
    MKL include directory not found

– Configuring incomplete, errors occurred!
See also “/mnt/c/Users/hihoan/workspace/github/CTranslate2/build/CMakeFiles/CMakeOutput.log”.
See also “/mnt/c/Users/hihoan/workspace/github/CTranslate2/build/CMakeFiles/CMakeError.log”.

Hi @guillaumekln,

I met below error when test the command refer to the tutorial.

I ran pip install --upgrade OpenNMT-py already before running above command.

Any advice much appreciate.
Regards,
Jim