Outils pour utilisateurs

Outils du site


linux_compiler_tensorflow_avec_bazel

Ceci est une ancienne révision du document !


Linux Compiler Tensorflow avec Bazel

Aucun tuto correct sur tous les internets, la doc de Google est maximaliste mais mal structurée, aucun exemple, comment définir des config ? Mystère
Si j'y arrive ce tuto va valoir de l'or !

Les téléchargements sont très gros: ce sont des paquets de 500 Mo !

Ressources

Contexte

  • Ubuntu Mate 20.04
  • python 3.8
  • venv

L'objectif est de compiler Tensorflow avec les options AVX2 et FMA !

Cuda

CudNN

  • cuDNN is a framework built on the top of CUDA and developed by NVIDIA for deep learning primitives. It stands for CUDA Deep Neural Network. It serves as a building block for deep learning and machine learning frameworks.
sudo apt install libcudnn8 libcudnn8-dev

TensorRT

  • NVIDIA® TensorRT™ is an SDK for high-performance deep learning inference. It includes a deep learning inference optimizer and runtime that delivers low latency and high throughput for deep learning inference applications.
sudo apt install libnvinfer8 libnvinfer8-dev

Bazel et Tensorflow

# Bazel
 
sudo apt install apt-transport-https curl gnupg
curl -fsSL https://bazel.build/bazel-release.pub.gpg | gpg --dearmor > bazel.gpg
sudo mv bazel.gpg /etc/apt/trusted.gpg.d/
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
 
# Dépendances
python3 -m pip install numpy wheel
python3 -m pip install keras_preprocessing --no-deps
 
# Récupération des sources de tensorflow
mkdir src
cd src/
git clone https://github.com/tensorflow/tensorflow.git
cd tensorflow
./configure

Le plus abcons: Configurer la compilation

Très important Des questions et des réponses:

  • non à ROCm (non à Rocky)
  • non à clang
  • non à download a fresh release of clang ça plante
  • oui à GCC
  • –config: -march=native
  • Pour 1060 GTX –> 6.1, Pour GTX 850m –> 5.0

Comment compiler avec AVX2 et FMA: répondre -march=native

Reset de la config

bazel clean

Compilation: Création du package pip

Parce que en plus bazel exige la bonne version:

sudo apt update && sudo apt install bazel-4.2.1
bazel build --config=cuda [--config=option] //tensorflow/tools/pip_package:build_pip_package

Le proc i7 tourne à fond depuis 3h

linux_compiler_tensorflow_avec_bazel.1639139744.txt.gz · Dernière modification : 2021/12/10 12:35 de serge