Skip to content
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++ extensions #20

Closed
GuangyanZhang opened this issue Jun 21, 2019 · 27 comments
Closed

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

GuangyanZhang opened this issue Jun 21, 2019 · 27 comments

Comments

@GuangyanZhang
Copy link

您好,首先我出现这样的问题:
RuntimeError: Ninja is required to load C++ extensions
然后我pip install ninja成功以后
又出现这样的问题:
/usr/local/lib/python3.5/dist-packages/torch/utils/cpp_extension.py:118: UserWarning:

                           !! WARNING !!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Your compiler (c++) may be ABI-incompatible with PyTorch!
Please use a compiler that is ABI-compatible with GCC 4.9 and above.
See https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html.

See https://gist.github.com/goldsborough/d466f43e8ffc948ff92de7486c5216d6
for instructions on how to install GCC 4.9 or higher.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

                          !! WARNING !!

warnings.warn(ABI_INCOMPATIBILITY_WARNING.format(compiler))
Traceback (most recent call last):
File "tools/train.py", line 27, in
import models
File "/data/HRNet-Semantic-Segmentation-master/tools/../lib/models/init.py", line 11, in
import models.seg_hrnet
File "/data/HRNet-Semantic-Segmentation-master/tools/../lib/models/seg_hrnet.py", line 22, in
from .sync_bn.inplace_abn.bn import InPlaceABNSync
File "/data/HRNet-Semantic-Segmentation-master/tools/../lib/models/sync_bn/init.py", line 1, in
from .inplace_abn import bn
File "/data/HRNet-Semantic-Segmentation-master/tools/../lib/models/sync_bn/inplace_abn/init.py", line 1, in
from .bn import ABN, InPlaceABN, InPlaceABNSync
File "/data/HRNet-Semantic-Segmentation-master/tools/../lib/models/sync_bn/inplace_abn/bn.py", line 14, in
from functions import *
File "/data/HRNet-Semantic-Segmentation-master/lib/models/sync_bn/inplace_abn/functions.py", line 16, in
extra_cuda_cflags=["--expt-extended-lambda"])
File "/usr/local/lib/python3.5/dist-packages/torch/utils/cpp_extension.py", line 514, in load
with_cuda=with_cuda)
File "/usr/local/lib/python3.5/dist-packages/torch/utils/cpp_extension.py", line 690, in _jit_compile
return _import_module_from_library(name, build_directory)
File "/usr/local/lib/python3.5/dist-packages/torch/utils/cpp_extension.py", line 773, in _import_module_from_library
return imp.load_module(module_name, file, path, description)
File "/usr/lib/python3.5/imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "/usr/lib/python3.5/imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: /tmp/torch_extensions/inplace_abn/inplace_abn.so: undefined symbol: _ZN2at5ErrorC1ENS_14SourceLocationESs

请问这个BN和pytorch是要同步编译吗?我的pytorch==0.4.1

@GuangyanZhang
Copy link
Author

我该怎么操作才能解决这个问题呢?希望您能指导一下,谢谢

@sunke123
Copy link
Member

You can try this docker: kesun/pose:pytorch-0.4.1-bn-cudnn-off
If possible, you adopt the official sync-bn provided by pytorch.

@GuangyanZhang
Copy link
Author

这个docker "kesun/pose:pytorch-0.4.1-bn-cudnn-off" 可以提供一个链接吗?谢谢!

@sunke123
Copy link
Member

https://cloud.docker.com/u/kesun/repository/docker/kesun/pose

I think you can pull this docker without any link.

@GuangyanZhang
Copy link
Author

好的,非常感谢

@sde123
Copy link

sde123 commented Jun 21, 2019

hi
your website 'https://cloud.docker.com/u/kesun/repository/docker/kesun/pose' is not working now. Could you tell me what is wrong?

@GuangyanZhang
Copy link
Author

This site maybe requires over the wall,I think

@sde123
Copy link

sde123 commented Jun 21, 2019

Hi
I can visit google,but I cannot visit this website,Therefore, it is not the reason of wall

@GuangyanZhang
Copy link
Author

I think website is limitted,you can wait a moment.......

@sunke123
Copy link
Member

@GuangyanZhang @sde123
Sorry about that.
https://hub.docker.com/r/kesun/pose/.

However, I have no idea why you need to visit this website.
You can just run "docker pull kesun/pose:pytorch-0.4.1-bn-cudnn-off" to pull this image.

@sde123
Copy link

sde123 commented Jun 21, 2019

Ok,Do you solve the above problem of BN and pytorch that you said?

