Giter VIP home page Giter VIP logo

Comments (24)

anderleich avatar anderleich commented on May 18, 2024 1

There was a bug in my script which was writting some file in another directory.
Thanks!

from ctranslate2.

guillaumekln avatar guillaumekln commented on May 18, 2024

Hi,

If you plan to use the Python API, you can simply run pip install ctranslate2 and get access to CPU translation on Linux.

For other use cases, the Dockerfiles specify how to install the dependencies and how to compile the project. A basic CPU build is also described in the README.

What errors did you get?

from ctranslate2.

anderleich avatar anderleich commented on May 18, 2024

These are the logs:
/opt/ctranslate_dependencies/ctranslate2-dev/src/primitives/cpu.cc: In static member function ‘static void ctranslate2::primitives::gemm(const In*, const In*, bool, bool, bool, bool, ctranslate2::dim_t, ctranslate2::dim_t, ctranslate2::dim_t, float, float, Out*, const Out*) [with In = signed char; Out = int; ctranslate2::Device D = (ctranslate2::Device)0; ctranslate2::dim_t = long int]’:
/opt/ctranslate_dependencies/ctranslate2-dev/src/primitives/cpu.cc:836:62: error: invalid conversion from ‘long long int’ to ‘CBLAS_TRANSPOSE’ [-fpermissive]
c, ldc, a_shift_compensation);
^
In file included from /opt/intel/mkl/include/mkl.h:31:0,
from /opt/ctranslate_dependencies/ctranslate2-dev/src/primitives/cpu.cc:14:
/opt/intel/mkl/include/mkl_cblas.h:834:6: note: initializing argument 2 of ‘void cblas_gemm_s8u8s32_compute(CBLAS_LAYOUT, CBLAS_TRANSPOSE, CBLAS_TRANSPOSE, CBLAS_OFFSET, long long int, long long int, long long int, float, const void*, long long int, char, const void*, long long int, char, float, int*, long long int, const int*)’
void cblas_gemm_s8u8s32_compute (const CBLAS_LAYOUT Layout, const CBLAS_TRANSPOSE TransA,
^
/opt/ctranslate_dependencies/ctranslate2-dev/src/primitives/cpu.cc:836:62: error: invalid conversion from ‘long long int’ to ‘CBLAS_TRANSPOSE’ [-fpermissive]
c, ldc, a_shift_compensation);
^

from ctranslate2.

anderleich avatar anderleich commented on May 18, 2024

I'm interested in the GPU part not CPU. Therefore, doing pip install is not an option I considered.
Thanks

from ctranslate2.

guillaumekln avatar guillaumekln commented on May 18, 2024

What is your Intel MKL version?

from ctranslate2.

anderleich avatar anderleich commented on May 18, 2024

I'd like to have the CPU option too. I case GPU is not available.

This is what I do:

