Closed adarsh-kr closed 6 years ago
Hi, please provide more information about your environment. What version of PyTorch are you using?
I am using torch==0.4.1.
I was initially running g++ compressionLayer.cc
which gave me the above mentioned error.
I located the torch.h file and added the path during compilation.
g++ -I /home/adarsh/.local/lib/python3.6/site-packages/torch/lib/include/ compressionLayer.cc
, which compiled but then I am getting following error :
/tmp/ccIqciqg.o: In function `at::infer_type(at::Tensor const&)':
compressionLayer.cc:(.text+0x241): undefined reference to `at::Error::Error(at::SourceLocation, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
/tmp/ccIqciqg.o: In function `at::UndefinedTensor::singleton()':
compressionLayer.cc:(.text._ZN2at15UndefinedTensor9singletonEv[_ZN2at15UndefinedTensor9singletonEv]+0x7): undefined reference to `at::UndefinedTensor::_singleton'
collect2: error: ld returned 1 exit status
Makefile:6: recipe for target 'compressionLayer.o' failed
make: *** [compressionLayer.o] Error 1
CompressionLayer.cc is this :
#include<torch/torch.h>
#include<iostream>
at::Tensor d_sigmoid(at::Tensor z) {
at::Tensor s = at::sigmoid(z);
return (1 - s) * s;
}
int main()
{}
What commands did you run to arrive at this compiler error? Please provide as much context as possible for me to help.
@goldsborough I have added all the info in the above comment. Please let me know if you have any questions.
You are not supposed to compile this code manually like this. Have you seen the setup.py and torch.utils.cpp_extensions.load instructions in the tutorial? I think it is explained quite well how to build an extension using the means we provide.
Can u pls tell me how build to this ?
It is explained in the tutorial here: https://pytorch.org/tutorials/advanced/cpp_extension.html#building-with-setuptools
My bad. I skipped that. Thanks
I am following this tutorial to create a C++ extension for Pytorch. My C++ code is giving following error :
How to get torch.h header file ? Is there some
pytorch-dev
version ?