linux_compiler_tensorflow_avec_bazel
Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
linux_compiler_tensorflow_avec_bazel [2021/12/10 08:12] – [Compilation: Création du package pip] serge | linux_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 alert 60%> | + | <WRAP center round box 60% centeralign> |
- | **Aucun tuto correct sur tous les internets, la doc de Google est maximaliste mais mal structurée, | + | **L' |
- | **Si j'y arrive ce tuto va valoir de l'or !** | + | Voir **[[movenet|]]** |
</ | </ | ||
- | Les téléchargements sont très gros: ce sont **des paquets** | + | =====La version Intel de Tensorflow===== |
+ | **[[https:// | ||
+ | <code bash> | ||
+ | python3 -m pip install intel-tensorflow | ||
+ | </ | ||
+ | |||
+ | Donne toujours le message AVX2 et FMA. Mais c'est normal.\\ | ||
+ | Bienvenue dans le monde de Tensoflow: c'est un Warning, mais ce n'est pas forcément vrai !\\ | ||
+ | Mon FPS a augmenté de 10 à 20 % :-P | ||
+ | |||
+ | **Il est inutile de compiler** 8-) | ||
=====Ressources===== | =====Ressources===== | ||
* **[[https:// | * **[[https:// | ||
- | * **[[https:// | + | * **[[https:// |
- | ===Contexte=== | + | Sur les internets, ça en cause: |
- | * Ubuntu Mate 20.04 | + | * https:// |
- | * python 3.8 | + | * https:// |
- | * venv | + | * https:// |
+ | * https:// | ||
+ | * https:// | ||
- | **L' | + | =====Installation de Bazel===== |
- | + | Bazel est le compilateur de Google. | |
- | ====Cuda==== | + | |
- | * [[https:// | + | |
- | * **[[installation_de_cuda|Installation de CUDA et Compilation de OpenCV avec CUDA]]** | + | |
- | + | ||
- | + | ||
- | ====CudNN==== | + | |
- | * **[[https:// | + | |
- | + | ||
- | sudo apt install libcudnn8 libcudnn8-dev | + | |
- | + | ||
- | ====TensorRT==== | + | |
- | * **[[https:// | + | |
- | + | ||
- | sudo apt install libnvinfer8 libnvinfer8-dev | + | |
- | + | ||
- | ====Bazel et Tensorflow==== | + | |
<code bash> | <code bash> | ||
# Bazel | # Bazel | ||
- | |||
sudo apt install apt-transport-https curl gnupg | sudo apt install apt-transport-https curl gnupg | ||
curl -fsSL https:// | curl -fsSL https:// | ||
Ligne 42: | Ligne 37: | ||
echo "deb [arch=amd64] https:// | echo "deb [arch=amd64] https:// | ||
sudo apt update | sudo apt update | ||
+ | sudo apt install bazel-4.2.1 | ||
+ | </ | ||
- | sudo apt install bazel | + | =====Sans GPU sur Debian===== |
- | + | Désinstaller les packages python tensorflow si ils sont installés. | |
- | # Dépendances | + | <code bash> |
- | python3 -m pip install numpy wheel | + | pip3 list |
+ | # Dans la list, chercher ce qu'il faut désinstaller ... | ||
+ | python3 -m pip uninstall tensorflow intel-tensorflow | ||
+ | ... | ||
+ | </ | ||
+ | Installation du nécessaire: | ||
+ | <code bash> | ||
+ | python3 -m pip install numpy wheel protobuf | ||
python3 -m pip install keras_preprocessing --no-deps | python3 -m pip install keras_preprocessing --no-deps | ||
+ | </ | ||
- | # Récupération des sources de tensorflow | + | Récupération des sources de tensorflow: |
- | mkdir src | + | <code bash> |
- | cd src/ | + | cd / |
- | git clone https:// | + | git clone https:// |
- | cd tensorflow | + | |
./configure | ./configure | ||
</ | </ | ||
- | **Très important** Des questions et des réponses: | + | Cela génère un fichier .tf_configure.bazelrc dans le dossier tensorflow |
- | * **non à ROCm** | + | Répondre entrée ou N partout, nous allons corriger le fichier |
- | * **non** | + | <code bash> |
- | * **non à download a fresh release of clang** ça plante | + | build --action_env PYTHON_BIN_PATH="/ |
- | * oui à GCC | + | build --action_env PYTHON_LIB_PATH="/ |
+ | build --python_path="/ | ||
+ | build:opt --copt=-march=native | ||
+ | build:opt --host_copt=-march=native | ||
+ | test --flaky_test_attempts=3 | ||
+ | test --test_size_filters=small, | ||
+ | test:v1 --test_tag_filters=-benchmark-test, | ||
+ | test:v1 --build_tag_filters=-benchmark-test, | ||
+ | test:v2 --test_tag_filters=-benchmark-test, | ||
+ | test:v2 --build_tag_filters=-benchmark-test, | ||
+ | </ | ||
- | ===Le plus abcons: la config=== | ||
- | <WRAP center round important 60%> | ||
- | ** Comment définir la configuration avec AVX2 et FMA** | ||
- | </ | ||
+ | ====Compilation de tensorflow==== | ||
+ | <code bash> | ||
+ | sudo ln -s / | ||
+ | bazel build -j 4 --copt=-mavx2 --copt=-mfma | ||
+ | ./ | ||
+ | </ | ||
+ | ===Consommation mémoire=== | ||
+ | Sur un i5 à 8 threads et 8 Go de Ram: -j 2 pour limiter la consommation de mémoire, sinon Swap de 8 Go insuffisante. | ||
+ | |||
+ | ===Stop et reprise=== | ||
+ | Bazel reprend là où il s'est arrêté. | ||
+ | |||
+ | ===Success=== | ||
+ | <code bash> | ||
+ | INFO: Elapsed time: 19106.040s, Critical Path: 196.86s | ||
+ | soit 5.3 heures, perso je trouve 7 heures! | ||
+ | INFO: 11460 processes: 1325 internal, 10135 local. | ||
+ | INFO: Build completed successfully, | ||
+ | </ | ||
+ | |||
+ | ====Nettoyage pour recommencer==== | ||
+ | <code bash> | ||
+ | bazel clean | ||
+ | </ | ||
+ | |||
+ | ====Installation==== | ||
+ | <code bash> | ||
+ | cd / | ||
+ | source mon_env/ | ||
+ | python3 -m pip uninstall tensorflow | ||
+ | python3 -m pip install / | ||
+ | </ | ||
- | ====Compilation: | + | ====Utilisation==== |
- | Parce que en plus bazel exige **la** bonne version: | + | Le message d'info AVX2 et FMA est toujours là ! |
- | sudo apt update && sudo apt install bazel-4.2.1 | + | |
- | bazel build --config=cuda [--config=option] // | + | |
{{tag>ia linux python sb tensorflow}} | {{tag>ia linux python sb tensorflow}} |
linux_compiler_tensorflow_avec_bazel.1639123973.txt.gz · Dernière modification : 2021/12/10 08:12 de serge