Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
7117 Discussions

MKLConfig.cmake finds wrong libraries | fix provided

DenizBahadir
New Contributor I
2,313 Views

I noticed on my Ubuntu 22.04 (WSL) system that, although I have installed Intel oneAPI MKL 2023.2.0 and the CMake Variable `MKL_ROOT` is correctly set, the call to `find_package(MKL 2023 CONFIG)` sadly does not find the correct libraries.

It prints the correct `MKL_ROOT` but then finds the libraries from MKL 2020.4 located in Ubuntu's system paths (`/usr/lib/x86_64-linux-gnu/libmkl_intel_ilp64.a` etc.) instead. (I have Ubuntu's package `intel-mkl` installed as well on my machine.)

 

By examining the file `MKLConfig.cmake` provided with Intel oneAPI MKL 2023.2.0 I noticed that the reason for that is, that the calls to `find_library` do not exclude system paths when searching. And as explained in CMake's documentation for `find_library`, system paths are considered before checking the paths provided via the `PATHS` option.

 

A working solution to this problem (which does not require to uninstall the `intel-mkl` package) is to add `NO_DEFAULT_PATH` as additional option to the two `find_library` calls.

I attached a patch which can be applied to `MKLConfig.cmake` that does exactly that.

Labels (1)
0 Kudos
7 Replies
DenizBahadir
New Contributor I
2,312 Views

The patch I mentioned above.

(I had to append the extension `.txt` because otherwise the forum software did not accept my file.)

0 Kudos
ShanmukhS_Intel
Moderator
2,262 Views

Hi Deniz,


Thanks for posting in Intel Communities.


A working solution to this problem (which does not require to uninstall the `intel-mkl` package) is to add `NO_DEFAULT_PATH` as additional option to the two `find_library` calls.

>> Thanks for sharing the details. We would like to inform you that, it is advised not to use multiple copies of MKL versions. However, Regarding your issue, We will get back to you soon with an update.


Best Regards,

Shanmukh.SS


0 Kudos
ShanmukhS_Intel
Moderator
2,214 Views

Hi Deniz,


We have tried installing the MKL as per the WSL mentioned by you. We could see the MKL libraries being copied to appropriate libraries and not to the system libraries as mentioned earlier.


Could you please let us know if there is any difference in our understanding?


Best Regards,

Shanmukh.SS


0 Kudos
DenizBahadir
New Contributor I
2,202 Views

Hi @ShanmukhS_Intel,

 

The problem is not with installing Intel oneAPI MKL 2023.2.0 (package `intel-oneapi-mkl-devel-2023.2.0` from https://apt.repos.intel.com/oneapi) side-by-side to Ubuntu 22.04's `intel-mkl` package. The problem occurs, when both are installed in their respective directories and one tries to build a CMake project that uses `find_package( MKL 2023 CONFIG )`.

 

The libraries of Intel oneAPI MKL 2023.2.0 are installed in `/opt/intel/oneapi/mkl/2023.2.0/lib/` and the libraries of Ubuntu's version of Intel MKL 2020.4 are installed in `/usr/lib/x86_64-linux-gnu/'.

The CMake package-config is then found in `/opt/intel/oneapi/mkl/2023.2.0/lib/cmake/mkl/` and while processing it the `MKL_ROOT` is correctly determined to be at `/opt/intel/oneapi/mkl/2023.2.0/`. However, the internal calls to `find_package` then first look in system paths for the Intel oneAPI MKL (2023.2.0) libraries and sadly find the libraries from Ubuntu's Intel MKL 2020.4 in `/usr/lib/x86_64-linux-gnu/`.

And that is the described problem.

 

The simple fix is to add the option `NO_DEFAULT_PATHS` to the internal `find_library` (as shown in the provided patch) in order to prevent it from searching the default system paths for the libraries (that are supposed to lie somewhere in `MKL_ROOT`.

0 Kudos
ShanmukhS_Intel
Moderator
2,167 Views

Hi Deniz,


Thanks for sharing the details. We are looking into your issue internally. We will get back to you soon with an update.


Best Regards,

Shanmukh.SS


0 Kudos
ShanmukhS_Intel
Moderator
2,129 Views

Hi Deniz,


A similar request was already in place and this is to acknowledge you that our team is working on this issue internally.


Best Regards,

Shanmukh.SS


0 Kudos
ShanmukhS_Intel
Moderator
2,008 Views

Hi,


Thank you for your patience. The issue raised by you has been targeted to be fixed in 2024.0 version which will released in the coming months. If the issue still persists with the new release, then you can start a new discussion for the community to investigate.


Best Regards,

Shanmukh.SS


0 Kudos
Reply