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

Building Edge TPU in an existing build system #691

Closed
gsirocco opened this issue Dec 12, 2022 · 19 comments
Closed

Building Edge TPU in an existing build system #691

gsirocco opened this issue Dec 12, 2022 · 19 comments
Assignees
Labels
comp:model Model related isssues Hardware:M.2 Accelerator B+M Coral M.2 Accelerator B+M key issues subtype:ubuntu/linux Ubuntu/Linux Build/installation issues type:build/install Build and install issues

Comments

@gsirocco
Copy link

gsirocco commented Dec 12, 2022

Description

Hi, I have an existing application that I'd like to integrate TPU support with. I already have TF and TFLite support being built through existing libraries not using Bazel. This is running and being built on a Ubuntu PC with an 8 TPU PCIe card. What is the easiest way build this. Ideally, I hope I don't need to build from source but from prebuilt libraries with some minimal header files. Is there a way to do this? Thanks!

The basic code is like this:

      // Find TPU device.
      size_t num_devices;
      std::unique_ptr<edgetpu_device, decltype(&edgetpu_free_devices)> devices(edgetpu_list_devices(&num_devices), &edgetpu_free_devices);
     if (num_devices == 0) {
	std::cerr << "No connected TPU found" << std::endl;
	return 1;
      }
      printf("num tpus %d\n",num_devices);
      for(int dev=0;dev<num_devices;dev++)
	printf("dev #%d path %d %s\n",dev,devices.get()[dev].type,devices.get()[dev].path);
      const auto& available_tpus =
	edgetpu::EdgeTpuManager::GetSingleton()->EnumerateEdgeTpu();
      if(available_tpus.size() < NUM_LDPC_TPUS) {
	std::cerr << "This example requires two Edge TPUs to run.";
	return 1;
      }
      std::string model_file[NUM_LDPC_TPUS]={"ldpc_enc/testmodel_supertrim0_edgetpu.tflite",
	"ldpc_enc/testmodel_supertrim1_edgetpu.tflite",
	"ldpc_enc/testmodel_supertrim2_edgetpu.tflite",
	"ldpc_enc/testmodel_supertrim3_edgetpu.tflite"};
      for(int i=0; i<NUM_LDPC_TPUS; i++)
	{
	  //TF_data_ptr->ldpc_enc_tpu->ldpc_tpu.model[i] = tflite::FlatBufferModel::BuildFromFile(model_file[i].c_str());
	  cpptpu_ptr->model[i] = tflite::FlatBufferModel::BuildFromFile(model_file[i].c_str());
	  //if (!TF_data_ptr->ldpc_enc_tpu->ldpc_tpu.model[i]) {
	  if (!cpptpu_ptr->model[i]) {
	    std::cerr << "Cannot read model from " << model_file[i] << std::endl;
	    return 1;
	  }

	  //if (tflite::InterpreterBuilder(*TF_data_ptr->ldpc_enc_tpu->ldpc_tpu.model[i], TF_data_ptr->ldpc_enc_tpu->ldpc_tpu.resolver[i])(&TF_data_ptr->ldpc_enc_tpu->ldpc_tpu.interpreter[i]) != kTfLiteOk) {
	  if (tflite::InterpreterBuilder(*cpptpu_ptr->model[i], cpptpu_ptr->resolver[i])(&cpptpu_ptr->interpreter[i]) != kTfLiteOk) {
	    std::cerr << "Cannot create interpreter" << std::endl;
	    return 1;
	  }

	  const auto& device = devices.get()[i];
	  auto* delegate =
	    edgetpu_create_delegate(device.type, device.path, nullptr, 0);
	  printf("created delegate\n");
	  //TF_data_ptr->ldpc_enc_tpu->ldpc_tpu.interpreter[i]->ModifyGraphWithDelegate(delegate);
	  cpptpu_ptr->interpreter[i]->ModifyGraphWithDelegate(delegate);
	  printf("modified graph with delegate\n");

	  std::cout << "Thread: " << i << " Interpreter was built." << std::endl;
	  //if(TF_data_ptr->ldpc_enc_tpu->ldpc_tpu.interpreter[i]->AllocateTensors() != kTfLiteOk) {
	  if(cpptpu_ptr->interpreter[i]->AllocateTensors() != kTfLiteOk) {
	    printf("Tensors not allocated thread: %d\n", i);
	    return 1;
	  }
	}

    const auto* input_tensor = interpreter[fecparinst]->input_tensor(0);
    if (input_tensor->type != kTfLiteInt8) {
      std::cerr << "Input tensor shape does not match input image" << std::endl;
      return 1;
    }

    std::copy(fecframe.begin(), fecframe.end(),
	      interpreter[fecparinst]->typed_input_tensor<int8_t>(0));

    struct timeval st, et;
    gettimeofday(&st,NULL);
    //for (int i = 0; i < iters; ++i)
      CHECK_EQ(interpreter[fecparinst]->Invoke(), kTfLiteOk);
    gettimeofday(&et,NULL);
    elapsed_time[fecparinst] = ((et.tv_sec - st.tv_sec) * 1000000) + (et.tv_usec - st.tv_usec);
    
    const TfLiteTensor& tensor = *interpreter[fecparinst]->output_tensor(0);
    auto* data = reinterpret_cast<int8_t*>(tensor.data.data);
