Outils pour utilisateurs

Outils du site


linux_compiler_tensorflow_avec_bazel

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
linux_compiler_tensorflow_avec_bazel [2021/12/16 12:42] – [Compilation de tensorflow] sergelinux_compiler_tensorflow_avec_bazel [2021/12/20 11:13] (Version actuelle) – [La version Intel de Tensorflow] serge
Ligne 1: Ligne 1:
 ====== Linux Compiler Tensorflow avec Bazel ====== ====== Linux Compiler Tensorflow avec Bazel ======
-<WRAP center round box 60%> +<WRAP center round box 60% centeralign
-**L'objectif est de compiler Tensorflow avec les options AVX2 et FMA !**\\+**L'objectif est de compiler Tensorflow avec les options AVX2 et FMA et sans GPU**\\
 Voir **[[movenet|]]** Voir **[[movenet|]]**
 </WRAP> </WRAP>
  
-=====Intel=====+=====La version Intel de Tensorflow=====
  
 **[[https://pypi.org/project/intel-tensorflow/|intel-tensorflow]]** **[[https://pypi.org/project/intel-tensorflow/|intel-tensorflow]]**
Ligne 12: Ligne 12:
 </code> </code>
  
-Donne toujours le message AVX2 et FMA, et ça ne va pas plus vite !+Donne toujours le message AVX2 et FMA. Mais c'est normal.\\ 
 +Bienvenue dans le monde de Tensoflow: c'est un Warningmais ce n'est pas forcément vrai !\\ 
 +Mon FPS a augmenté de 10 à 20 % :-P
  
-https://github.com/tensorflow/tensorflow/issues/7660+**Il est inutile de compiler** 8-)
 =====Ressources===== =====Ressources=====
   * **[[https://www.tensorflow.org/install/source|Compiler à partir de la source]]**   * **[[https://www.tensorflow.org/install/source|Compiler à partir de la source]]**
-  * **[[https://docs.bazel.build/versions/main/install-ubuntu.html|Installing Bazel on Ubuntu]]** +  * **[[https://www.intel.com/content/www/us/en/developer/articles/guide/optimization-for-tensorflow-installation-guide.html|Build TensorFlow from Source with Intel oneAPI oneDNN library]]** 
-  * **[[https://technofob.com/2019/06/14/how-to-compile-tensorflow-2-0-with-avx2-fma-instructions-on-mac/|How to fix Your CPU supports instructions that this TensorFlow binary was not compiled to useAVX2 FMA]] ** on-mac+ 
 +Sur les internets, ça en cause: 
 +  * https://docs.bazel.build/versions/main/install-ubuntu.html 
 +  * https://technofob.com/2019/06/14/how-to-compile-tensorflow-2-0-with-avx2-fma-instructions-on-mac 
 +  * https://github.com/tensorflow/tensorflow/issues/7660 
 +  * https://ai-pool.com/d/proper-way-to-compile-tensorflow-with-sse4-2-and-avx 
 +  https://github.com/GTGraphics3/tensorflow-1.4.2-AVX-MKL
  
 =====Installation de Bazel===== =====Installation de Bazel=====
Ligne 33: Ligne 41:
  
 =====Sans GPU sur Debian===== =====Sans GPU sur Debian=====
-Désinstaller les packages python protobuf et tensorflow si ils sont installés. +Désinstaller les packages python tensorflow si ils sont installés. 
 +<code bash> 
 +pip3 list 
 +# Dans la list, chercher ce qu'il faut désinstaller ... 
 +python3 -m pip uninstall tensorflow intel-tensorflow 
 +... 
 +</code>
 Installation du nécessaire: Installation du nécessaire:
-  python3 -m pip install numpy wheel +<code bash> 
-  python3 -m pip install keras_preprocessing --no-deps +python3 -m pip install numpy wheel protobuf 
-  +python3 -m pip install keras_preprocessing --no-deps 
 +</code> 
 Récupération des sources de tensorflow: Récupération des sources de tensorflow:
-  cd /votre/dossier/src +<code bash> 
-  git clone https://github.com/tensorflow/tensorflow  +cd /votre/dossier/src 
-  ./configure +git clone https://github.com/tensorflow/tensorflow  
- +./configure
-====Mes réponses==== +
-<code> +
-Make sure you are running at least bazel 4.2.1 +
-Please specify the location of python. [Default is /usr/bin/python3]:  +
-Found possible Python library paths: +
-  /usr/lib/python3/dist-packages +
-  /usr/local/lib/python3.9/dist-packages +
-Please input the desired Python library path to use.  Default is [/usr/lib/python3/dist-packages] +
-Do you wish to build TensorFlow with ROCm support? [y/N]: n +
-No ROCm support will be enabled for TensorFlow. +
-Do you wish to build TensorFlow with CUDA support? [y/N]: n +
-No CUDA support will be enabled for TensorFlow. +
-Do you wish to download a fresh release of clang? (Experimental) [y/N]: n +
-Clang will not be downloaded. +
-Please specify optimization flags to use during compilation when bazel option "--config=opt" is specified [Default is -Wno-sign-compare]: -march=native +
-Would you like to interactively configure ./WORKSPACE for Android builds? [y/N]: n +
-Not configuring the WORKSPACE for Android builds.+
 </code> </code>
  
-====Avant de recommencer==== +Cela génère un fichier .tf_configure.bazelrc dans le dossier tensorflow (c'est un fichier cachéCtrl+h).\\ 
-  bazel clean +Répondre entrée ou N partoutnous allons corriger le fichier à la main:
-   +
-====Compilation de tensorflow==== +
-  sudo ln -s /usr/bin/python3 /usr/bin/python +
-  bazel build -j 4 //tensorflow/tools/pip_package:build_pip_package +
-  ./bazel-bin/tensorflow/tools/pip_package/build_pip_package /media/data/tensorflow_pkg +
- +
-INFOElapsed time: 11341.078s, Critical Path: 1101.95s\\ +
-INFO: 11460 processes: 1325 internal10135 local.\\ +
-INFOBuild completed successfully, 11460 total actions\\ +
-soit 3.1 heures ! +
- +
-=====Test spécial=====+
 <code bash> <code bash>
 build --action_env PYTHON_BIN_PATH="/usr/bin/python3" build --action_env PYTHON_BIN_PATH="/usr/bin/python3"
Ligne 91: Ligne 77:
 </code> </code>
  
-  bazel build -j 4  --copt=-mavx2 --copt=-mfma  //tensorflow/tools/pip_package:build_pip_package 
  
 +
 +====Compilation de tensorflow====
 +<code bash>
 +sudo ln -s /usr/bin/python3 /usr/bin/python
 +bazel build -j 4  --copt=-mavx2 --copt=-mfma  //tensorflow/tools/pip_package:build_pip_package
 +./bazel-bin/tensorflow/tools/pip_package/build_pip_package /media/data/tensorflow_pkg
 +</code>
  
 ===Consommation mémoire=== ===Consommation mémoire===
-Sur un i5 à 8 threads et 8 Go de Ram: -j pour limiter la consommation de mémoire+Sur un i5 à 8 threads et 8 Go de Ram: -j pour limiter la consommation de mémoire, sinon Swap de 8 Go insuffisante.
  
-====Conseils Geek==== +===Stop et reprise=== 
-Au lieu de répondre aux questions de ./configure, éditer le fichier **.tf_configure.bazelrc** du dossier tensorflow (fichier caché, faire Ctrl+h).+Bazel reprend là où il s'est arrêté Pour nettoyer avant de reprendre: bazel clean 
 + 
 +===Success===
 <code bash> <code bash>
-build --action_env PYTHON_BIN_PATH="/usr/bin/python3" +INFOElapsed time19106.040s, Critical Path196.86s 
-build --action_env PYTHON_LIB_PATH="/usr/lib/python3/dist-packages" +soit 5.heuresperso je trouve 7 heures! 
-build --python_path="/usr/bin/python3" +INFO11460 processes1325 internal10135 local. 
-build:opt --copt=-march=native +INFOBuild completed successfully11460 total actions
-build:opt --copt=-Wno-sign-compare +
-build:opt --copt=-mavx +
-build:opt --copt=-mavx2 +
-build:opt --copt=-mfma +
-build:opt --host_copt=-march=native +
-build:opt --define with_default_optimizations=true +
-test --flaky_test_attempts=3 +
-test --test_size_filters=small,medium +
-test:v1 --test_tag_filters=-benchmark-test,-no_oss,-gpu,-oss_serial +
-test:v1 --build_tag_filters=-benchmark-test,-no_oss,-gpu +
-test:v2 --test_tag_filters=-benchmark-test,-no_oss,-gpu,-oss_serial,-v1only +
-test:v2 --build_tag_filters=-benchmark-test,-no_oss,-gpu,-v1only+
 </code> </code>
  
 +====Nettoyage pour recommencer====
 +<code bash>
 +bazel clean
 +</code>
  
 ====Installation==== ====Installation====
-  cd /media/data/3D/projets/grande_echelle_move 
-  source mon_env/bin/activate 
-  python3 -m pip uninstall tensorflow 
-  python3 -m pip install /media/data/src/tensorflow-2.8.0-cp38-cp38-linux_x86_64.whl 
-   
-=====Avec GPU===== 
-Ubuntu Mate 20.04, python 3.8, venv 
- 
-===Cuda=== 
-  * **[[compilation_de_oepncv_avec_cuda_sur_ubuntu|Installation de CUDA et Compilation de OpenCV avec CUDA]]** 
-===CudNN=== 
-  sudo apt install libcudnn8 libcudnn8-dev 
-===TensorRT=== 
-  sudo apt install libnvinfer8 libnvinfer8-dev 
-   
-====Tensorflow==== 
 <code bash> <code bash>
-# Dépendances +cd /media/data/3D/projets/grande_echelle_move 
-python3 -m pip install numpy wheel +source mon_env/bin/activate 
-python3 -m pip install keras_preprocessing --no-deps +python3 -m pip uninstall tensorflow 
- +python3 -m pip install /media/data/src/tensorflow-2.8.0-cp38-cp38-linux_x86_64.whl
-# Récupération des sources de tensorflow +
-mkdir src +
-cd src/ +
-git clone https://github.com/tensorflow/tensorflow.git +
-cd tensorflow +
-./configure+
 </code> </code>
  
- +====Utilisation==== 
- +Le message d'info AVX2 et FMA est toujours là !
  
 {{tag>ia linux python sb tensorflow}} {{tag>ia linux python sb tensorflow}}
linux_compiler_tensorflow_avec_bazel.1639658570.txt.gz · Dernière modification : 2021/12/16 12:42 de serge