google-coral / libedgetpu

Source code for the userspace level runtime driver for Coral.ai devices.
Apache License 2.0
179 stars 60 forks source link

Can't use Makefile build #55

Closed drosseau closed 7 months ago

drosseau commented 8 months ago

Description

I'm trying to build this library with the Makefile method, but I can't seem to get it working.

Here is my process:

CODEPATH=/home/user/code/github.com
EDGETPU=$CODEPATH/google-coral/libedgetpu
TFROOT=$CODEPATH/tensorflow/tensorflow

$ git clone https://github.com/tensorflow/tensorflow $TFROOT
$ git clone https://github.com/google-coral/libedgetpu $EDGETPU
$ cd $TFROOT
$ git checkout v2.11.1
$ cd $EDGETPU
$ git checkout release-grouper
$ make SHELL=$(which bash) TFROOT=$TFROOT -f makefile_build/Makefile libedgetpu
make: *** No rule to make target '/home/user/code/github.com/tensorflow/tensorflow/tensorflow/lite/c/common.c', needed by '/home/user/code/github.com/google-coral/libedgetpu/makefile_build/../out//home/user/code/github.com/tensorflow/tensorflow/tensorflow/lite/c/common.o'.  Stop.

Sadly I'm not too familiar with debugging Makefiles so I'm not able to fully understand why that error is occuring

$ make --version
GNU Make 4.4.1
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Click to expand! ### Issue Type Build/Install ### Operating System Linux ### Coral Device USB Accelerator ### Other Devices _No response_ ### Programming Language _No response_ ### Relevant Log Output _No response_
tosa-no-onchan commented 8 months ago

I got same error too. I think, libedgetpu is suitable for tensorflow 2.5. Try it with tensorflow 2.5. See https://github.com/google-coral/libedgetpu/blob/master/workspace.bzl

$ git clone https://github.com/tensorflow/tensorflow $ cd tensorflow $ git checkout a4dfb8d1a71385bd6d122e4f27f86dcebb96712d -b tf2.5

tosa-no-onchan commented 8 months ago

I found the flowwing,

in libedgetpu/makefile_build/Makefile ... 65 LIBEDGETPU_CSRCS := $(TFROOT)/tensorflow/lite/c/common.c 66 LIBEDGETPU_COBJS := $(call TOBUILDDIR,$(patsubst %.c,%.o,$(LIBEDGETPU_CSRCS)))

But in tensorflow newer verion than 2.5, there is not common.c on $(TFROOT)/tensorflow/lite/c/

tosa-no-onchan commented 8 months ago

edit libedgetpu/makefile_build/Makefile ... 65 #LIBEDGETPU_CSRCS := $(TFROOT)/tensorflow/lite/c/common.c 65 LIBEDGETPU_CSRCS := $(TFROOT)/tensorflow/lite/core/c/common.cc ... 187 #$(LIBEDGETPU_COBJS) : $(BUILDDIR)/%.o: %.c 187 $(LIBEDGETPU_COBJS) : $(BUILDDIR)/%.o: %.cc ...

and try it with tf 2.11.1

tosa-no-onchan commented 8 months ago

Sorry, edit libedgetpu/makefile_build/Makefile does not work. try with tf2.5

drosseau commented 8 months ago

Thanks for the ideas, I think you helped me figure out it.

I had to make these changes:

diff --git a/makefile_build/Makefile b/makefile_build/Makefile
index ef7d290..74ec2cb 100644
--- a/makefile_build/Makefile
+++ b/makefile_build/Makefile
@@ -22,7 +22,7 @@ LIBEDGETPU_CFLAGS := \
 LIBEDGETPU_CXXFLAGS := \
    -fPIC \
    -Wall \
-   -std=c++14 \
+   -std=c++17 \
    -DDARWINN_PORT_DEFAULT

 LIBEDGETPU_LDFLAGS := \
@@ -59,10 +59,11 @@ LIBEDGETPU_INCLUDES := \
    $(BUILDDIR)/$(BUILDROOT)
 LIBEDGETPU_INCLUDES := $(addprefix -I,$(LIBEDGETPU_INCLUDES))

-LIBEDGETPU_CSRCS := $(TFROOT)/tensorflow/lite/c/common.c
+LIBEDGETPU_CSRCS :=
 LIBEDGETPU_COBJS := $(call TOBUILDDIR,$(patsubst %.c,%.o,$(LIBEDGETPU_CSRCS)))

 LIBEDGETPU_CCSRCS := \
+   $(TFROOT)/tensorflow/lite/c/common.cc \
    $(BUILDROOT)/api/allocated_buffer.cc \
    $(BUILDROOT)/api/buffer.cc \
    $(BUILDROOT)/api/driver_options_helper.cc \
diff --git a/api/allocated_buffer.h b/api/allocated_buffer.h
index 97740f0..7bc0547 100644
--- a/api/allocated_buffer.h
+++ b/api/allocated_buffer.h
@@ -16,6 +16,7 @@
 #define DARWINN_API_ALLOCATED_BUFFER_H_

 #include <functional>
+#include <cstddef>

 namespace platforms {
 namespace darwinn {

and then I changed my setup above to:

CODEPATH=/home/user/code/github.com
EDGETPU=$CODEPATH/google-coral/libedgetpu
TFROOT=$CODEPATH/tensorflow/tensorflow

$ git clone https://github.com/google-coral/libedgetpu $EDGETPU
$ git clone https://github.com/tensorflow/tensorflow $TFROOT
$ cd $TFROOT
$ git checkout v2.11.1
$ cd $EDGETPU
$ git checkout release-grouper
# The Makefile seemed to have issues with this being an absolute path
$ ln -s "$TFROOT" tensorflow
$ make SHELL=$(which bash) TFROOT=tensorflow -f makefile_build/Makefile libedgetpu
google-coral-bot[bot] commented 7 months ago

Are you satisfied with the resolution of your issue? Yes No