wamuir / graft

Go language bindings to the TensorFlow C API
https://pkg.go.dev/github.com/wamuir/graft
Apache License 2.0
44 stars 3 forks source link

Build error #13

Open exyzzy opened 1 year ago

exyzzy commented 1 year ago

Hello,

I'm on Mac m2, I think my go env is ok, and the basic gcc test for libtensorflow works fine. However, when I try to build your hello TensorFlow example here I get the following. Any ideas? Thanks

 % go install
# github.com/wamuir/graft/tensorflow
../../../../pkg/mod/github.com/wamuir/graft@v0.4.0/tensorflow/tensor.go:69:26: could not determine kind of name for C.TF_FLOAT8_E4M3FN
../../../../pkg/mod/github.com/wamuir/graft@v0.4.0/tensorflow/tensor.go:68:26: could not determine kind of name for C.TF_FLOAT8_E5M2
wamuir commented 1 year ago

Yep, you just need to use the graft release that matches your libtensorflow version. You are using a graft version that is newer than your libtensorflow. See releases and let me know if you have issues.

On Mon, May 8, 2023 at 11:32 AM Eric Lang @.***> wrote:

Hello,

I'm on Mac m2, I think my go env is ok, and the basic gcc test for libtensorflow works fine. However, when I try to build your hello TensorFlow example here I get the following. Any ideas? Thanks

% go install github.com/wamuir/graft/tensorflow

../../../../pkg/mod/ @./tensorflow/tensor.go:69:26: could not determine kind of name for C.TF_FLOAT8_E4M3FN ../../../../pkg/mod/ @./tensorflow/tensor.go:68:26: could not determine kind of name for C.TF_FLOAT8_E5M2

— Reply to this email directly, view it on GitHub https://github.com/wamuir/graft/issues/13, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEFPZETOKERIBXQ357GBK7TXFEGXPANCNFSM6AAAAAAX2DIHVQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

exyzzy commented 1 year ago

derp, yes, that was it. All is good. Thanks

janhartman commented 11 months ago

Hey @exyzzy, I'm curious as to how you got libtensorflow to work on your Mac. I have an M1 Mac and for some reason, even libtensorflow that I built myself (tried different versions, from 2.7 to 2.14) doesn't want to work. The funny thing is that it worked up to approx. this September and stopped after a MacOS update. If you can share any info it would be extremely helpful, thanks in advance! :)

janhartman commented 11 months ago

Figured it out - had to manually set DYLD_LIBRARY_PATH=/usr/local/lib. It didn't occur to me to try it before as I assumed this directory would be included by default.

ariden83 commented 3 months ago

horrible, by requiring me to fix the problem above, I am destroying my tensorflow installation... it's getting worse and worse... with messages such as:

2024-06-19 16: 45:58.857890: I tensorflow/core/platform/cpu_feature_guard.cc:210] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 AVX_VNNI FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.

2024-06-19 16:45:59.507007: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT

Was it not possible to indicate which version of tensorflow is compatible with the latest lib update in the readme ?

wamuir commented 3 months ago

@ariden83

2024-06-19 16: 45:58.857890: I tensorflow/core/platform/cpu_feature_guard.cc:210] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations. To enable the following instructions: AVX2 AVX_VNNI FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.

You have chosen to use a build of libtensorflow that does not take advantage of several CPU instructions. This is an informational message. Ignore it, use a different libtensorflow build, or compile libtensorflow yourself to use these instructions. If you don't like the info message then you should open an issue at: https://github.com/tensorflow/tensorflow.

2024-06-19 16:45:59.507007: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT

What did you expect? Did you install TensorRT? https://developer.nvidia.com/tensorrt

Was it not possible to indicate which version of tensorflow is compatible with the latest lib update in the readme ?

This information is listed clearly on the releases page https://github.com/wamuir/graft/releases

ariden83 commented 3 months ago

Still me, even using a docker image, I always encounter this error, can you help me.

  1. FROM nvcr.io/nvidia/tensorflow:24.01-tf2-py3
  2. curl -L "https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-linux-x86_64-2.8.0.tar.gz" | tar -C /usr/local -xz
  3. github.com/wamuir/graft v0.6.0

CF:

  1. I create this dockerfile with TensorFlow Version 2.14.0 :

https://github.com/ariden83/gocomments/blob/main/api/Dockerfile (using this image https://github.com/ariden83/gocomments/blob/main/model/Dockerfile (model_tensorflow-container))

  1. In the previous docker file we've got : RUN curl -L "https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-linux-x86_64-2.8.0.tar.gz" | tar -C /usr/local -xz

  2. In my GO mod, i required graft v0.6.0 : https://github.com/ariden83/gocomments/blob/main/api/go.mod > github.com/wamuir/graft v0.6.0

(I also tested with more old and recent versions of wamuir/graft 4.0, 4.1, 5, 5.1, 6, 6.1, 7, 8)

I've always got this error

github.com/wamuir/graft/tensorflow

vendor/github.com/wamuir/graft/tensorflow/tensor.go:69:26: could not determine kind of name for C.TF_FLOAT8_E4M3FN vendor/github.com/wamuir/graft/tensorflow/tensor.go:68:26: could not determine kind of name for C.TF_FLOAT8_E5M2

Could you help me to modify the dockerfile ?

wamuir commented 3 months ago

@ariden83 Assuming your machine is amd_64:

FROM golang:1.21-bookworm

RUN curl -L https://storage.googleapis.com/tensorflow/versions/2.16.1/libtensorflow-cpu-linux-$(uname -m).tar.gz \
    | tar xz --directory /usr/local \
    && ldconfig

WORKDIR /app
RUN curl -fSLs https://raw.githubusercontent.com/wamuir/graft/nightly/tools/graft_package/_libtensorflow_graft_hello.go\
    > hello_tf.go \
    && go mod init graft-test-app \
    && go get github.com/wamuir/graft@v0.8.1 \
    && go mod tidy

ENTRYPOINT ["go", "run"]
ariden83 commented 3 months ago

Thank you very much, its works well in local and in an docker image.