Click to expand!

Issue Type

Build/Install

Operating System

Ubuntu

Coral Device

M.2 Accelerator B+M

Other Devices

No response

Programming Language

C++

Relevant Log Output

No response

@google-coral-bot google-coral-bot bot added comp:model Model related isssues Hardware:M.2 Accelerator B+M Coral M.2 Accelerator B+M key issues subtype:ubuntu/linux Ubuntu/Linux Build/installation issues type:build/install Build and install issues labels Dec 12, 2022
@hjonnala
Copy link
Contributor

hjonnala commented Dec 13, 2022

Hello @gsirocco which tensorflow version are you using? Can you please go through this page and see if it helps..

@gsirocco
Copy link
Author

Hi, it is version: 2.7.0-dev20211101. I will look at the page. Thanks!

@gsirocco
Copy link
Author

gsirocco commented Dec 15, 2022

Hi, I have downloaded the libedgetpu and tensorflow source for includes, however I am getting the following error. I'm not sure if that's quite correct because the instructions say that edgetpu.h should be included but it seems like a lot more was necessary in terms of header files from the tensorflow source

error: ‘ops’ in namespace ‘tflite’ does not name a type
9 | tflite::ops::builtin::BuiltinOpResolver resolver

Dynamically link your code
Include the edgetpu.h or edgetpu_c.h file in your project.

Link to the libedgetpu.so file. You should have installed this library during device setup, but you can also build it yourself.

Clone the TensorFlow repo using the TENSORFLOW_COMMIT version specified here—that's the version used to build the libedgetpu.so library, so your TensorFlow version must match. Then build TensorFlow Lite (libtensorflow-lite.a) and also link to that.

For example code, checkout classify.cc and the corresponding Makefile.

@gsirocco
Copy link
Author

I'm also getting the error below. Is there something incorrect in the tensorflow source that I downloaded or do I need to download something additional? Thanks!

error: ‘FlatBufferModel’ is not a member of ‘tflite’

@gsirocco
Copy link
Author

I've gotten past the namspace errors by including the correct files.
I have to download an build flatbuffers as well, however the build result does not seem correct since I am getting the link error below. I have done "cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release" and then make believing that this should be correct for Linux on x86_64 machine? Any help for this is appreciated. Thanks!!

/usr/local/lib/libflatc.so: _ZTTNSt7__cxx1119basic_istringstreamIcSt11char_traitsIcESaIcEEE: invalid version 8 (max 0)

@gsirocco
Copy link
Author

gsirocco commented Dec 19, 2022

I have gotten past the flatbuffer link error by installing the flatbuffer properly to have a libflatbuffers.a
However, I am getting some linker errors for some tflite functions below. I am linking with: /usr/local/lib/libtensorflow_framework.so.2.7.0 /usr/local/lib/libtensorflow.so.2.7.0
/usr/local/lib/libtensorflowlite_c.so

warning: relocation against _ZTVN6tflite8resource20InitializationStatusE' in read-only section .text.ZN6tflite8resource20InitializationStatusC2EOS1[ZN6tflite8resource20InitializationStatusC5EOS1]'

undefined reference to `tflite::DefaultErrorReporter()'

undefined reference to `tflite::FlatBufferModel::BuildFromFile(char const*, tflite::ErrorReporter*)'

undefined reference to `tflite::FlatBufferModel::~FlatBufferModel()'

undefined reference to `tflite::InterpreterBuilder::InterpreterBuilder(tflite::FlatBufferModel const&, tflite::OpResolver const&, tflite::InterpreterOptions const*)'