@GuangyanZhang
Copy link
Author

my website is limitted,so I want download by other computer.but I find that my environment cann't use docker.....

@GuangyanZhang
Copy link
Author

@sde123 I don't,I should adopt the official sync-bn provided by pytorch.that's bad.

@GuangyanZhang
Copy link
Author

@sde123 你好,之前那个搞定了,现在又出现这样的问题,我是不是哪里路径不对或者参数不对呢?,能指导下吗?
File "tools/train.py", line 245, in
main()
File "tools/train.py", line 56, in main
args = parse_args()
File "tools/train.py", line 51, in parse_args
update_config(config, args)
File "/data/HRNet-Semantic-Segmentation-master/tools/../lib/config/default.py", line 114, in update_config
cfg.merge_from_file(args.cfg)
File "/usr/local/lib/python3.5/dist-packages/yacs/config.py", line 171, in merge_from_file
self.merge_from_other_cfg(cfg)
File "/usr/local/lib/python3.5/dist-packages/yacs/config.py", line 175, in merge_from_other_cfg
_merge_a_into_b(cfg_other, self, self, [])
File "/usr/local/lib/python3.5/dist-packages/yacs/config.py", line 401, in _merge_a_into_b
_merge_a_into_b(v, b[k], root, key_list + [k])
File "/usr/local/lib/python3.5/dist-packages/yacs/config.py", line 401, in _merge_a_into_b
_merge_a_into_b(v, b[k], root, key_list + [k])
File "/usr/local/lib/python3.5/dist-packages/yacs/config.py", line 392, in _merge_a_into_b
raise KeyError("Non-existent config key: {}".format(full_key))
KeyError: 'Non-existent config key: MODEL.EXTRA.STAGE4'

@jwnirvana
Copy link

I am confused by this problem(ninjia),too. Could you teach me to solve it,please?

@GuangyanZhang
Copy link
Author

you should install pytorch 0.4.0 and ninja~

@frostinassiky
Copy link

@GuangyanZhang Did you check your config (yaml) file? Does it contain STAGE4?

@yanli-star
Copy link