MKL_VERSION=2020
MKL_UPDATE=0
MKL_BUILD=088
wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2019.PUB
apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS-.PUB
rm GPG-PUB-KEY-INTEL-SW-PRODUCTS-
.PUB
echo "deb https://apt.repos.intel.com/mkl all main" > /etc/apt/sources.list.d/intel-mkl.list
apt-get update
apt-get install -y --no-install-recommends \
intel-mkl-64bit-$MKL_VERSION.$MKL_UPDATE-$MKL_BUILD
apt-get clean
rm -rf /var/lib/apt/lists/*

from ctranslate2.

guillaumekln avatar guillaumekln commented on May 18, 2024

The lines referenced in the error log do not seem to match the file /opt/intel/mkl/include/mkl_cblas.h included in Intel MKL 2020.0-088. So it seems you are not using the correct Intel MKL version. Can you verify that?

If you don't need CPU execution at all, you can also disable Intel MKL using these flags during CMake configuration: -DWITH_MKL=OFF -DOPENMP_RUNTIME=NONE

from ctranslate2.

anderleich avatar anderleich commented on May 18, 2024

I'm sorry but I'm afraid I can't go any further configuring MKL with the right version
CUDA VERSION 10.1
This is how my script looks like so far:

TENSORRT_MAJOR_VERSION=6
TENSORRT_VERSION=${TENSORRT_MAJOR_VERSION}.0.1

REPOSITORY_DIR=$PWD
DEPENDENCIES_PATH=/opt/ctranslate_dependencies
mkdir -p /opt/ctranslate_dependencies || exit 1
                                                                                                                                        
apt-get update && \                                                                                                                           
    apt-get install -y --no-install-recommends \                                                                                              
        apt-transport-https \                                                                                                                 
        build-essential \                                                                                                                     
        ca-certificates \                                                                                                                     
        python3-dev \                                                                                                                         
        gnupg2 \                                                                                                                              
        libnvinfer${TENSORRT_MAJOR_VERSION}=${TENSORRT_VERSION}-1+cuda10.0 \                                                                  
        libnvinfer-dev=${TENSORRT_VERSION}-1+cuda10.0 \                                                                                       
        wget && \                                                                                                                             
    apt-get clean && \                                                                                                                        
    rm -rf /var/lib/apt/lists/*                                                                                                               

cd $DEPENDENCIES_PATH                                                                                                                                         
wget https://cmake.org/files/v3.12/cmake-3.12.2-Linux-x86_64.tar.gz                                                                           
tar xf cmake-3.12.2-Linux-x86_64.tar.gz                                                                                                       
rm cmake-3.12.2-Linux-x86_64.tar.gz           
                                                                                                
export PATH=$PATH:$DEPENDENCIES_PATH/cmake-3.12.2-Linux-x86_64/bin

MKL_VERSION=2020
MKL_UPDATE=0
MKL_BUILD=088                                                                                                                                        
wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2019.PUB                                                        
apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS-*.PUB 
rm GPG-PUB-KEY-INTEL-SW-PRODUCTS-*.PUB                                                                                                        
echo "deb https://apt.repos.intel.com/mkl all main" > /etc/apt/sources.list.d/intel-mkl.list                                                  
apt-get update                                                                                                                                
apt-get install -y --no-install-recommends \                                                                                                  
        intel-mkl-64bit-$MKL_VERSION.$MKL_UPDATE-$MKL_BUILD                                                                                   
apt-get clean                                                                                                                                 
rm -rf /var/lib/apt/lists/*                                                                                                                   

mkdir -p $DEPENDENCIES_PATH/ctranslate2-dev || exit 1
cd $DEPENDENCIES_PATH/ctranslate2-dev

cp -r $REPOSITORY_DIR/third_party third_party
cp -r $REPOSITORY_DIR/cli cli
cp -r $REPOSITORY_DIR/include include
cp -r $REPOSITORY_DIR/src src
cp $REPOSITORY_DIR/CMakeLists.txt .

export CXX_FLAGS=${CXX_FLAGS}
export CUDA_NVCC_FLAGS=${CUDA_NVCC_FLAGS:-"-Xfatbin -compress-all"}
export CUDA_ARCH_LIST=${CUDA_ARCH_LIST:-"Common"}
export CTRANSLATE2_ROOT=$DEPENDENCIES_DIR/ctranslate2

mkdir -p build
cd build
cmake -D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-10.1 \
      -DCMAKE_INSTALL_PREFIX=${CTRANSLATE2_ROOT} \
      -DWITH_CUDA=ON \
      -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="${CXX_FLAGS}" \
      -DCUDA_NVCC_FLAGS="${CUDA_NVCC_FLAGS}" -DCUDA_ARCH_LIST="${CUDA_ARCH_LIST}" ..
VERBOSE=1 make -j4
make install
`

from ctranslate2.

guillaumekln avatar guillaumekln commented on May 18, 2024

Can you add set -e at the top of the script and run it again? It will stop on the first error.

from ctranslate2.

anderleich avatar anderleich commented on May 18, 2024

This is the log

[ 78%] Building CXX object CMakeFiles/ctranslate2.dir/src/sampling.cc.o
/usr/bin/c++  -DMKL_ILP64 -DWITH_CUDA -DWITH_MKL -DWITH_TENSORRT -Dctranslate2_EXPORTS -I/usr/local/cuda-10.1/include -I/opt/ctranslate_dependencies/ctranslate2-dev/include -I/opt/intel/mkl/include  -Wall -Wextra -ffast-math -m64 -isystem /usr/include/x86_64-linux-gnu -O3 -DNDEBUG -fPIC   -fopenmp -std=gnu++11 -o CMakeFiles/ctranslate2.dir/src/sampling.cc.o -c /opt/ctranslate_dependencies/ctranslate2-dev/src/sampling.cc
/opt/ctranslate_dependencies/ctranslate2-dev/src/primitives/cpu.cc: In static member function ‘static void ctranslate2::primitives<D>::max(const T*, const T*, T*, ctranslate2::dim_t) [with T = float; ctranslate2::Device D = (ctranslate2::Device)0; ctranslate2::dim_t = long int]’:
/opt/ctranslate_dependencies/ctranslate2-dev/src/primitives/cpu.cc:253:25: error: invalid conversion from ‘const float*’ to ‘float*’ [-fpermissive]
     vsFmax(size, a, b, c);
                         ^
In file included from /opt/ctranslate_dependencies/ctranslate2-dev/src/primitives/cpu.cc:14:0:
/opt/intel/mkl/include/mkl_vml_functions.h:1441:16: note:   initializing argument 3 of ‘void vsFmax(long long int, const float*, float*, float*)’
 _Mkl_Api(void, vsFmax, (const MKL_INT n, const float  a[], float  r1[], float  r2[]))
                ^
/opt/intel/mkl/include/mkl.h:23:47: note: in definition of macro ‘_Mkl_Api’
 #define _Mkl_Api(rtype,name,arg) extern rtype name    arg;
                                               ^
/opt/ctranslate_dependencies/ctranslate2-dev/src/primitives/cpu.cc: In static member function ‘static void ctranslate2::primitives<D>::min(const T*, const T*, T*, ctranslate2::dim_t) [with T = float; ctranslate2::Device D = (ctranslate2::Device)0; ctranslate2::dim_t = long int]’:
/opt/ctranslate_dependencies/ctranslate2-dev/src/primitives/cpu.cc:275:25: error: invalid conversion from ‘const float*’ to ‘float*’ [-fpermissive]
     vsFmin(size, a, b, c);
                         ^
In file included from /opt/ctranslate_dependencies/ctranslate2-dev/src/primitives/cpu.cc:14:0:
/opt/intel/mkl/include/mkl_vml_functions.h:1456:16: note:   initializing argument 3 of ‘void vsFmin(long long int, const float*, float*, float*)’
 _Mkl_Api(void, vsFmin, (const MKL_INT n, const float  a[], float  r1[], float  r2[]))
                ^
/opt/intel/mkl/include/mkl.h:23:47: note: in definition of macro ‘_Mkl_Api’
 #define _Mkl_Api(rtype,name,arg) extern rtype name    arg;
                                               ^
/opt/ctranslate_dependencies/ctranslate2-dev/src/primitives/cpu.cc: In static member function ‘static void ctranslate2::primitives<D>::gemm(const In*, const In*, bool, bool, bool, bool, ctranslate2::dim_t, ctranslate2::dim_t, ctranslate2::dim_t, float, float, Out*, const Out*) [with In = short int; Out = int; ctranslate2::Device D = (ctranslate2::Device)0; ctranslate2::dim_t = long int]’:
/opt/ctranslate_dependencies/ctranslate2-dev/src/primitives/cpu.cc:721:47: error: invalid conversion from ‘long long int’ to ‘CBLAS_TRANSPOSE’ [-fpermissive]
                                    c, ldc, &oc);
                                               ^
In file included from /opt/intel/mkl/include/mkl.h:31:0,
                 from /opt/ctranslate_dependencies/ctranslate2-dev/src/primitives/cpu.cc:14:
/opt/intel/mkl/include/mkl_cblas.h:842:6: note:   initializing argument 2 of ‘void cblas_gemm_s16s16s32_compute(CBLAS_LAYOUT, CBLAS_TRANSPOSE, CBLAS_TRANSPOSE, CBLAS_OFFSET, long long int, long long int, long long int, float, const short int*, long long int, short int, const short int*, long long int, short int, float, int*, long long int, const int*)’
 void cblas_gemm_s16s16s32_compute(const  CBLAS_LAYOUT Layout, const CBLAS_TRANSPOSE TransA,
      ^
/opt/ctranslate_dependencies/ctranslate2-dev/src/primitives/cpu.cc:721:47: error: invalid conversion from ‘long long int’ to ‘CBLAS_TRANSPOSE’ [-fpermissive]
                                    c, ldc, &oc);
                                               ^
In file included from /opt/intel/mkl/include/mkl.h:31:0,
                 from /opt/ctranslate_dependencies/ctranslate2-dev/src/primitives/cpu.cc:14:
/opt/intel/mkl/include/mkl_cblas.h:842:6: note:   initializing argument 3 of ‘void cblas_gemm_s16s16s32_compute(CBLAS_LAYOUT, CBLAS_TRANSPOSE, CBLAS_TRANSPOSE, CBLAS_OFFSET, long long int, long long int, long long int, float, const short int*, long long int, short int, const short int*, long long int, short int, float, int*, long long int, const int*)’
 void cblas_gemm_s16s16s32_compute(const  CBLAS_LAYOUT Layout, const CBLAS_TRANSPOSE TransA,
      ^
/opt/ctranslate_dependencies/ctranslate2-dev/src/primitives/cpu.cc: In static member function ‘static void ctranslate2::primitives<D>::gemm(const In*, const In*, bool, bool, bool, bool, ctranslate2::dim_t, ctranslate2::dim_t, ctranslate2::dim_t, float, float, Out*, const Out*) [with In = signed char; Out = int; ctranslate2::Device D = (ctranslate2::Device)0; ctranslate2::dim_t = long int]’:
/opt/ctranslate_dependencies/ctranslate2-dev/src/primitives/cpu.cc:836:62: error: invalid conversion from ‘long long int’ to ‘CBLAS_TRANSPOSE’ [-fpermissive]
                                  c, ldc, a_shift_compensation);
                                                              ^
In file included from /opt/intel/mkl/include/mkl.h:31:0,
                 from /opt/ctranslate_dependencies/ctranslate2-dev/src/primitives/cpu.cc:14:
/opt/intel/mkl/include/mkl_cblas.h:834:6: note:   initializing argument 2 of ‘void cblas_gemm_s8u8s32_compute(CBLAS_LAYOUT, CBLAS_TRANSPOSE, CBLAS_TRANSPOSE, CBLAS_OFFSET, long long int, long long int, long long int, float, const void*, long long int, char, const void*, long long int, char, float, int*, long long int, const int*)’
 void cblas_gemm_s8u8s32_compute  (const  CBLAS_LAYOUT Layout, const CBLAS_TRANSPOSE TransA,
      ^
/opt/ctranslate_dependencies/ctranslate2-dev/src/primitives/cpu.cc:836:62: error: invalid conversion from ‘long long int’ to ‘CBLAS_TRANSPOSE’ [-fpermissive]
                                  c, ldc, a_shift_compensation);
                                                              ^
In file included from /opt/intel/mkl/include/mkl.h:31:0,
                 from /opt/ctranslate_dependencies/ctranslate2-dev/src/primitives/cpu.cc:14:
/opt/intel/mkl/include/mkl_cblas.h:834:6: note:   initializing argument 3 of ‘void cblas_gemm_s8u8s32_compute(CBLAS_LAYOUT, CBLAS_TRANSPOSE, CBLAS_TRANSPOSE, CBLAS_OFFSET, long long int, long long int, long long int, float, const void*, long long int, char, const void*, long long int, char, float, int*, long long int, const int*)’
 void cblas_gemm_s8u8s32_compute  (const  CBLAS_LAYOUT Layout, const CBLAS_TRANSPOSE TransA,
      ^
CMakeFiles/ctranslate2.dir/build.make:553: recipe for target 'CMakeFiles/ctranslate2.dir/src/primitives/cpu.cc.o' failed
make[2]: *** [CMakeFiles/ctranslate2.dir/src/primitives/cpu.cc.o] Error 1
make[2]: *** Waiting for unfinished jobs....
/opt/ctranslate_dependencies/ctranslate2-dev/src/profiler.cc:117:30: warning: unused parameter ‘device’ [-Wunused-parameter]
   void init_profiling(Device device, size_t num_threads) {
                              ^
/opt/ctranslate_dependencies/ctranslate2-dev/src/profiler.cc:117:45: warning: unused parameter ‘num_threads’ [-Wunused-parameter]
   void init_profiling(Device device, size_t num_threads) {
                                             ^
make[2]: Leaving directory '/opt/ctranslate_dependencies/ctranslate2-dev/build'
CMakeFiles/Makefile2:72: recipe for target 'CMakeFiles/ctranslate2.dir/all' failed
make[1]: *** [CMakeFiles/ctranslate2.dir/all] Error 2
make[1]: Leaving directory '/opt/ctranslate_dependencies/ctranslate2-dev/build'
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2

from ctranslate2.

guillaumekln avatar guillaumekln commented on May 18, 2024

I can only think that you installed Intel MKL in the past and its installation was not correctly updated. I suggest removing Intel MKL and installing it again from https://software.intel.com/content/www/us/en/develop/tools/math-kernel-library.html.

from ctranslate2.

anderleich avatar anderleich commented on May 18, 2024

That was the issue! I reinstalled INtel MKL and it succesfully compiled.
However, I've got another error. Apparently CuBlas is missing for Cuda 10.1, which gives an error in the following command:

apt-get install -y --no-install-recommends \
        cuda-cublas-$CUDA_PKG_VERSION \
        python3-distutils-extra \
        wget

https://forums.developer.nvidia.com/t/cublas-for-10-1-is-missing/71015

from ctranslate2.

guillaumekln avatar guillaumekln commented on May 18, 2024

The package is libcublas10 for CUDA 10.1 and above.

from ctranslate2.

anderleich avatar anderleich commented on May 18, 2024

Thanks! It worked!

One last thing... I want to install Ctranslate for Python3.6. This is my code

LANG=en_US.UTF-8
cp $REPOSITORY_DIR/README.md .
cp -r $REPOSITORY_DIR/python python
cd $DEPENDENCIES_PATH/ctranslate2-dev/python

mkdir -p $DEPENDENCIES_PATH/ctranslate2 || exit 1                                                                                                                                         
wget -nv https://bootstrap.pypa.io/get-pip.py                                                                                                 
python3.6 get-pip.py                                                                                                                          
python3.6 -m pip --no-cache-dir install pybind11==2.4.3                                                                                       
python3.6 setup.py bdist_wheel                                                                                                                
rm -r build                                                                                                                                   
rm get-pip.py                                                                                                                                 
python3.6 -m pip freeze | grep pybind11 > $DEPENDENCIES_PATH/ctranslate2/install_requirements.txt                                             
python3.6 setup.py sdist                                                                                                                      
mv dist/* $DEPENDENCIES_PATH/ctranslate2                                                                                                      
rmdir dist                                                                                                                                    


cd $DEPENDENCIES_PATH
mkdir -p $DEPENDENCIES_PATH/ctranslate2/lib || exit 1
cp /opt/intel/lib/intel64/libiomp5.so $DEPENDENCIES_PATH/ctranslate2/lib
cp -P /usr/lib/x86_64-linux-gnu/libcudnn.so* $DEPENDENCIES_PATH/ctranslate2/lib
cp -P /usr/lib/x86_64-linux-gnu/libnvinfer.so* $DEPENDENCIES_PATH/ctranslate2/lib

apt-get update
apt-get install -y --no-install-recommends \
       libcublas10 \
       cuda-cublas-$CUDA_PKG_VERSION \
       python3-distutils-extra \
       wget
apt-get clean
rm -rf /var/lib/apt/lists/*

cp -r $DEPENDENCIES_PATH/ctranslate2 /opt/ctranslate2


wget -nv https://bootstrap.pypa.io/get-pip.py
python3.6 get-pip.py
python3.6 -m pip --no-cache-dir install /opt/ctranslate2/*cp3*.whl
rm get-pip.py

However this seems to build it for Python3.5, which results in this error:

ctranslate2-1.4.0-cp35-cp35m-linux_x86_64.whl is not a supported wheel on this platform.

from ctranslate2.

guillaumekln avatar guillaumekln commented on May 18, 2024

The pattern /opt/ctranslate2/*cp3*.whl matches all Python 3 version. You probably want to use /opt/ctranslate2/*cp36*.whl.

from ctranslate2.

anderleich avatar anderleich commented on May 18, 2024

cp35 is the only file available. It does not find cp36

from ctranslate2.

guillaumekln avatar guillaumekln commented on May 18, 2024

So you did not run the same script you shared above? Because this line:

python3.6 setup.py bdist_wheel

should build a wheel for Python 3.6, not 3.5. The rule is to use the same Python version for building and installing the package.

from ctranslate2.

anderleich avatar anderleich commented on May 18, 2024

Got it! There was a conflict with a previous installation.
Thanks for your help and patience.

from ctranslate2.

anderleich avatar anderleich commented on May 18, 2024

Hi,
After succesfull installation when I try to translate a sentence I get:

AttributeError: module 'ctranslate2' has no attribute 'Translator'

from ctranslate2.

guillaumekln avatar guillaumekln commented on May 18, 2024

This means the Python module is unable to load the compiled extension. Can you run the following in a Python interpreter and check the error?

from ctranslate2 import translator

from ctranslate2.

anderleich avatar anderleich commented on May 18, 2024
ImportError: libctranslate2.so: cannot open shared object file: No such file or directory

I've done this before

export CTRANSLATE2_ROOT=/opt/ctranslate2
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CTRANSLATE2_ROOT/lib

from ctranslate2.

guillaumekln avatar guillaumekln commented on May 18, 2024

/opt/ctranslate2

Did you install CTranslate2 in this location? If not, you should update the path.

from ctranslate2.

anderleich avatar anderleich commented on May 18, 2024

Yes. That's the installation directory.

The log says:
building 'ctranslate2.translator' extension

But it seems it's not getting installed

from ctranslate2.

guillaumekln avatar guillaumekln commented on May 18, 2024

You should find where libtctranslate2.so was installed (after make install in your script) and add this directory to the LD_LIBRARY_PATH environment variable.

from ctranslate2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.