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

Issue with running tensorflow cpp releases #59

Closed
HackersSpirit opened this issue Nov 27, 2018 · 13 comments
Closed

Issue with running tensorflow cpp releases #59

HackersSpirit opened this issue Nov 27, 2018 · 13 comments

Comments

@HackersSpirit
Copy link

HackersSpirit commented Nov 27, 2018

Hello,
OS: Windows 10 64-bit
I tried to run the tensorflow program with different versions of tensorflow and getting the similar error all the time:
class std::basic_string<char,struct std::char_traits,class std::allocator > __cdecl tensorflow::Status::ToString(void)const " (?ToString@Status@tensorflow@@qeba?AV?$basic_string@DU?$char_traits@D@std@@v?$allocator@D@2@@std@@xz) referenced in function main
main.obj : error LNK2019: unresolved external symbol "public: virtual __cdecl tensorflow::ConfigProto::~ConfigProto(void)" (??1ConfigProto@tensorflow@@UEAA@XZ) referenced in function "public: __cdecl tensorflow::SessionOptions::~SessionOptions(void)" (??1SessionOptions@tensorflow@@qeaa@XZ)
main.obj : error LNK2019: unresolved external symbol "public: __cdecl tensorflow::SessionOptions::SessionOptions(void)" (??0SessionOptions@tensorflow@@qeaa@XZ) referenced in function main
main.obj : error LNK2019: unresolved external symbol "class tensorflow::Status __cdecl tensorflow::NewSession(struct tensorflow::SessionOptions const &,class tensorflow::Session * )" (?NewSession@tensorflow@@ya?AVStatus@1@AEBUSessionOptions@1@PEAPEAVSession@1@@z) referenced in function main
debug\tensorflowcppNew.exe : fatal error LNK1120: 4 unresolved externals
All the versions give me a linking error:
Please find the sample code that i am trying to run:
Session
session;
Status status = NewSession(SessionOptions(), &session);

if (!status.ok()) {
     std::cout << status.ToString() << "\n";
     return 1;
    }
``
@fo40225
Copy link
Owner

fo40225 commented Nov 27, 2018

You can use Release build instead of Debug build to see if it resolve this error or not.

@HackersSpirit
Copy link
Author

HackersSpirit commented Nov 28, 2018

@fo40225 : Exactly which one is the release build. I downloaded suppose tensorflow 1.8 in lib folder i can see tensorflow.lib and tensorflow_static.lib
And there is tensorflow.dll file in the bin folder.
Sharing the program and the error message for clarity:
Program:

#define NOMINMAX
#include <Windows.h>
#include <QCoreApplication>
#include "tensorflow/core/public/session.h"
#include "tensorflow/core/platform/env.h"
#include "tensorflow/cc/client/client_session.h"

using namespace tensorflow;

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    Session* session;
     Status status = NewSession(SessionOptions(), &session);
     if (!status.ok()) {
       std::cout << status.ToString() << "\n";
       return 1;
     }

    return a.exec();
}

Error Message:
ain.obj : error LNK2019: unresolved external symbol "public: class std::basic_string<char,struct std::char_traits,class std::allocator > __cdecl tensorflow::Status::ToString(void)const " (?ToString@Status@tensorflow@@qeba?AV?$basic_string@DU?$char_traits@D@std@@v?$allocator@D@2@@std@@xz) referenced in function main
main.obj : error LNK2019: unresolved external symbol "public: virtual __cdecl tensorflow::ConfigProto::~ConfigProto(void)" (??1ConfigProto@tensorflow@@UEAA@XZ) referenced in function "public: __cdecl tensorflow::SessionOptions::~SessionOptions(void)" (??1SessionOptions@tensorflow@@qeaa@XZ)
main.obj : error LNK2019: unresolved external symbol "public: __cdecl tensorflow::SessionOptions::SessionOptions(void)" (??0SessionOptions@tensorflow@@qeaa@XZ) referenced in function main
main.obj : error LNK2019: unresolved external symbol "class tensorflow::Status __cdecl tensorflow::NewSession(struct tensorflow::SessionOptions const &,class tensorflow::Session * *)" (?NewSession@tensorflow@@ya?AVStatus@1@AEBUSessionOptions@1@PEAPEAVSession@1@@z) referenced in function main
debug\tensorflowcppNew.exe : fatal error LNK1120: 4 unresolved externals

@fo40225
Copy link
Owner

fo40225 commented Nov 28, 2018

Try to link protobuf 3.4.1 lib in your project

@HackersSpirit
Copy link
Author

Do I have to download and build it.
Because i tried to link protobuf.lib file which i got through bazel build and it is giving me
the same error condition

@fo40225
Copy link
Owner

fo40225 commented Nov 30, 2018

I got tons of link error when I link with tensorflow_static.lib and link with tensorflow.lib is no problem.

@HackersSpirit
Copy link
Author

@fo40225 : Actually i am getting symbol not found issue in the library. It is similar to the issue faced in the libtensorflow_cc.so generated by bazel which is an ongoing issue in the forum.
Can you please try to run the sample program on prebuilt libary of tensorflow 1.8 or can you please tell the exact steps which you are following so that i can replicate.
I am stuck in the issue for long time.

@fo40225
Copy link
Owner

fo40225 commented Dec 8, 2018

https://youtu.be/7u3tE1lqmbw

@HackersSpirit
Copy link
Author

@fo40225 : Thanks for the video was very helpful.
I was able to find out that following release did not run on my system: libtensorflow-cpu-windows-x86_64-1.8.0-avx2
Where as following release ran successfully: libtensorflow-cpu-windows-x86_64-1.8.0-sse2
I have did a bit google and found out that this are the instruction sets supported by cpu.
The tensorflow source which i have tried to build gives me the similar issue, so i would like to know that any special instruction have to be passed while building from source or this is done internally.
Also if you have any idea using bazel for similar issue.
Thanks

@fo40225
Copy link
Owner

fo40225 commented Dec 10, 2018

You can check your cpu is avx2 instruction sets supported or not,

and you should change the compiler options in your project's property.
https://docs.microsoft.com/en-us/cpp/build/reference/arch-x64

@HackersSpirit
Copy link
Author

@fo40225 : Actually I thing my cpu supports avx2. Because when i run the program using the pre-build library file it gives following message:2018-12-10 13:53:10.355529: Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2
But when i run your precompiled binary which supports AVX AVX2 i get the above mentioned errrors.

@fo40225
Copy link
Owner

fo40225 commented Dec 10, 2018

https://youtu.be/aoIS-wuoPdg

Can't reproduce your error.

@HackersSpirit
Copy link
Author

@fo40225 : Just making myself clear.
Actually the above message : Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2
Does not appear as error message. It just gets displayed on the command line when i run the library build using sse2.

@fo40225
Copy link
Owner

fo40225 commented Dec 19, 2018

@HackersSpirit all build is Release built (in fact, tensorflow will build break in debug mode)

press ALT + mouse or arrow key to do column selection (vertical selection, block selection whatever) in most code editor (even in Word)

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