I am trying to install Tensorflow Lite on Raspberry Pi Zero W. I followed the steps from the official website (https://www.tensorflow.org/lite/guide/build_cmake_arm). But I get the following error message:
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
-- Check for working C compiler: /home/pi/toolchains/arm-rpi-linux-gnueabihf/x64-gcc-6.5.0/arm-rpi-linux-gnueabihf/bin/arm-rpi-linux-gnueabihf-gcc
-- Check for working C compiler: /home/pi/toolchains/arm-rpi-linux-gnueabihf/x64-gcc-6.5.0/arm-rpi-linux-gnueabihf/bin/arm-rpi-linux-gnueabihf-gcc -- broken
CMake Error at /usr/share/cmake-3.16/Modules/CMakeTestCCompiler.cmake:60 (message):
The C compiler
"/home/pi/toolchains/arm-rpi-linux-gnueabihf/x64-gcc-6.5.0/arm-rpi-linux-gnueabihf/bin/arm-rpi-linux-gnueabihf-gcc"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /home/pi/Project/cmake-3.16.0/CMakeFiles/CMakeTmp
Run Build Command(s):/usr/bin/make cmTC_ed1a3/fast && /usr/bin/make -f CMakeFiles/cmTC_ed1a3.dir/build.make CMakeFiles/cmTC_ed1a3.dir/build
make[1]: Entering directory '/home/pi/Project/cmake-3.16.0/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_ed1a3.dir/testCCompiler.c.o
/home/pi/toolchains/arm-rpi-linux-gnueabihf/x64-gcc-6.5.0/arm-rpi-linux-gnueabihf/bin/arm-rpi-linux-gnueabihf-gcc -march=armv6 -mfpu=vfp -funsafe-math-optimizations -o CMakeFiles/cmTC_ed1a3.dir/testCCompiler.c.o -c /home/pi/Project/cmake-3.16.0/CMakeFiles/CMakeTmp/testCCompiler.c
/home/pi/toolchains/arm-rpi-linux-gnueabihf/x64-gcc-6.5.0/arm-rpi-linux-gnueabihf/bin/arm-rpi-linux-gnueabihf-gcc: 1: /home/pi/toolchains/arm-rpi-linux-gnueabihf/x64-gcc-6.5.0/arm-rpi-linux-gnueabihf/bin/arm-rpi-linux-gnueabihf-gcc: Syntax error: ")" unexpected
make[1]: *** [CMakeFiles/cmTC_ed1a3.dir/build.make:66: CMakeFiles/cmTC_ed1a3.dir/testCCompiler.c.o] Error 2
make[1]: Leaving directory '/home/pi/Project/cmake-3.16.0/CMakeFiles/CMakeTmp'
make: *** [Makefile:121: cmTC_ed1a3/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:44 (project)
Configuring incomplete, errors occurred!
See also "/home/pi/Project/cmake-3.16.0/CMakeFiles/CMakeOutput.log".
See also "/home/pi/Project/cmake-3.16.0/CMakeFiles/CMakeError.log".
Does anyone know how to fix the problem?
I ran into the same problem like you!
The instructions given at https://www.tensorflow.org/lite/guide/build_cmake_arm?hl=en are not intended to be executed on the Raspberry Pi (at least the last ones).
Let me share, what I'll figured out.
Short answer:
you're trying to run a cross-compile of TensorFlow Lite for an ARM made for x86 platform on an ARM system (your Raspberry Pi). What you're trying to do actually needs to be done on an x86 platform.
(on the top of the tutorial page is a hint: "following instructions have been tested on Ubuntu 16.04.3 64-bit PC (AMD64)" which reveals that the commands have been run on x86)
Some details:
The message ‘Syntax error: "(" unexpected’ probably comes from a shell. Why is a shell trying to execute your binary? Because the kernel tried and gave up. Why did the kernel fail to run the program? Because the executable is not in a supported format -> meant to be run on x86 but was executed on ARM.
https://unix.stackexchange.com/questions/336436/syntax-error-unexpected-when-execute-a-compiled-c-program
With older TensorFlow versions it was possible to compile TF lite on the Raspberry Pi itself via the
./tensorflow-2.4.1/tensorflow/lite/tools/make/download_dependencies.sh /and build_aarch64_lib.sh scripts.
However, this scripts got removed in version 2.8 (or even with an earlier version before). See note in the Readme of the Git: https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/tools/make/README.md
Using Python for inference
Unfortunately I have no real solution how to compile / built TensorFlow Lite on the Raspberry itself. I personally ended up using Python (only needed inference) and followed this Tutorial:
https://qengineering.eu/install-tensorflow-2.7-on-raspberry-64-os.html
Related
I'm still a newbie to assembly language and cross-compiling etc. I've already googled the problem I'm having and seen a few similar posts but none of them solved my problem unfortunately.
We're learning ARM32 Syntax at the university and playing around with assembly code on AARCH64 machines on a uni server. So we need to cross-compile the .s files to be able to run them.
We use the command arm-linuxgnueabihf-gcc to cross-compile.
Now the system (the loader I guess) is configured properly to execute these 32-bit cross executables. When I tried to debug a 32b exec however GDB crashes with error: selected architecture armv7 is not compatible with reported target architecture aarch64
There are screenshots below that illustrate the problem. Thanks for any help!
System infos:
System info
No error with native compiler:
No error with native compiler
Error with cross-compilation:
Error with cross-compilation
I am able to compile this for linux and run it on linux, but I would like to be able to run it on my windows machine as well.
https://github.com/bear24rw/rgb_table/tree/master/code/table_drivers/beat_finder
(is this allowed?)
When I try to cross compile it on my linux machine, I get an error saying Termios.h cannot be found. I read somewhere that termios.h and mingw don't work together. So then I spent hours downloading a few compiling tools for windows (on capped internet speeds) to try and make progress on windows since that's where I want to run the application anyway. I'm trying to use Cygwin now and when I try to compile it by making a few changes to the makefile to try and use
x86_64-pc-cygwin-gcc
I get
/usr/lib/gcc/x86_64-pc-cygwin/6.4.0/../../../../x86_64-pc-cygwin/bin/ld:
cannot find -lftdi
collect2: error: ld returned 1 exit status
make: *** [makefile:6: main] Error 1
I have used the package installer for cygwin but I only found ftdi1, but I did find the ftdi.h raw file on github and copied it to my usr/include folder. so I'm not sure what to do from here but I'd really like to get this code running on my windows machine as an .exe I just need to know which direction I should go in, trying to solve the termios.h error on the linux machine, or ftdi.h error on the windows machine.
When I try to cross compile it on my linux machine, I get an error saying Termios.h cannot be found.
That's because <termios.h> describes terminal handling functionality which doesn't exist on Windows. However, I don't see any code in main.c which would actually depend on termios functionality -- you can probably just remove that #include.
As far as -lftdi goes, ftdi1 should be the right library. Make sure you've installed the -dev package from Cygwin.
When I try to add it to sources as per debian install instructions I get this error. I'm guessing this means that there are no arm packages for it.
Failed to fetch https://dist.crystal-lang.org/apt/dists/crystal/InRelease Unable to find expected entry 'main/binary-armhf/Packages' in Release file (Wrong sources.list entry or malformed file)
I'm guessing I probably need to install it from source. How would I go about doing that with an arm cpu? When I check it out and run make I get the error:
You need to have a crystal executable in your path! Makefile:113:
recipe for target '.build/crystal' failed make: *** [.build/crystal]
Error 1
Any suggestions would be greatly appreciated.
EDIT: There's now a semi-official repository for crystal on raspbian, check it out here: http://public.portalier.com/raspbian
Crystal doesn't build Debian packages for ARM, and you're correct in that you'll need to build from source.
However, the Crystal compiler is written in Crystal. This presents the obvious problem of how to get a compiler to build the compiler. The answer is cross-compilation: building an arm binary on a x86 desktop computer and copying it across.
Here's a quick step-by-step based on my memory of last time I cross-compiled:
Install Crystal on a x86 desktop PC, and check it works.
Install all required libraries on the desktop and Raspberry Pi. You'll need the same LLVM version on the Raspberry Pi and desktop. This is probably the hardest and longest step. You can install llvm 3.9 from debian testing for ARM, see this stackoverflow post for how to install only LLVM from debian testing.
Check out the sources from git on both computers, and run make deps.
Cross-compile the compiler by running this command in the root of the git repository:
./bin/crystal build src/compiler/crystal.cr --cross-compile --target arm-unknown-linux-gnueabihf --release -s -D without_openssl -D without_zlib
This command will create a crystal.o file in your current directory, and also output a linker command (cc crystal.o -o crystal ...).
Copy crystal.o to the raspberry pi, and run the linker command. Be sure to edit the absolute path to llvm_ext.o so that it points to the Crystal checkout on your Raspberry Pi, not the checkout on your desktop. Also make sure that all references to llvm-config in the command are for the correct LLVM version. For example, changing /usr/local/bin/llvm-config to llvm-config-3.9 on Raspbian.
Run the crystal executable in your current directory (./crystal -v) and make sure it works.
Ensure to set CRYSTAL_PATH environment variable is set to lib:/path/to/crystal/source/checkout/src so that the compiler can find the standard library when compiling applications.
Not sure if this is the correct place for this kind of question. If not, please point me in the right direction.
I'm using OSX 10.5.8 on a white 13" macbook with Xcode 3.1.4. When installing py27-bottleneck through macports, I get the following error
---> Building py27-bottleneck
running build
running build_py
package init file 'bottleneck/tests/__init__.py' not found (or not a regular file)
package init file 'bottleneck/src/func/__init__.py' not found (or not a regular file)
package init file 'bottleneck/src/move/__init__.py' not found (or not a regular file)
package init file 'bottleneck/tests/__init__.py' not found (or not a regular file)
package init file 'bottleneck/src/func/__init__.py' not found (or not a regular file)
package init file 'bottleneck/src/move/__init__.py' not found (or not a regular file)
running build_ext
building 'func' extension
/usr/bin/gcc-4.2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch i386 -I/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/include -I/opt/local/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c bottleneck/src/func/func.c -o build/temp.macosx-10.5-i386-2.7/bottleneck/src/func/func.o
In file included from /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1760,
from /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:17,
from /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,
from bottleneck/src/func/func.c:314:
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:15:2: warning: #warning "Using deprecated NumPy API, disable it by " "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION"
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/include/numpy/__ufunc_api.h:242: warning: ?_import_umath? defined but not used
cc1(53864) malloc: *** mmap(size=298745856) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
cc1: out of memory allocating 298742336 bytes after a total of 0 bytes
error: command '/usr/bin/gcc-4.2' failed with exit status 1
Command failed: cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_python_py-bottleneck/py27-bottleneck/work/Bottleneck-0.8.0" && /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 setup.py --no-user-cfg build
Exit code: 1
Error: org.macports.build for port py27-bottleneck returned: command execution failed
Warning: targets not executed for py27-bottleneck: org.macports.activate org.macports.build org.macports.destroot org.macports.install
Please see the log file for port py27-bottleneck for details:
/opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_ports_python_py-bottleneck/py27-bottleneck/main.log
Error: Problem while installing py27-bottleneck
I don't really know what the problem is and why this had happened, but what I noticed was that macports is still using an old compiler.
So does anybody know how I can fix this problem?
Also, why is macports still using gcc-4.2, while I have all my symlinks pointing at /opt/local/bin/gcc-mp-4.8. I remember having this problem earlier with installing some other python packages (or maybe it was this one, I don't remember), so I forced macports to use the newer compiler by changing the makefile and it worked temporarily. Until I started upgrading my outdated ports. Obviously now macports encountered linking errors and just reinstalled the all those packages (this is where I am now). So why does macports not just use the newer compiler? Or how can I make him do this? (maybe I shouldn't?)
Any help is appreciated. Thanks.
On 10.5.8 with Xcode 3.1.4 MacPorts uses the following compilers (in-order, unless blacklisted by ports because known to break):
GCC 4.2 from /usr/bin
A MacPorts build of the same compiler (with a few minor bugfixes)
GCC 4.0 from /usr/bin
Clang 3.3 from MacPorts
It seems this port should be blacklisting GCC 4.2 (and probably 2. and 3., too). You could file that as a bug, but to be honest, support for 10.5 is only given on a best-effort basis because most maintainers can't test on this platform anymore, so that's probably not getting you anywhere unless you provide a patch with your report.
You could override the compiler from command line like you did before. To stop rev-upgrade from immediately starting rebuilds, you can set revupgrade_mode report in your macports.conf. I'd have to see the output of port -dy rev-upgrade when it encounters broken ports to know why it produces broken binaries.
It has already been mentioned that the select mechanism doesn't affect which compilers MacPorts chooses for its ports (because depending on what's selected by the user would add another variable that might make builds unreproducible, which is something we're trying to avoid). MacPorts' default compilers can be changed, but doing so is completely unsupported and deliberately undocumented. That being said, if you still want to attempt this, https://apple.stackexchange.com/questions/118550/define-local-keyword-globally-in-a-macports-config/122997#122997 has some info on how to do that.
Ive been trying to setup mpich2 to compile some programs using MPI on windows 7. The problem that I encounter is that it wont create the binary files when I build a project.
I use the stadard mpi program to test (hello world) and I get this message after building it:
13:33:29 ** Rebuild of configuration Debug for project mpitest **
Info: Internal Builder is used for build mpiCC "-IC:\MPICH2\include"
-O0 -g3 -Wall -c -fmessage-length=0 -o "src\mpitest.o" "..\src\mpitest.c"
The Open MPI wrapper compiler was unable to find the specified
compiler cl.exe in your PATH.
Note that this compiler was either specified at configure time or in one of several
possible environment variables.
13:33:29 Build Finished (took 78ms)
I tried to search for cl.exe but it doesn't exist. I have to say that I also installed openMPI but I didn't use it cause the cluster that I am gonna target run the program is using MPICH2. I have already installed 32bit minGW, 32bit MPICH2 and 32bit openMPI.
Is it normal to not create binaries since i run the .c file in the cluster? If its normal how am i going to check if the program is ok even for 1 process?
Thanks in advance! Cheers!
I found the answer by luck... In the project preferences, select C/C++ build-> Tool Chain editor-> choose cygwin and its done. For some reason i had mingw in that option and wouldnt create binaries, i suppose it needs some other tools that can be found only in the cygwin and not mingw... Still trying to set it and run on the cluster... so many options :/