Maratyszcza / NNPACK

Acceleration package for neural networks on multi-core CPUs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build failed, cos_npi_over_8 is not available in common

redradist opened this issue · comments

commented

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

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"