-
Notifications
You must be signed in to change notification settings - Fork 451
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
RuntimeError: Ninja is required to load C++ extension #167
Comments
Please run following command: wget https://github.com/ninja-build/ninja/releases/download/v1.8.2/ninja-linux.zip
sudo unzip ninja-linux.zip -d /usr/local/bin/
sudo update-alternatives --install /usr/bin/ninja ninja /usr/local/bin/ninja 1 --force solution from https://www.claudiokuenzler.com/blog/756/install-newer-ninja-build-tools-ubuntu-14.04-trusty#.XEDUk89KjOB |
Hi,author. Does the solution from https://www.claudiokuenzler.com/blog/756/install-newer-ninja-build-tools-ubuntu-14.04-trusty#.XEDUk89KjOB work? I tried it and it still doesn't work. |
Hi, my problem was solved.However, the code still can't run. I tried many times, even ask an engineer of Dji for help. Finally, my personal opinion is that the stability of the code is poor. I hope you can run it successfully and let me know. Thanks |
How to do this without sudo Permission? |
I seem to have the same problem Traceback (most recent call last): How can I fix this on a windows machine ? |
Just curious. Have you found a method to overcome this sudo permission issue? thanks |
I just |
The simplest solution is sometimes overlooked. Thank you, BooPatienze! |
I also encounter with this problem on a windows platform, have you solved it bro? |
For Windows, I would recommend using docker https://hangzhang.org/PyTorch-Encoding/notes/compile.html#using-docker |
It works for me. |
I found the subprocess does not include the lib path of conda environments. So I manually set the environments in the script, and it works now.
|
None of these solutions work for me on Windows |
Thanks. It works for me! |
|
Please use the docker solution if you ran into any troubles especially on windows https://hangzhang.org/PyTorch-Encoding/notes/compile.html#using-docker |
@nom57 A bit off topic, but you might want to use Windows Subsystem for Linux if you are on Windows. It greatly simplifies working with a machine learning workload on Windows. I use it regularly on Windows 11. It's essentially a virtual machine, although with near native performance. |
Just a few comments on the great answer of tommy-qichang which solves my problem immediately.
|
This solution is the real answer to this question! Thank you @tommy-qichang @AndyJZhao !
|
my_env = os.environ.copy() |
@SysOverdrive and @csyhy1986 I also encountered this issue on my Windows system, doing the following steps has solved the issue for me.
I am not sure if this is the right solution, but my error is gone now. |
This works! |
Hi,author. I have followed the instructions on your page. I got your code by git clone, and run "python setup.py install" with no errors. However when I run "python3 demo.py", I got the error like this:
Traceback (most recent call last):
File "/home/llg/.local/lib/python3.5/site-packages/torch/utils/cpp_extension.py", line 873, in verify_ninja_availability
subprocess.check_call('ninja --version'.split(), stdout=devnull)
File "/usr/lib/python3.5/subprocess.py", line 576, in check_call
retcode = call(*popenargs, **kwargs)
File "/usr/lib/python3.5/subprocess.py", line 557, in call
with Popen(*popenargs, **kwargs) as p:
File "/usr/lib/python3.5/subprocess.py", line 947, in init
restore_signals, start_new_session)
File "/usr/lib/python3.5/subprocess.py", line 1551, in _execute_child
raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'ninja'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "1.py", line 2, in
import encoding
File "/home/llg/Documents/PyTorch-Encoding/encoding/init.py", line 13, in
from . import nn, functions, parallel, utils, models, datasets, transforms
File "/home/llg/Documents/PyTorch-Encoding/encoding/nn/init.py", line 12, in
from .encoding import *
File "/home/llg/Documents/PyTorch-Encoding/encoding/nn/encoding.py", line 18, in
from ..functions import scaled_l2, aggregate, pairwise_cosine
File "/home/llg/Documents/PyTorch-Encoding/encoding/functions/init.py", line 2, in
from .encoding import *
File "/home/llg/Documents/PyTorch-Encoding/encoding/functions/encoding.py", line 14, in
from .. import lib
File "/home/llg/Documents/PyTorch-Encoding/encoding/lib/init.py", line 15, in
], build_directory=cpu_path, verbose=False)
File "/home/llg/.local/lib/python3.5/site-packages/torch/utils/cpp_extension.py", line 645, in load
is_python_module)
File "/home/llg/.local/lib/python3.5/site-packages/torch/utils/cpp_extension.py", line 814, in _jit_compile
with_cuda=with_cuda)
File "/home/llg/.local/lib/python3.5/site-packages/torch/utils/cpp_extension.py", line 837, in _write_ninja_file_and_build
verify_ninja_availability()
File "/home/llg/.local/lib/python3.5/site-packages/torch/utils/cpp_extension.py", line 875, in verify_ninja_availability
raise RuntimeError("Ninja is required to load C++ extensions")
RuntimeError: Ninja is required to load C++ extension
How to overcome it? What's the "Ninja"?
The text was updated successfully, but these errors were encountered: