Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to compile from source on windows 11? #1692

Open
ivanhe123 opened this issue May 5, 2024 · 2 comments
Open

How to compile from source on windows 11? #1692

ivanhe123 opened this issue May 5, 2024 · 2 comments

Comments

@ivanhe123
Copy link

I got the error of RuntimeError: Library cublas64_11.dll is not found or cannot be loaded. I searched and saw that I need to compile it from source to make it support 12.1 CUDA.

How do I do it on windows? In the documentation it only works for linux.

@seclog
Copy link

seclog commented May 12, 2024

You can check the windows compilation scripts under python/tools in the ctranslate2 source directory.
https://github.com/OpenNMT/CTranslate2/blob/master/python/tools/prepare_build_environment_windows.sh
It should use a linux-like shell environment for windows, like msys2.
When I compiled it, I used the cmd terminal directly. Here is a brief description, the main content is similar to the above script.

  1. install visual studio2022

  2. install Intel MKL and Nvidia CudaToolkit and Cudnn from the official website.

Important Notes!When installing cudnn, you can refer to the pdf to merge the bin,include,lib directory of cudnn and cuda, otherwise you can't find the cudnn library in the cmake stage.
https://docs.nvidia.com/deeplearning/cudnn/archives/cudnn-804/pdf/cuDNN-Installation-Guide.pdf

  1. install oneDNN (you can refer to prepare_build_environment_windows.sh script to compile using cmake)

  2. git clone source code to d-disk

    git clone https://github.com/OpenNMT/CTranslate2.git

  3. Open the build environment provided by Intel mkl "Intel oneAPI command prompt for Intel 64 for Visual Studio 2022".

  4. cmake configuration

set CTRANSLATE2_ROOT=d:\ctranslate2\
mkdir build
cd build

cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=%CTRANSLATE2_ROOT% -DCMAKE_PREFIX_PATH="C:/Program Files (x86)/Intel/oneAPI/ compiler/latest/windows/compiler/lib/intel64_win;C:/Program Files (x86)/oneDNN" -DBUILD_CLI=OFF -DWITH_DNNL=ON -DWITH_CUDA=ON -DWITH_CUDNN=ON -DCCMAKE_PREFIX_PATH="C:/Program Files (x86)/Intel/oneAPI/ CUDNN=ON -DCUDA_TOOLKIT_ROOT_DIR=%CUDA_ROOT% -DCUDA_DYNAMIC_LOADING=ON -DCUDA_NVCC_FLAGS="-Xfatbin=-compress-all" -DCUDA_ARCH_LIST=" Common" ...

cmake --build . --config Release --target install --parallel 6 --verbose

@prasad-pr-20
Copy link

HI @seclog, @panosk, Based on the above instructions I've modified my cmake command to use only DNNL and not CUDA which looks like this cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=%CTRANSLATE2_ROOT% -DWITH_DNNL=ON ...

Post the build, I followed the instructions in prepare_build_environment_windows.sh
I've copied the DLLs to python/ctranslate2/ folder.
Later after pip install is completed, I observe that the dlls are present as a part of the site-packages directory of the ctranslate2 package,
Yet when I try to import the ctranslate2 package in my code, I get the DLL not found error as in the image below.
The list of DLLs I've copied are

  • ctranslate2.dll
  • libiomp5md.dll
  • cudnn64_8.dll
  • dnnl.dll

Dll_not_found_error

Can you please suggest how do I fix this issue, inoder to get the import running? Also, I've uninstalled the CUDA from my machine as my priority was using DNNL and have retained only the dll.

Thanks in advance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants