Created
May 14, 2020 19:26
-
-
Save CorradoLanera/c6ab1cb2448394c9abbc93f64ba29d1c to your computer and use it in GitHub Desktop.
[summer 2020] Optimized TF 2.2 r-tensorflow R4.0.0 Ubuntu 18.04
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
R package tensorflow use the conda envirnment "r-tensorflow". hence I have to install my compiled version of tf within that environment | |
1. update system and python | |
``` | |
sudo apt-get update | |
sudo apt-get upgrade | |
``` | |
2. install and update conda, and anaconda | |
``` | |
conda update conda | |
conda update conda-build | |
conda deactivate | |
conda update --all | |
# conda remove --name r-tensorflow --all | |
``` | |
3. install bazel | |
# adapted from https://gist.github.com/Brainiarc7/6d6c3f23ea057775b72c52817759b25c | |
``` | |
# one time setup | |
$ sudo apt-get install software-properties-common swig | |
$ sudo apt install curl | |
$ curl https://bazel.build/bazel-release.pub.gpg | sudo apt-key add - | |
$ echo "deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list | |
$ sudo apt update && sudo apt install bazel | |
# currently I have bezel 3.1 which is ok : | |
# as https://github.com/tensorflow/tensorflow/blob/master/configure.py | |
# states | |
# _TF_MIN_BAZEL_VERSION = '2.0.0' | |
# _TF_MAX_BAZEL_VERSION = '3.99.0' | |
``` | |
4. I need also jdk # https://thishosting.rocks/install-java-ubuntu/ | |
``` | |
java --version # do I need it?? probably not (at least version 8, now it is 11) | |
## for Ubuntu 18.04 it is 11: | |
sudo apt update && apt install sudo apt install openjdk-11-jdk | |
``` | |
5. install/check other needed packages | |
``` | |
sudo apt-get update && sudo apt-get install -y python3-numpy python3-dev python3-pip python3-wheel | |
``` | |
6. enter the environment | |
``` | |
# conda create -n r-tensorflow python=3 # if already created deleate it! | |
conda activate r-tensorflow | |
``` | |
7. install numpy and other dependencies | |
``` | |
conda install six numpy wheel setuptools mock 'future>=0.17.1' | |
pip install -U keras_applications --no-deps | |
pip install -U keras_preprocessing --no-deps | |
``` | |
8. download tensorflow | |
``` | |
git clone https://github.com/tensorflow/tensorflow | |
cd tensorflow/ | |
git checkout r2.2 # r2.2 is actually the latest branch for tf | |
``` | |
9. install it (remember...last time ~11 hours!!) | |
``` | |
sudo apt install bazel-2.0.0 | |
yes "" | ./configure | |
# the following command takes long time | |
bazel build --config=opt tensorflow/tools/pip_package:build_pip_package | |
mkdir build_pkg | |
bazel-bin/tensorflow/tools/pip_package/build_pip_package `pwd`/build_pkg | |
cd build_pkg | |
pip install --upgrade tensorflow-* | |
``` | |
10. check no warnings when it runs! | |
# run a simple TF model | |
11. exit from teh environment | |
``` | |
conda deactivate | |
``` | |
12. enjoy. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment