redradist:

I just hard-coded version of the Python that was detected wrong to 3.8
And then build starts but faced with another issue:
Traceback (most recent call last):
  File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/redra/Projects/AI/pytorch/third_party/python-peachpy/peachpy/x86_64/__main__.py", line 280, in <module>
    main()
  File "/home/redra/Projects/AI/pytorch/third_party/python-peachpy/peachpy/x86_64/__main__.py", line 267, in main
[ 57%] Built target XNNPACK
    execute_script(writers, options.input[0])
  File "/home/redra/Projects/AI/pytorch/third_party/python-peachpy/peachpy/x86_64/__main__.py", line 198, in execute_script
    execute_script(writers, source_filename)
  File "/home/redra/Projects/AI/pytorch/third_party/python-peachpy/peachpy/x86_64/__main__.py", line 198, in execute_script
    execute_script(writers, source_filename)
  File "/home/redra/Projects/AI/pytorch/third_party/python-peachpy/peachpy/x86_64/__main__.py", line 202, in execute_script
    exec(code, globals())
  File "/home/redra/Projects/AI/pytorch/third_party/NNPACK/src/x86_64-fma/2d-fourier-8x8.py", line 5, in <module>
    import fft.complex_soa
  File "/home/redra/Projects/AI/pytorch/third_party/NNPACK/src/x86_64-fma/fft/complex_soa.py", line 7, in <module>
    from common import cos_npi_over_8, sin_npi_over_8, cos_npi_over_4, sin_npi_over_4
ImportError: cannot import name 'cos_npi_over_8' from 'common' (/home/redra/.local/lib/python3.8/site-packages/common/__init__.py)
[ 57%] Building C object sleef/src/libm/CMakeFiles/sleefavx512fnofma.dir/sleefsimddp.c.o
[ 57%] Building CXX object caffe2/proto/CMakeFiles/Caffe2_PROTO.dir/caffe2.pb.cc.o
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:3282: confu-deps/NNPACK/CMakeFiles/nnpack.dir/all] Error 2

Seems like this is related to sudo make install -- ImportError: cannot import name cos_npi_over_8 · Issue #2296 · facebookarchive/caffe2 · GitHub


I’ve found the root cause for this issue:
  
      github.com/Maratyszcza/NNPACK
  
  
    
  
	  
  

  
    
      Build failed, cos_npi_over_8 is not available in common 4
    

    
      
        opened 
        
          
        
        May 3, 2021
      
      


      
        
          
          redradist
        
      
    

    
    
  


  
    When I try to build PyTorch I got the following error:
```diff
ImportError: ca…nnot 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:
```console
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