(.data.rel.ro._ZTVN6tflite3ops7builtin40BuiltinOpResolverWithoutDefaultDelegatesE[_ZTVN6tflite3ops7builtin40BuiltinOpResolverWithoutDefaultDelegatesE]+0x18): undefined reference to `tflite::MutableOpResolver::FindOp(char const*, int) const'

@gsirocco
Copy link
Author

gsirocco commented Dec 20, 2022

I'm getting close I believe with the correct library. Now I am facing an issue which I believe has been seen before but I can't quite figure out what the solution is. Is there some missing library? I tried installing/linking with fftw but this didn't seem to do solve it. Thanks for any pointers on this. I think this is in fftw3? I have tried to link with libfftw3, but it doesn't seem to solve the issue.

/usr/bin/ld: /usr/local/lib/libtensorflow-lite.a(spectrogram.cc.o): undefined reference to symbol 'rdft'
/usr/bin/ld: /usr/local/lib//libtensorflow_framework.so.2: error adding symbols: DSO missing from command line

@gsirocco
Copy link
Author

gsirocco commented Dec 21, 2022

I found this solution to the 'rdft' undefined reference, but not really sure what the solution entails. Doing an nm on the fftw3 library, it doesn't look like rdft alone is defined, so I'm not sure where this is supposed to come from. Any pointers would be appreciated. I'm wondering if this would be the rdft source (https://packages.altlinux.org/en/p9/srpms/fft2d/)?

@hjonnala
Copy link
Contributor

hjonnala commented Jan 3, 2023

Hi, it is version: 2.7.0-dev20211101. Thanks!

Hi, are you able to build libedgetpu.so with your TF version?

@gsirocco
Copy link
Author

gsirocco commented Jan 5, 2023

I'm using tensorflow, tensorflow lite and tpu all in the same build. I'm not sure if the versions are compatible. How would I check the library versions of tensorflow, tensorflow lite and tpu to determine compatibility?
I see that the tensorflow libs are 2.7.0 by their file name below, but I'm not sure about the tensorflow-lite and libedgetpu. Is there any easy way to determine this from the library files? Thanks!

rwxrwxrwx 1 root root        28 Dec  2 01:31 libtensorflow_framework.so -> libtensorflow_framework.so.2
lrwxrwxrwx 1 root root        32 Dec  2 01:28 libtensorflow_framework.so.2 -> libtensorflow_framework.so.2.7.0
-r-xr-xr-x 1 root root  35625048 Dec  2 01:25 libtensorflow_framework.so.2.7.0
-r-xr-xr-x 1 root root   9161386 Dec 20 01:52 libtensorflow-lite.a
lrwxrwxrwx 1 root root        18 Dec  2 01:30 libtensorflow.so -> libtensorflow.so.2
lrwxrwxrwx 1 root root        22 Dec  2 01:29 libtensorflow.so.2 -> libtensorflow.so.2.7.0
-r-xr-xr-x 1 root root 327543408 Dec  2 01:25 libtensorflow.so.2.7.0
/var/lib/dpkg/info/libedgetpu-dev.md5sums
/var/lib/dpkg/info/libedgetpu1-max:amd64.triggers
/var/lib/dpkg/info/libedgetpu1-max:amd64.preinst
/var/lib/dpkg/info/libedgetpu1-max:amd64.templates
/var/lib/dpkg/info/libedgetpu1-max:amd64.shlibs
/var/lib/dpkg/info/libedgetpu1-max:amd64.postrm
/var/lib/dpkg/info/libedgetpu-dev.list
/var/lib/dpkg/info/libedgetpu1-max:amd64.list
/var/lib/dpkg/info/libedgetpu1-max:amd64.md5sums
/var/cache/apt/archives/libedgetpu1-max_16.0_amd64.deb
/var/cache/apt/archives/libedgetpu-dev_16.0_amd64.deb
/usr/lib/x86_64-linux-gnu/libedgetpu.so.1.0

@hjonnala
Copy link
Contributor

hjonnala commented Jan 5, 2023

You can build the libedgetpu seperately and then link libedgetpu.so with your current build.

  1. Please check the tensorflow version using the methods metntioned at: https://phoenixnap.com/kb/check-tensorflow-version
  2. get the tensorflow commit for your TF version and replace at: https://github.com/google-coral/libedgetpu/blob/master/workspace.bzl#L9
  3. Replace the TF commit in the below command to get the sha256 number and update the TENSORFLOW_SHA256: https://github.com/google-coral/libedgetpu/blob/master/workspace.bzl#L10
hemanth:~$ curl -fLs https://github.com/tensorflow/tensorflow/archive/<TF COMMIT>.tar.gz | sha256sum
hemanth:~$ curl -fLs https://github.com/tensorflow/tensorflow/archive/a4dfb8d1a71385bd6d122e4f27f86dcebb96712d.tar.gz | sha256sum
cb99f136dc5c89143669888a44bfdd134c086e1e2d9e36278c1eb0f03fe62d76  -
  1. Buid the libedgetpu using the make command.

@gsirocco
Copy link
Author

gsirocco commented Jan 6, 2023

Thanks for the steps. I have tried to do the libedgetpu make, but am getting the following error. Thanks!

~/libedgetpu$ make
Extracting Bazel installation...
Starting local Bazel server and connecting to it...
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
WARNING: Download from http://mirror.tensorflow.org/github.com/tensorflow/runtime/archive/64c92c8013b557087351c91b5423b6046d10f206.tar.gz failed: class java.io.FileNotFoundException GET returned 404 Not Found
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
 checking cached actions
WARNING: Download from https://storage.googleapis.com/mirror.tensorflow.org/github.com/llvm/llvm-project/archive/43d6991c2a4cc2ac374e68c029634f2b59ffdfdf.tar.gz failed: class java.io.FileNotFoundException GET returned 404 Not Found
 checking cached actions
 checking cached actions
 checking cached actions
Loading: 0 packages loaded
Loading: 1 packages loaded
bazel build --stripopt=-x --compilation_mode=opt --cpu=k8 --embed_label='TENSORFLOW_COMMIT=c256c071bb26e1e13b4666d1b3e229e110bc914a' --stamp //tflite/public:libedgetpu_direct_all.so.stripped
WARNING: Download from https://storage.googleapis.com/mirror.tensorflow.org/github.com/llvm/llvm-project/archive/43d6991c2a4cc2ac374e68c029634f2b59ffdfdf.tar.gz failed: class java.io.FileNotFoundException GET returned 404 Not Found
WARNING: Download from http://mirror.tensorflow.org/github.com/tensorflow/runtime/archive/64c92c8013b557087351c91b5423b6046d10f206.tar.gz failed: class java.io.FileNotFoundException GET returned 404 Not Found
ERROR: /home/gsosnow/.cache/bazel/_bazel_gsosnow/16a635ae350cf6bf2b0cceb1c00e2e1c/external/bazel_tools/platforms/BUILD:84:6: in alias rule @bazel_tools//platforms:linux: Constraints from @bazel_tools//platforms have been removed. Please use constraints from @platforms repository embedded in Bazel, or preferably declare dependency on https://github.com/bazelbuild/platforms. See https://github.com/bazelbuild/bazel/issues/8622 for details.
ERROR: /home/gsosnow/.cache/bazel/_bazel_gsosnow/16a635ae350cf6bf2b0cceb1c00e2e1c/external/bazel_tools/platforms/BUILD:84:6: Analysis of target '@bazel_tools//platforms:linux' failed
ERROR: /home/gsosnow/libedgetpu/tflite/public/BUILD:93:10: While resolving toolchains for target //tflite/public:libedgetpu_direct_all.so: Target @local_execution_config_platform//:platform was referenced as a platform, but does not provide PlatformInfo
ERROR: Analysis of target '//tflite/public:libedgetpu_direct_all.so.stripped' failed; build aborted:
INFO: Elapsed time: 0.981s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (7 packages loaded, 8 targets configured)
make: *** [Makefile:97: libedgetpu-direct] Error 1

@hjonnala
Copy link
Contributor

hjonnala commented Jan 6, 2023

Please try with either bazel version 4.0.0 or upgrade your tnesorflow to the latest version.

@gsirocco
Copy link
Author

gsirocco commented Jan 7, 2023

I have installed and made with bazel version 4.0.0. It has gotten a lot further, but has encountered this error. Thanks!!

SUBCOMMAND: # @com_google_absl//absl/strings:strings [action 'Compiling absl/strings/str_cat.cc', configuration: 90093f8df29368cc40dd23132025156f7bcc0c0de869534494b79dbb7d1e38d2, execution platform: @local_execution_config_platform//:platform]
(cd /home/gsosnow/.cache/bazel/_bazel_gsosnow/16a635ae350cf6bf2b0cceb1c00e2e1c/execroot/libedgetpu && \
  exec env - \
    PATH=/home/gsosnow/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin \
    PWD=/proc/self/cwd \
  /usr/bin/gcc -fPIC -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -msse4.2 -g0 -O3 -DNDEBUG '-D_FORTIFY_SOURCE=2' -ffunction-sections -fdata-sections '-std=c++14' -MD -MF bazel-out/k8-opt/bin/external/com_google_absl/absl/strings/_objs/strings/str_cat.d '-frandom-seed=bazel-out/k8-opt/bin/external/com_google_absl/absl/strings/_objs/strings/str_cat.o' -iquote external/com_google_absl -iquote bazel-out/k8-opt/bin/external/com_google_absl -Wall -Wextra -Wcast-qual -Wconversion-null -Wformat-security -Wmissing-declarations -Woverlength-strings -Wpointer-arith -Wundef -Wunused-local-typedefs -Wunused-result -Wvarargs -Wvla -Wwrite-strings -DNOMINMAX -no-canonical-prefixes -fno-canonical-system-headers -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -c external/com_google_absl/absl/strings/str_cat.cc -o bazel-out/k8-opt/bin/external/com_google_absl/absl/strings/_objs/strings/str_cat.o)
ERROR: /home/gsosnow/libedgetpu/api/BUILD:91:11: Compiling api/allocated_buffer.cc failed: (Exit 1): gcc failed: error executing command
  (cd /home/gsosnow/.cache/bazel/_bazel_gsosnow/16a635ae350cf6bf2b0cceb1c00e2e1c/sandbox/linux-sandbox/142/execroot/libedgetpu && \
  exec env - \
    PATH=/home/gsosnow/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin \
    PWD=/proc/self/cwd \
  /usr/bin/gcc -fPIC -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -msse4.2 -g0 -O3 -DNDEBUG '-D_FORTIFY_SOURCE=2' -ffunction-sections -fdata-sections '-std=c++14' -MD -MF bazel-out/k8-opt/bin/api/_objs/allocated_buffer/allocated_buffer.d '-frandom-seed=bazel-out/k8-opt/bin/api/_objs/allocated_buffer/allocated_buffer.o' -DDARWINN_PORT_DEFAULT -iquote . -iquote bazel-out/k8-opt/bin -iquote external/com_google_absl -iquote bazel-out/k8-opt/bin/external/com_google_absl -no-canonical-prefixes -fno-canonical-system-headers -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -c api/allocated_buffer.cc -o bazel-out/k8-opt/bin/api/_objs/allocated_buffer/allocated_buffer.o)
Execution platform: @local_execution_config_platform//:platform

Use --sandbox_debug to see verbose messages from the sandbox gcc failed: error executing command
  (cd /home/gsosnow/.cache/bazel/_bazel_gsosnow/16a635ae350cf6bf2b0cceb1c00e2e1c/sandbox/linux-sandbox/142/execroot/libedgetpu && \
  exec env - \
    PATH=/home/gsosnow/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin \
    PWD=/proc/self/cwd \
  /usr/bin/gcc -fPIC -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -msse4.2 -g0 -O3 -DNDEBUG '-D_FORTIFY_SOURCE=2' -ffunction-sections -fdata-sections '-std=c++14' -MD -MF bazel-out/k8-opt/bin/api/_objs/allocated_buffer/allocated_buffer.d '-frandom-seed=bazel-out/k8-opt/bin/api/_objs/allocated_buffer/allocated_buffer.o' -DDARWINN_PORT_DEFAULT -iquote . -iquote bazel-out/k8-opt/bin -iquote external/com_google_absl -iquote bazel-out/k8-opt/bin/external/com_google_absl -no-canonical-prefixes -fno-canonical-system-headers -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -c api/allocated_buffer.cc -o bazel-out/k8-opt/bin/api/_objs/allocated_buffer/allocated_buffer.o)
Execution platform: @local_execution_config_platform//:platform

Use --sandbox_debug to see verbose messages from the sandbox
In file included from api/allocated_buffer.cc:15:
./api/allocated_buffer.h:31:39: error: 'size_t' has not been declared
   31 |   AllocatedBuffer(unsigned char* ptr, size_t size_bytes,
      |                                       ^~~~~~
./api/allocated_buffer.h:47:3: error: 'size_t' does not name a type
   47 |   size_t size_bytes() const { return size_bytes_; }
      |   ^~~~~~
./api/allocated_buffer.h:19:1: note: 'size_t' is defined in header '<cstddef>'; did you forget to '#include <cstddef>'?
   18 | #include <functional>
  +++ |+#include <cstddef>
   19 |
./api/allocated_buffer.h:54:3: error: 'size_t' does not name a type
   54 |   size_t size_bytes_;
      |   ^~~~~~
./api/allocated_buffer.h:54:3: note: 'size_t' is defined in header '<cstddef>'; did you forget to '#include <cstddef>'?
api/allocated_buffer.cc:22:1: error: no declaration matches 'platforms::darwinn::AllocatedBuffer::AllocatedBuffer(unsigned char*, size_t, platforms::darwinn::AllocatedBuffer::FreeCallback)'
   22 | AllocatedBuffer::AllocatedBuffer(unsigned char* ptr, size_t size_bytes,
      | ^~~~~~~~~~~~~~~
In file included from api/allocated_buffer.cc:15:
./api/allocated_buffer.h:37:3: note: candidates are: 'platforms::darwinn::AllocatedBuffer::AllocatedBuffer(const platforms::darwinn::AllocatedBuffer&)'
   37 |   AllocatedBuffer(const AllocatedBuffer&) = delete;
      |   ^~~~~~~~~~~~~~~
./api/allocated_buffer.h:31:3: note:                 'platforms::darwinn::AllocatedBuffer::AllocatedBuffer(unsigned char*, int, platforms::darwinn::AllocatedBuffer::FreeCallback)'
   31 |   AllocatedBuffer(unsigned char* ptr, size_t size_bytes,
      |   ^~~~~~~~~~~~~~~
./api/allocated_buffer.h:26:7: note: 'class platforms::darwinn::AllocatedBuffer' defined here
   26 | class AllocatedBuffer {
      |       ^~~~~~~~~~~~~~~
Target //tflite/public:libedgetpu_direct_all.so.stripped failed to build
INFO: Elapsed time: 19.843s, Critical Path: 7.42s
INFO: 326 processes: 197 internal, 129 linux-sandbox.
FAILED: Build did NOT complete successfully
make: *** [Makefile:97: libedgetpu-direct] Error 1

@hjonnala
Copy link
Contributor

hjonnala commented Jan 7, 2023

./api/allocated_buffer.h:54:3: note: 'size_t' is defined in header ''; did you forget to '#include '?

Please add #include <cstddef> to libedgetpu/api/allocated_buffer.h file.

@gsirocco
Copy link
Author

gsirocco commented Jan 7, 2023

Thanks, now getting this error. I guess some usb library needs to be installed?

SUBCOMMAND: # @com_google_absl//absl/flags:flag_internal [action 'Compiling absl/flags/internal/flag.cc', configuration: 90093f8df29368cc40dd23132025156f7bcc0c0de869534494b79dbb7d1e38d2, execution platform: @local_execution_config_platform//:platform]
(cd /home/gsosnow/.cache/bazel/_bazel_gsosnow/16a635ae350cf6bf2b0cceb1c00e2e1c/execroot/libedgetpu && \
  exec env - \
    PATH=/home/gsosnow/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin \
    PWD=/proc/self/cwd \
  /usr/bin/gcc -fPIC -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -msse4.2 -g0 -O3 -DNDEBUG '-D_FORTIFY_SOURCE=2' -ffunction-sections -fdata-sections '-std=c++14' -MD -MF bazel-out/k8-opt/bin/external/com_google_absl/absl/flags/_objs/flag_internal/flag.d '-frandom-seed=bazel-out/k8-opt/bin/external/com_google_absl/absl/flags/_objs/flag_internal/flag.o' -iquote external/com_google_absl -iquote bazel-out/k8-opt/bin/external/com_google_absl -Wall -Wextra -Wcast-qual -Wconversion-null -Wformat-security -Wmissing-declarations -Woverlength-strings -Wpointer-arith -Wundef -Wunused-local-typedefs -Wunused-result -Wvarargs -Wvla -Wwrite-strings -DNOMINMAX -no-canonical-prefixes -fno-canonical-system-headers -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -c external/com_google_absl/absl/flags/internal/flag.cc -o bazel-out/k8-opt/bin/external/com_google_absl/absl/flags/_objs/flag_internal/flag.o)
ERROR: /home/gsosnow/libedgetpu/driver/usb/BUILD:33:11: Compiling driver/usb/libusb_options_default.cc failed: (Exit 1): gcc failed: error executing command
  (cd /home/gsosnow/.cache/bazel/_bazel_gsosnow/16a635ae350cf6bf2b0cceb1c00e2e1c/sandbox/linux-sandbox/247/execroot/libedgetpu && \
  exec env - \
    PATH=/home/gsosnow/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin \
    PWD=/proc/self/cwd \
  /usr/bin/gcc -fPIC -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -msse4.2 -g0 -O3 -DNDEBUG '-D_FORTIFY_SOURCE=2' -ffunction-sections -fdata-sections '-std=c++14' -MD -MF bazel-out/k8-opt/bin/driver/usb/_objs/libusb_options/libusb_options_default.d '-frandom-seed=bazel-out/k8-opt/bin/driver/usb/_objs/libusb_options/libusb_options_default.o' -DDARWINN_PORT_DEFAULT -iquote . -iquote bazel-out/k8-opt/bin -iquote external/com_google_absl -iquote bazel-out/k8-opt/bin/external/com_google_absl -iquote external/libusb -iquote bazel-out/k8-opt/bin/external/libusb -no-canonical-prefixes -fno-canonical-system-headers -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -c driver/usb/libusb_options_default.cc -o bazel-out/k8-opt/bin/driver/usb/_objs/libusb_options/libusb_options_default.o)
Execution platform: @local_execution_config_platform//:platform

Use --sandbox_debug to see verbose messages from the sandbox gcc failed: error executing command
  (cd /home/gsosnow/.cache/bazel/_bazel_gsosnow/16a635ae350cf6bf2b0cceb1c00e2e1c/sandbox/linux-sandbox/247/execroot/libedgetpu && \
  exec env - \
    PATH=/home/gsosnow/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin \
    PWD=/proc/self/cwd \
  /usr/bin/gcc -fPIC -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -msse4.2 -g0 -O3 -DNDEBUG '-D_FORTIFY_SOURCE=2' -ffunction-sections -fdata-sections '-std=c++14' -MD -MF bazel-out/k8-opt/bin/driver/usb/_objs/libusb_options/libusb_options_default.d '-frandom-seed=bazel-out/k8-opt/bin/driver/usb/_objs/libusb_options/libusb_options_default.o' -DDARWINN_PORT_DEFAULT -iquote . -iquote bazel-out/k8-opt/bin -iquote external/com_google_absl -iquote bazel-out/k8-opt/bin/external/com_google_absl -iquote external/libusb -iquote bazel-out/k8-opt/bin/external/libusb -no-canonical-prefixes -fno-canonical-system-headers -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -c driver/usb/libusb_options_default.cc -o bazel-out/k8-opt/bin/driver/usb/_objs/libusb_options/libusb_options_default.o)
Execution platform: @local_execution_config_platform//:platform

Use --sandbox_debug to see verbose messages from the sandbox
In file included from driver/usb/libusb_options_default.cc:15:
./driver/usb/libusb_options.h:22:10: fatal error: libusb-1.0/libusb.h: No such file or directory
   22 | #include <libusb-1.0/libusb.h>
      |          ^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Target //tflite/public:libedgetpu_direct_all.so.stripped failed to build
INFO: Elapsed time: 2.268s, Critical Path: 1.87s
INFO: 111 processes: 68 internal, 43 linux-sandbox.
FAILED: Build did NOT complete successfully
make: *** [Makefile:97: libedgetpu-direct] Error 1

@gsirocco
Copy link
Author

gsirocco commented Jan 7, 2023

Maybe this? Yes, this worked!!
sudo apt-get install libusb-1.0-0-dev

@gsirocco
Copy link
Author

I am able to build now with tensorflowlite_c lib and using C for TFLite and edge tpu. Thanks!!

@google-coral-bot
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:model Model related isssues Hardware:M.2 Accelerator B+M Coral M.2 Accelerator B+M key issues subtype:ubuntu/linux Ubuntu/Linux Build/installation issues type:build/install Build and install issues
Projects
None yet
Development

No branches or pull requests

2 participants