fangwei123456 / spikingjelly

SpikingJelly is an open-source deep learning framework for Spiking Neural Network (SNN) based on PyTorch.
https://spikingjelly.readthedocs.io
Other
1.35k stars 239 forks source link

RuntimeError: Ninja is required to load C++ extensions #47

Closed K-H-Ismail closed 3 years ago

K-H-Ismail commented 3 years ago

Hello, I am struggling to have this module installed :

spikingjelly/cext/neuron.py", line 5, in import _C_neuron ModuleNotFoundError: No module named '_C_neuron'

I've tried both installing from pip and building from source. Can you help me ?

K-H-Ismail commented 3 years ago

Hello, It seems that ninja is required here and it should be at /usr/bin which makes it hard without sudo privileges :

Traceback (most recent call last): File "speechcommands.py", line 23, in from csrc.plif import MultiStepParametricLIFNode File "/home/ismail/spikingjelly/csrc/plif.py", line 13, in _C_PLIF = cpp_extension.load(name='neuron_plif', sources=['./csrc/plif.cpp', './csrc/plif_kernel.cu'], File "/home/ismail/python-3.8.1/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 986, in load return _jit_compile( File "/home/ismail/python-3.8.1/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 1193, in _jit_compile _write_ninja_file_and_build_library( File "/home/ismail/python-3.8.1/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 1268, in _write_ninja_file_and_build_library verify_ninja_availability() File "/home/ismail/python-3.8.1/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 1323, in verify_ninja_availability raise RuntimeError("Ninja is required to load C++ extensions") RuntimeError: Ninja is required to load C++ extensions

fangwei123456 commented 3 years ago

Using anaconda to create a virtual environment and running SpikingJelly at this environment may be a good choice.

If you have created a env, e.g., 'pytorch-env', you can use 'conda install ninja' to install ninja.

K-H-Ismail commented 3 years ago

Thanks Fang Wei, it seems that using pip3 install ninja solved the issue too. :)