-
Notifications
You must be signed in to change notification settings - Fork 264
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
Difficult CMake build system producing unexpected results with MKL >= 2021.3.0 #528
Comments
If you want to compile from source, you can use the command below: |
To illustrate the difficulty I had here better, here is a snippet of the recipe I'm using to successfully build IPEX for Intel CPUs:
This is a lot. Ideally, I wouldn't need to modify the sources for IPEX to just build the C++ project, or do that build work through Python. And, ideally, I wouldn't need to define obscure CMake configuration variables like Not building the CPPSDK reduces the build time here since we don't need to compress the end result into a package, and then re-extract it just to get it installed to the correct location. I am very glad there was a way to bypass this and reduce to overall build time. |
@gtkramer, not sure what happened with your pull-request, so I created a new one - #587 @xuhancn, I noticed you tried to fix build with Clang previously, could you check my pull-request? Thanks! |
@AngryLoki ah, I unfortunately wasn't able to bring this to completion from being moved onto other work and our team moving away from IPEX in general in favor of OpenVINO, since we're seeing better model inferencing there on our Intel CPUs. I assume the patch is still needed, but I haven't had time to check this out. We can close this issue though since we don't have plans to come back to IPEX right now and build only the C++ component to support our C++ development, which would be easier for us with adjustments to IPEX's CMake. |
I am part of an internal team with Intel and we are using the C++ version of PyTorch for some of our work. We are interested in the CPU version of IPEX to ensure our inferencing is running as fast as possible on modern server CPUs.
We need to build IPEX 2.2.0+cpu from source, and as I began working with the build system, a few observations came to mind.
libintel-ext-pt-cpu.so
.setup.py
creates aversion.h
, which would ideally be done in CMake, which the code in the project needs to compile.PYTHON_EXECUTABLE
andPYTHON_INCLUDE_DIR
as a configuration option. We already dofind_package(Python COMPONENTS Interpreter Development)
inintel_extension_for_pytorch/csrc/CMakeLists.txt
, which creates all of the variables needed. As long as the virtual environment is added to the CMAKE_PREFIX_PATH, this should work ok?pip install
for MKL packages in CMake as a part ofFindoneMKL.cmake
is unexpected. This would be better put intosetup.py
as a requirement so that this is done automatically by pip. This should be fine because MKL is required to build the project. If not in a virtual environment, which typically wouldn't be needed for building C++ code, this can end up installing the MKL packages into unexpected locations.FindoneMKL.cmake
(statically with 32-bit integers and GNU threading), and once fromFindOMP.cmake
(dynamically with 64-bit integers and Intel threading). It took a great deal of time to figure out what was going on when I found twofind_package
calls that were MKL-related. One wasfind_package(oneMKL)
incsrc/cpu/CMakeLists.txt
andtests/cpu/cpp/CMakeLists.txt
and the other wasfind_package(MKL)
inFindOMP.cmake
. MKL should ideally be pulled in once and in one way only. My builds were failing with the dynamic MKL import when the build logs reported that the static MKL import was successful.CMakeLists.txt
can only buildcsrc/cpu/CMakeLists.txt
. It can't be used to buildtests/cpu/cpp/CMakeList.txt
, which was unexpected.include(CTest)
and then the user can set-DBUILD_TESTING=ON/OFF
when configuring the project with CMake. Or, this can be anoption
that the project defines a default value for. Defining relative paths back to the root CMake to configure testing properly is not very easy to read or understand (or I imagine maintain).cmake/IPEXConfig.cmake.in
, please consider doing something liketarget_link_libraries(intel-ext-pt-cpu INTERFACE "-Wl,--push-state,--no-as-needed" "${IPEX_CPU_CORE_LIBRARY}" "-Wl,--pop-state")
. This follows what MKL does. It's easier to readtarget_include_directories
andtarget_link_libraries
rather than one massiveset_target_properties
. Additionally, it's more mindful about preserving the state of the linker, being very clear that we're only applying--no-as-needed
to the IPEX library. It also gives a way to have theintel-ext-pt-cpu
target that is available for use in consuming CMake projects to also use thetorch
target that comes fromTorchConfig.cmake
. It can be added astarget_link_library
, like how TorchVision does it withtarget_link_libraries(${PN}::${PN} INTERFACE torch)
.I'm guessing the complexity here arose from needing to use CMake to build the C++ project, but also needing to build a wheel in Python. I've found that building wheels in Python is best done with Python's own infrastructure. Bridging this gap with CMake is often difficult since there is no standard process for this, so I can understand how things are the way they are. At least for the C++ side of things, the changes listed above would make building this project MUCH easier for us if we could call out to CMake directly. I also ran into some AVX512 FP16 build issues due to invalid conversions from
c10::Half
to_Float16
(we are building with GCC 13.2 on modern enough Xeons), but I'll file a separate issue for that along with the patch I have for the fixes.The text was updated successfully, but these errors were encountered: