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

windows installation error #63

Closed
Kur-Ich opened this issue Oct 29, 2021 · 6 comments
Closed

windows installation error #63

Kur-Ich opened this issue Oct 29, 2021 · 6 comments

Comments

@Kur-Ich
Copy link

Kur-Ich commented Oct 29, 2021

Hi, I've installed the Tensorflow for C folder in 'C:\libtensorflow 2.6.0' and added this folder to the Path environment variables. Using 'go get github.com/galeone/tfgo' I get the following error:

21b591\attrs.go:20:11: fatal error: tensorflow/c/c_api.h: No such file or directory
   20 | // #include "tensorflow/c/c_api.h"

Is something else still needed?

@galeone
Copy link
Owner

galeone commented Oct 29, 2021

I have no idea since I don't use windows. But we treated this topic some time ago in another issue, and it looks like Go bindings on Windows are not officially supported, but if you're willing to hack a little bit it seems possible to make them work #46 (comment)

I haven't tried it since I don't have a Windows machine

@galeone galeone closed this as completed Nov 6, 2021
@HFANFA
Copy link

HFANFA commented Nov 14, 2022

Hello, lucky to meet here, I also had the same problem on Windows and it was solved after trying some scenarios.

As a share, hope it helps:

(1) First you need a 64-bit gcc environment (MINGW64) and properly configured to the environment variables (so that go can be called);

(2) Next, you need to go to the Tensorflow distribution API (https://www.tensorflow.org/install/lang_c) to download the corresponding C version API;

(3) Extract to a suitable directory, then you need to add the directory to the environment variable and log out of the system to log in again.

PS: (My own solution is to directly merge 'lib' and 'include' in the file into 'lib' and 'include' under MINGW64, even if this is not easy to manage, but the configuration environment variables are omitted);The MINGW64 I use is supported by msys64.

You can then check that tensorflow's C API can be successfully called with the following simple code:

#include <stdio.h>
#include <tensorflow/c/c_api.h>
//Note: Include files start with tensorflow layers,if not find, check your environment variables
int main() {
  printf("Hello from TensorFlow C library version %s\n", TF_Version());
  return 0;
}

and Compile the sample program to create an executable file, and then run the following command:

  gcc hello_tf.c -ltensorflow -o hello_tf

  ./hello_tf

  [output]:Hello from TensorFlow C library version number

After that, you can use "go get" to continue installing 'tfgo' and determine whether it is available through the examples in the documentation

@galeone
Copy link
Owner

galeone commented Nov 14, 2022

hey @iFANGXIE this is great news!

This process can be helpful for other Windows users. Can you open a merge request adding this in a new section in the README?

If you speak Chinese, it would be also great if you can update the README.cn.md file. Thank you!

@Prayforhanluo
Copy link

Hello, lucky to meet here, I also had the same problem on Windows and it was solved after trying some scenarios.

As a share, hope it helps:

(1) First you need a 64-bit gcc environment (MINGW64) and properly configured to the environment variables (so that go can be called);

(2) Next, you need to go to the Tensorflow distribution API (https://www.tensorflow.org/install/lang_c) to download the corresponding C version API;

(3) Extract to a suitable directory, then you need to add the directory to the environment variable and log out of the system to log in again.

PS: (My own solution is to directly merge 'lib' and 'include' in the file into 'lib' and 'include' under MINGW64, even if this is not easy to manage, but the configuration environment variables are omitted);The MINGW64 I use is supported by msys64.

You can then check that tensorflow's C API can be successfully called with the following simple code:

#include <stdio.h>
#include <tensorflow/c/c_api.h>
//Note: Include files start with tensorflow layers,if not find, check your environment variables
int main() {
  printf("Hello from TensorFlow C library version %s\n", TF_Version());
  return 0;
}

and Compile the sample program to create an executable file, and then run the following command:

  gcc hello_tf.c -ltensorflow -o hello_tf

  ./hello_tf

  [output]:Hello from TensorFlow C library version number

After that, you can use "go get" to continue installing 'tfgo' and determine whether it is available through the examples in the documentation

still not work TnT

@ThorvaldOF
Copy link

I had the same issue with the C library, thanks a lot HFANFA for your solution, it worked

@Yuelioi
Copy link

Yuelioi commented Jul 5, 2024

If someone use HFANFA's solution and not work, maybe you can try rebot~ and then worked

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

6 participants