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: Error building extension 'add2',后面这句不理解fatal error: add2.h: No such file or directory #6

Open
Henry-Avery opened this issue Dec 28, 2021 · 2 comments

Comments

@Henry-Avery
Copy link

我在Jupiter notebook里运行下面jit命令的编译报错如下
python3 time.py --compiler jit

Using /tmp/torch_extensions as PyTorch extensions root...
Detected CUDA files, patching ldflags
Emitting ninja build file /tmp/torch_extensions/add2/build.ninja...
Building extension module add2...
[1/2] c++ -MMD -MF add2_ops.o.d -DTORCH_EXTENSION_NAME=add2 -DTORCH_API_INCLUDE_EXTENSION_H -I/gby/NN-CUDA-Example-master/pytorch/include -isystem /usr/local/lib/python3.6/dist-packages/torch/include -isystem /usr/local/lib/python3.6/dist-packages/torch/include/torch/csrc/api/include -isystem /usr/local/lib/python3.6/dist-packages/torch/include/TH -isystem /usr/local/lib/python3.6/dist-packages/torch/include/THC -isystem /usr/local/cuda/include -isystem /usr/include/python3.6m -D_GLIBCXX_USE_CXX11_ABI=0 -fPIC -std=c++11 -c /gby/NN-CUDA-Example-master/pytorch/add2_ops.cpp -o add2_ops.o
FAILED: add2_ops.o
c++ -MMD -MF add2_ops.o.d -DTORCH_EXTENSION_NAME=add2 -DTORCH_API_INCLUDE_EXTENSION_H -I/gby/NN-CUDA-Example-master/pytorch/include -isystem /usr/local/lib/python3.6/dist-packages/torch/include -isystem /usr/local/lib/python3.6/dist-packages/torch/include/torch/csrc/api/include -isystem /usr/local/lib/python3.6/dist-packages/torch/include/TH -isystem /usr/local/lib/python3.6/dist-packages/torch/include/THC -isystem /usr/local/cuda/include -isystem /usr/include/python3.6m -D_GLIBCXX_USE_CXX11_ABI=0 -fPIC -std=c++11 -c /gby/NN-CUDA-Example-master/pytorch/add2_ops.cpp -o add2_ops.o
/gby/NN-CUDA-Example-master/pytorch/add2_ops.cpp:2:10: fatal error: add2.h: No such file or directory
#include "add2.h"
^~~~~~~~
compilation terminated.
ninja: build stopped: subcommand failed.
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/torch/utils/cpp_extension.py", line 960, in _build_extension_module
check=True)
File "/usr/lib/python3.6/subprocess.py", line 438, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "time.py", line 56, in
verbose=True)
File "/usr/local/lib/python3.6/dist-packages/torch/utils/cpp_extension.py", line 658, in load
is_python_module)
File "/usr/local/lib/python3.6/dist-packages/torch/utils/cpp_extension.py", line 827, in _jit_compile
with_cuda=with_cuda)
File "/usr/local/lib/python3.6/dist-packages/torch/utils/cpp_extension.py", line 880, in _write_ninja_file_and_build
_build_extension_module(name, build_directory, verbose)
File "/usr/local/lib/python3.6/dist-packages/torch/utils/cpp_extension.py", line 973, in _build_extension_module
raise RuntimeError(message)
RuntimeError: Error building extension 'add2'

运行下面cmake命令的编译报错如下
Traceback (most recent call last):
File "time.py", line 60, in
torch.ops.load_library("build/libadd2.so")
File "/usr/local/lib/python3.6/dist-packages/torch/_ops.py", line 106, in load_library
ctypes.CDLL(path)
File "/usr/lib/python3.6/ctypes/init.py", line 348, in init
self._handle = _dlopen(self._name, mode)
OSError: /gby/NN-CUDA-Example-master/pytorch/build/libadd2.so: cannot open shared object file: No such file or directory

@Henry-Avery
Copy link
Author

我把#nclude路径改完#include "../include/add2.h"之后就找到文件了,但是又有新的报错error: expected constructor, destructor, or type conversion before ‘(’ token TORCH_LIBRARY(add2, m)

具体报错如下