@GuangyanZhang 你好,我安装pytorch0.4.1和您出现了同样的问题,又安装了pytorch0.4.0和ninja,出现了下面这样的问题,请问您出现过吗,怎么解决呢?
File "tools/train.py", line 27, in
import models
File "/root/userfolder/code/HRNet-Seg/tools/../lib/models/init.py", line 11, in
import models.seg_hrnet
File "/root/userfolder/code/HRNet-Seg/tools/../lib/models/seg_hrnet.py", line 22, in
from .sync_bn.inplace_abn.bn import InPlaceABNSync
File "/root/userfolder/code/HRNet-Seg/tools/../lib/models/sync_bn/init.py", line 1, in
from .inplace_abn import bn
File "/root/userfolder/code/HRNet-Seg/tools/../lib/models/sync_bn/inplace_abn/init.py", line 1, in
from .bn import ABN, InPlaceABN, InPlaceABNSync
File "/root/userfolder/code/HRNet-Seg/tools/../lib/models/sync_bn/inplace_abn/bn.py", line 14, in
from functions import *
File "/root/userfolder/code/HRNet-Seg/tools/../lib/models/sync_bn/inplace_abn/functions.py", line 16, in
extra_cuda_cflags=["--expt-extended-lambda"])
File "/root/userfolder/anaconda3/envs/python27/lib/python2.7/site-packages/torch/utils/cpp_extension.py", line 501, in load
_build_extension_module(name, build_directory)
File "/root/userfolder/anaconda3/envs/python27/lib/python2.7/site-packages/torch/utils/cpp_extension.py", line 582, in _build_extension_module
name, error.output.decode()))
RuntimeError: Error building extension 'inplace_abn': ninja: warning: bad deps log signature or version; starting over
[1/4] /usr/local/cuda:/bin/nvcc -DTORCH_EXTENSION_NAME=inplace_abn -I/root/userfolder/anaconda3/envs/python27/lib/python2.7/site-packages/torch/lib/include -I/root/userfolder/anaconda3/envs/python27/lib/python2.7/site-packages/torch/lib/include/TH -I/root/userfolder/anaconda3/envs/python27/lib/python2.7/site-packages/torch/lib/include/THC -I/usr/local/cuda:/include -I/root/userfolder/anaconda3/envs/python27/include/python2.7 --compiler-options '-fPIC' --expt-extended-lambda -std=c++11 -c /root/userfolder/code/HRNet-Seg/lib/models/sync_bn/inplace_abn/src/inplace_abn_cuda.cu -o inplace_abn_cuda.cuda.o
FAILED: inplace_abn_cuda.cuda.o
/usr/local/cuda:/bin/nvcc -DTORCH_EXTENSION_NAME=inplace_abn -I/root/userfolder/anaconda3/envs/python27/lib/python2.7/site-packages/torch/lib/include -I/root/userfolder/anaconda3/envs/python27/lib/python2.7/site-packages/torch/lib/include/TH -I/root/userfolder/anaconda3/envs/python27/lib/python2.7/site-packages/torch/lib/include/THC -I/usr/local/cuda:/include -I/root/userfolder/anaconda3/envs/python27/include/python2.7 --compiler-options '-fPIC' --expt-extended-lambda -std=c++11 -c /root/userfolder/code/HRNet-Seg/lib/models/sync_bn/inplace_abn/src/inplace_abn_cuda.cu -o inplace_abn_cuda.cuda.o
/bin/sh: 1: /usr/local/cuda:/bin/nvcc: not found
[2/4] c++ -MMD -MF inplace_abn_cpu.o.d -DTORCH_EXTENSION_NAME=inplace_abn -I/root/userfolder/anaconda3/envs/python27/lib/python2.7/site-packages/torch/lib/include -I/root/userfolder/anaconda3/envs/python27/lib/python2.7/site-packages/torch/lib/include/TH -I/root/userfolder/anaconda3/envs/python27/lib/python2.7/site-packages/torch/lib/include/THC -I/usr/local/cuda:/include -I/root/userfolder/anaconda3/envs/python27/include/python2.7 -fPIC -std=c++11 -O3 -c /root/userfolder/code/HRNet-Seg/lib/models/sync_bn/inplace_abn/src/inplace_abn_cpu.cpp -o inplace_abn_cpu.o
[3/4] c++ -MMD -MF inplace_abn.o.d -DTORCH_EXTENSION_NAME=inplace_abn -I/root/userfolder/anaconda3/envs/python27/lib/python2.7/site-packages/torch/lib/include -I/root/userfolder/anaconda3/envs/python27/lib/python2.7/site-packages/torch/lib/include/TH -I/root/userfolder/anaconda3/envs/python27/lib/python2.7/site-packages/torch/lib/include/THC -I/usr/local/cuda:/include -I/root/userfolder/anaconda3/envs/python27/include/python2.7 -fPIC -std=c++11 -O3 -c /root/userfolder/code/HRNet-Seg/lib/models/sync_bn/inplace_abn/src/inplace_abn.cpp -o inplace_abn.o
ninja: build stopped: subcommand failed.

@GuangyanZhang
Copy link
Author

@frostinassiky you should change the default.py~

@GuangyanZhang
Copy link
Author

@yanyunyun ,没有出现过,这个应该还是ninja的问题

@sxhsunday
Copy link

@yanyunyun
Seg/lib/models/sync_bn/inplace_abn/src/inplace_abn.cpp -o inplace_abn.o
ninja: build stopped: subcommand failed.
did you solve this problem?

@yanli-star
Copy link

@sxhsunday
I solved this issue by installing pytorch 1.1 and using pytorch-v1.1 branch.

@sxhsunday
Copy link

@yanyunyun
Thank you very much. it is work now.

@kaishijeng
Copy link

@sxhsunday @yanyunyun

I install pytorch 1.1 using conda and checkout pytorch v1.1 branch. However, I still got the same error.
Can you provide instruction how you install pytorch 1.1 and checkout pytorch v1.1 branch?
ALso which version ninja fo you use?

Thanks,

@neverstoplearn
Copy link

@sxhsunday @yanyunyun

I install pytorch 1.1 using conda and checkout pytorch v1.1 branch. However, I still got the same error.
Can you provide instruction how you install pytorch 1.1 and checkout pytorch v1.1 branch?
ALso which version ninja fo you use?

Thanks,

I have the same error as you have you solve it? thanks,

@kaizen0890
Copy link

I found that this error relates to version matching problem, specifying between Torch and ninja version.
Therefore I solved this problem by finding ninja version which matching with Torch version.
My environment as show as below:
Ubuntu: 16.04
Gcc: 6.5.0
Python: 3.5.2
Torch: 0.4.1
ninja: 1.8.2
Hopefully that it can help you guys!

@iris0329
Copy link

iris0329 commented Apr 9, 2020

@sxhsunday
I solved this issue by installing pytorch 1.1 and using pytorch-v1.1 branch.

It works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests