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

Build failed, cos_npi_over_8 is not available in common #202

Open
redradist opened this issue May 3, 2021 · 1 comment
Open

Build failed, cos_npi_over_8 is not available in common #202

redradist opened this issue May 3, 2021 · 1 comment

Comments

@redradist
Copy link

redradist commented May 3, 2021

When I try to build PyTorch I got the following error:

ImportError: cannot import name 'cos_npi_over_8' from 'common' (~/.local/lib/python3.8/site-packages/common/__init__.py)
make[2]: *** [confu-deps/NNPACK/CMakeFiles/nnpack.dir/build.make:81: confu-deps/NNPACK/src/x86_64-fma/2d-fourier-8x8.py.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:2697: confu-deps/NNPACK/CMakeFiles/nnpack.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

I investigated this issue for some time and figured out that there was missed path in PYTHONPATH to x86_64-fma where those module located with all child modules
To fix the issue I modified CMakeLists.txt:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5ecd2df..6c6af68 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -169,11 +169,12 @@ IF(NNPACK_BACKEND STREQUAL "x86-64")
     SET(PYTHON_PEACHPY_SOURCE_DIR "${CONFU_DEPENDENCIES_SOURCE_DIR}/peachpy" CACHE STRING "PeachPy (Python package) source directory")
   ENDIF()
 
+  SET(PYTHON_NNPACK_MODULE_DIR ${CMAKE_CURRENT_LIST_DIR}/src/x86_64-fma)
   IF(${PYTHON_VERSION_STRING} VERSION_LESS 3.4)
     # ---[ Python < 3.4 does not natively support enums, and needs a polyfill
     SET(PEACHPY_PYTHONPATH "${PYTHON_SIX_SOURCE_DIR}:${PYTHON_ENUM_SOURCE_DIR}:${PYTHON_PEACHPY_SOURCE_DIR}")
   ELSE()
-    SET(PEACHPY_PYTHONPATH "${PYTHON_SIX_SOURCE_DIR}:${PYTHON_PEACHPY_SOURCE_DIR}")
+    SET(PEACHPY_PYTHONPATH "${PYTHON_NNPACK_MODULE_DIR}:${PYTHON_SIX_SOURCE_DIR}:${PYTHON_PEACHPY_SOURCE_DIR}")
   ENDIF()
 ENDIF()

After this PyTorch compiled successfully ...
Is it and issue of PyTorch ?
For me it seems like it is an issue in build file for NNPACK

@wzhao18
Copy link

wzhao18 commented May 15, 2023

I hit the same issue, the reason is that it is loading 'common' package instead of that in the src/x86_64-fma.

pip3 uninstall common will make it work.

The loading of this package is done at

"-I${PROJECT_SOURCE_DIR}/src" "-I${PROJECT_SOURCE_DIR}/src/x86_64-fma" "-I${FP16_SOURCE_DIR}/include"

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

2 participants