Compile tensorflow CPU on small RAM devices

I just write how to compile tensorflow with GPU support in a older post, but recently I have to apply it on a device that have less power and the pip version of tensorflow does not work out of the box. In particular I am on a teclast x4 with linux but this guide can be used also from a raspberry pi user or fot other similar devices.

This guide is build as a note after testing it in a linux environment (Linux Mint 20.1) but I think that the same can be done also with other operating system.

The problems

The officila tensorflow guide does not work and get errors, but watching the swap during the compilation say me that it is used. Also in a more economic or arm architecture you can not have enought memory to compile it.

The problem is that I do not have enought ram (8GB) to compile it. So I follow the guide but I try to solve this problem by adding some paramiters.

The solution

If you ave also problem with cpus you can also add the paramiter --jobs=5

So you can follow the officila tensorflow guide and when you arrive to the build add these paramiters. In particular if you need only the pip package you can do the following:

bazel build --local_ram_resources=512 --jobs=3 --verbose_failures //tensorflow/tools/pip_package:build_pip_package

Now I have a version of tensorflow compiled on my personal CPU and I can use the tensorflow code.

Intel N4100 problem

….
tensorflow/python/lib/core/bfloat16.cc:608:60: note: no known conversion for argument 2 from ‘<unresolved overloaded function type>’ to ‘PyUFuncGenericFunction {aka void (*)(char**, const long int*, const long int*, void*)}’
Target //tensorflow/tools/pip_package:build_pip_package failed to build
….

like in this issue but the solution seams does not work for me.

So if less ram is enoght you can try the proposed solution or create a swap partition. For the N4100 I wandering for the solution.

Conclusions

For too meny existing trained model tensorflow it usefull, but I prefer to start my new project with pytorch.

If you have some comments about tensorflow and reason to use it again today write in the comment in order to the best of our nowledge.

--

--

Linux user and Open Source fun. Deep learning PhD Student, Full stack web developer, Mobile developer, Musitian.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Nicola Landro

Linux user and Open Source fun. Deep learning PhD Student, Full stack web developer, Mobile developer, Musitian.