IBM / aihwkit

IBM Analog Hardware Acceleration Kit
https://aihwkit.readthedocs.io
MIT License
365 stars 148 forks source link

CMake building problems #670

Closed amine-ziad-ounnoughene closed 4 months ago

amine-ziad-ounnoughene commented 4 months ago

Description

I'm encountering an issue while trying to install aihwkit using pip install aihwkit. Despite following the developer installation guide provided in the documentation, I'm still facing the same error during the build process. The command used is: py setup.py build_ext -DCMAKE_EXPORT_COMPILE_COMMANDS=TRUE --inplace -DRPU_BLAS=OpenBLAS -j16 -DUSE_CUDA=ON -DRPU_CUDA_ARCHITECTURES="60;70" -DCMAKE_PREFIX_PATH=$CONDA_PREFIX

Error Output

Here is the error I am receiving:

[40/41] Linking CXX shared module src\aihwkit\simulator\rpu_base.cp311-win_amd64.pyd
FAILED: src\aihwkit/simulator/rpu_base.cp311-win_amd64.pyd
C:\WINDOWS\system32\cmd.exe /C "cd . && C:\Users\amine\Music\cmake-3.30.0-windows-x86_64\bin\cmake.exe -E vs_link_dll --intdir=src\aihwkit\simulator\CMakeFiles\rpu_base.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x86\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x86\mt.exe --manifests -- C:\PROGRA~1\MIB055~1\2022\COMMUN~1\VC\Tools\MSVC\1440~1.338\bin\Hostx86\x64\link.exe /nologo src\aihwkit\simulator\CMakeFiles\rpu_base.dir\rpu_base_src\rpu_base.cpp.obj src\aihwkit\simulator\CMakeFiles\rpu_base.dir\rpu_base_src\rpu_base_devices.cpp.obj src\aihwkit\simulator\CMakeFiles\rpu_base.dir\rpu_base_src\rpu_base_tiles.cpp.obj src\aihwkit\simulator\CMakeFiles\rpu_base.dir\rpu_base_src\rpu_base_tiles_cuda.cpp.obj src\aihwkit\simulator\CMakeFiles\rpu_base.dir\rpu_base_src\rpu_base_utils.cpp.obj /out:src\aihwkit\simulator\rpu_base.cp311-win_amd64.pyd /implib:src\aihwkit\simulator\rpu_base.lib /pdb:src\aihwkit\simulator\rpu_base.pdb /dll /version:0.0 /machine:x64 /INCREMENTAL:NO -LTCG -LIBPATH:C:\Users\amine\AppData\Local\Programs\Python\Python311\Lib\site-packages\torch\lib torch_python.lib RPU_CPU.lib C:\Users\amine\AppData\Local\Programs\Python\Python311\libs\python311.lib C:\Users\amine\Music\OpenBLAS\lib\libopenblas.lib c10.lib torch_cpu.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && C:\WINDOWS\system32\cmd.exe /C "cd /D C:\Users\amine\AppData\Local\Temp\pip-install-umh_hmx7\aihwkit_8931b3e25b57445cb7de185fc2c4430f && stubgen --module src/aihwkit/simulator --output ."
LINK: command "C:\PROGRA~1\MIB055~1\2022\COMMUN~1\VC\Tools\MSVC\1440~1.338\bin\Hostx86\x64\link.exe /nologo src\aihwkit\simulator\CMakeFiles\rpu_base.dir\rpu_base_src\rpu_base.cpp.obj src\aihwkit\simulator\CMakeFiles\rpu_base.dir\rpu_base_src\rpu_base_devices.cpp.obj src\aihwkit\simulator\CMakeFiles\rpu_base.dir\rpu_base_src\rpu_base_tiles.cpp.obj src\aihwkit\simulator\CMakeFiles\rpu_base.dir\rpu_base_src\rpu_base_tiles_cuda.cpp.obj src\aihwkit\simulator\CMakeFiles\rpu_base.dir\rpu_base_src\rpu_base_utils.cpp.obj /out:src\aihwkit\simulator\rpu_base.cp311-win_amd64.pyd /implib:src\aihwkit\simulator\rpu_base.lib /pdb:src\aihwkit\simulator\rpu_base.pdb /dll /version:0.0 /machine:x64 /INCREMENTAL:NO -LTCG -LIBPATH:C:\Users\amine\AppData\Local\Programs\Python\Python311\Lib\site-packages\torch\lib torch_python.lib RPU_CPU.lib C:\Users\amine\AppData\Local\Programs\Python\Python311\libs\python311.lib C:\Users\amine\Music\OpenBLAS\lib\libopenblas.lib c10.lib torch_cpu.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST:EMBED,ID=2" failed (exit code 1120) with the following output:
Creation of library src\aihwkit\simulator\rpu_base.lib and object src\aihwkit\simulator\rpu_base.exp
RPU_CPU.lib(math_util.cpp.obj) : error LNK2001: unresolved external symbol cblas_snrm2
RPU_CPU.lib(math_util.cpp.obj) : error LNK2001: unresolved external symbol cblas_dnrm2
RPU_CPU.lib(math_util.cpp.obj) : error LNK2001: unresolved external symbol cblas_isamax
RPU_CPU.lib(math_util.cpp.obj) : error LNK2001: unresolved external symbol cblas_idamax
RPU_CPU.lib(math_util.cpp.obj) : error LNK2001: unresolved external symbol cblas_scopy
RPU_CPU.lib(math_util.cpp.obj) : error LNK2001: unresolved external symbol cblas_dcopy
RPU_CPU.lib(math_util.cpp.obj) : error LNK2001: unresolved external symbol cblas_sscal
RPU_CPU.lib(math_util.cpp.obj) : error LNK2001: unresolved external symbol cblas_dscal
RPU_CPU.lib(math_util.cpp.obj) : error LNK2001: unresolved external symbol cblas_sgemv
RPU_CPU.lib(math_util.cpp.obj) : error LNK2001: unresolved external symbol cblas_dgemv
RPU_CPU.lib(math_util.cpp.obj) : error LNK2001: unresolved external symbol cblas_sger
RPU_CPU.lib(math_util.cpp.obj) : error LNK2001: unresolved external symbol cblas_dger
RPU_CPU.lib(math_util.cpp.obj) : error LNK2001: unresolved external symbol cblas_sgemm
RPU_CPU.lib(math_util.cpp.obj) : error LNK2001: unresolved external symbol cblas_dgemm
src\aihwkit\simulator\rpu_base.cp311-win_amd64.pyd : fatal error LNK1120: 14 unresolved externals
ninja: build stopped: subcommand failed.
Traceback (most recent call last):
  File "C:\Users\amine\AppData\Local\Programs\Python\Python311\Lib\site-packages\skbuild\setuptools_wrap.py", line 672, in setup
    cmkr.make(make_args, install_target=cmake_install_target, env=env)
  File "C:\Users\amine\AppData\Local\Programs\Python\Python311\Lib\site-packages\skbuild\cmaker.py", line 696, in make
    self.make_impl(clargs=clargs, config=config, source_dir=source_dir, install_target=install_target, env=env)
  File "C:\Users\amine\AppData\Local\Programs\Python\Python311\Lib\site-packages\skbuild\cmaker.py", line 741, in make_impl
    raise SKBuildError(msg)

An error occurred while building with CMake.
  Command:
    'C:\Users\amine\Music\cmake-3.30.0-windows-x86_64\bin\cmake.EXE' --build . --target install --config Release --
  Install target:
    install
  Source directory:
    C:\Users\amine\AppData\Local\Temp\pip-install-umh_hmx7\aihwkit_8931b3e25b57445cb7de185fc2c4430f
  Working directory:
    C:\Users\amine\AppData\Local\Temp\pip-install-umh_hmx7\aihwkit_8931b3e25b57445cb7de185fc2c4430f\_skbuild\win-amd64-3.11\cmake-build
Please check the install target is valid and see CMake's output for more information.

[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for aihwkit
Running setup.py clean for aihwkit
Failed to build aihwkit
ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (aihwkit)

Current status

I followed the developer installation guide and have the following setup:

OpenBLAS MinGW gfortran CMake 3.30.0 Python 3.11.1 CUDA 11.8 and 12.1 Conda Windows 11 I would appreciate any guidance on resolving this issue.

kaoutar55 commented 4 months ago

Windows is not a well-supported platform. Can you try to use WCL in windows to compile the kit. Please give it a try and let us know if you encounter any issues.

amine-ziad-ounnoughene commented 4 months ago

with WSL Ubuntu it worked !!, thank you for your help