Using /tmp/torch_extensions as PyTorch extensions root...
Detected CUDA files, patching ldflags
Emitting ninja build file /tmp/torch_extensions/add2/build.ninja...
Building extension module add2...
[1/2] c++ -MMD -MF add2_ops.o.d -DTORCH_EXTENSION_NAME=add2 -DTORCH_API_INCLUDE_EXTENSION_H -I/gby/NN-CUDA-Example-master/pytorch/include -isystem /usr/local/lib/python3.6/dist-packages/torch/include -isystem /usr/local/lib/python3.6/dist-packages/torch/include/torch/csrc/api/include -isystem /usr/local/lib/python3.6/dist-packages/torch/include/TH -isystem /usr/local/lib/python3.6/dist-packages/torch/include/THC -isystem /usr/local/cuda/include -isystem /usr/include/python3.6m -D_GLIBCXX_USE_CXX11_ABI=0 -fPIC -std=c++11 -c /gby/NN-CUDA-Example-master/pytorch/add2_ops.cpp -o add2_ops.o
FAILED: add2_ops.o
c++ -MMD -MF add2_ops.o.d -DTORCH_EXTENSION_NAME=add2 -DTORCH_API_INCLUDE_EXTENSION_H -I/gby/NN-CUDA-Example-master/pytorch/include -isystem /usr/local/lib/python3.6/dist-packages/torch/include -isystem /usr/local/lib/python3.6/dist-packages/torch/include/torch/csrc/api/include -isystem /usr/local/lib/python3.6/dist-packages/torch/include/TH -isystem /usr/local/lib/python3.6/dist-packages/torch/include/THC -isystem /usr/local/cuda/include -isystem /usr/include/python3.6m -D_GLIBCXX_USE_CXX11_ABI=0 -fPIC -std=c++11 -c /gby/NN-CUDA-Example-master/pytorch/add2_ops.cpp -o add2_ops.o
/gby/NN-CUDA-Example-master/pytorch/add2_ops.cpp:20:14: error: expected constructor, destructor, or type conversion before ‘(’ token
TORCH_LIBRARY(add2, m) {
^
ninja: build stopped: subcommand failed.
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/torch/utils/cpp_extension.py", line 960, in _build_extension_module
check=True)
File "/usr/lib/python3.6/subprocess.py", line 438, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "time.py", line 56, in
verbose=True)
File "/usr/local/lib/python3.6/dist-packages/torch/utils/cpp_extension.py", line 658, in load
is_python_module)
File "/usr/local/lib/python3.6/dist-packages/torch/utils/cpp_extension.py", line 827, in _jit_compile
with_cuda=with_cuda)
File "/usr/local/lib/python3.6/dist-packages/torch/utils/cpp_extension.py", line 880, in _write_ninja_file_and_build
_build_extension_module(name, build_directory, verbose)
File "/usr/local/lib/python3.6/dist-packages/torch/utils/cpp_extension.py", line 973, in _build_extension_module
raise RuntimeError(message)
RuntimeError: Error building extension 'add2'

@Joeland4
Copy link

我把#nclude路径改完#include "../include/add2.h"之后就找到文件了,但是又有新的报错error: expected constructor, destructor, or type conversion before ‘(’ token TORCH_LIBRARY(add2, m)

具体报错如下

Using /tmp/torch_extensions as PyTorch extensions root... Detected CUDA files, patching ldflags Emitting ninja build file /tmp/torch_extensions/add2/build.ninja... Building extension module add2... [1/2] c++ -MMD -MF add2_ops.o.d -DTORCH_EXTENSION_NAME=add2 -DTORCH_API_INCLUDE_EXTENSION_H -I/gby/NN-CUDA-Example-master/pytorch/include -isystem /usr/local/lib/python3.6/dist-packages/torch/include -isystem /usr/local/lib/python3.6/dist-packages/torch/include/torch/csrc/api/include -isystem /usr/local/lib/python3.6/dist-packages/torch/include/TH -isystem /usr/local/lib/python3.6/dist-packages/torch/include/THC -isystem /usr/local/cuda/include -isystem /usr/include/python3.6m -D_GLIBCXX_USE_CXX11_ABI=0 -fPIC -std=c++11 -c /gby/NN-CUDA-Example-master/pytorch/add2_ops.cpp -o add2_ops.o FAILED: add2_ops.o c++ -MMD -MF add2_ops.o.d -DTORCH_EXTENSION_NAME=add2 -DTORCH_API_INCLUDE_EXTENSION_H -I/gby/NN-CUDA-Example-master/pytorch/include -isystem /usr/local/lib/python3.6/dist-packages/torch/include -isystem /usr/local/lib/python3.6/dist-packages/torch/include/torch/csrc/api/include -isystem /usr/local/lib/python3.6/dist-packages/torch/include/TH -isystem /usr/local/lib/python3.6/dist-packages/torch/include/THC -isystem /usr/local/cuda/include -isystem /usr/include/python3.6m -D_GLIBCXX_USE_CXX11_ABI=0 -fPIC -std=c++11 -c /gby/NN-CUDA-Example-master/pytorch/add2_ops.cpp -o add2_ops.o /gby/NN-CUDA-Example-master/pytorch/add2_ops.cpp:20:14: error: expected constructor, destructor, or type conversion before ‘(’ token TORCH_LIBRARY(add2, m) { ^ ninja: build stopped: subcommand failed. Traceback (most recent call last): File "/usr/local/lib/python3.6/dist-packages/torch/utils/cpp_extension.py", line 960, in _build_extension_module check=True) File "/usr/lib/python3.6/subprocess.py", line 438, in run output=stdout, stderr=stderr) subprocess.CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "time.py", line 56, in verbose=True) File "/usr/local/lib/python3.6/dist-packages/torch/utils/cpp_extension.py", line 658, in load is_python_module) File "/usr/local/lib/python3.6/dist-packages/torch/utils/cpp_extension.py", line 827, in _jit_compile with_cuda=with_cuda) File "/usr/local/lib/python3.6/dist-packages/torch/utils/cpp_extension.py", line 880, in _write_ninja_file_and_build _build_extension_module(name, build_directory, verbose) File "/usr/local/lib/python3.6/dist-packages/torch/utils/cpp_extension.py", line 973, in _build_extension_module raise RuntimeError(message) RuntimeError: Error building extension 'add2'

请问报错解决了吗?同样的报错。

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

2 participants