RoboForex – Professional services on Forex market
Reference links:
- <https://github.com/tensorflow/tensorflow/issues/7660>
- <https://github.com/tensorflow/tensorflow/issues/349>
When compiling TensorFlow from source on my Amazon AWS Ubuntu server, I kept getting strange build errors. After a lot of searching, I could not find a clear answer.
I installed swig, which TensorFlow may need during the build. I am not sure whether this was the deciding factor, but it is worth checking:
sudo apt install swig
The more likely cause was simply running out of memory during compilation. One workaround is to reduce the number of parallel Bazel build jobs. Passing --local_resources 2048,0.5,1.0 tells Bazel to limit local resource use, and --jobs 1 keeps the build to one job at a time:
bazel build -c opt --jobs 1 --local_resources 2048,0.5,1.0 --verbose_failures --config=cuda //tensorflow/tools/pip_package:build_pip_package
I also added a swap file.
Create a 4 GB swap file. This method is relatively slow:
sudo dd if=/dev/zero of=/swapfile bs=1G count=4
Alternatively, use fallocate:
sudo fallocate -l 4G /swapfile
Then set the correct permissions, initialize it as swap, and enable it:
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
If you want to use this swap file automatically on boot, append this line to /etc/fstab:
/swapfile none swap sw 0 0
Bingo!
