Télécharger Anaconda
- Ouvrez l'adresse de téléchargement d'Anaconda , puis téléchargez la dernière version d'Anaconda.
- Ouvrez le terminal, entrez le fichier où se trouve le package de téléchargement Anaconda et exécutez
bash Anaconda3-2020.02-Linux-x86_64.sh
-le jusqu'au bouty
. - Une fois l'installation terminée, exécutez pour
conda --version
vérifier si l'installation a réussi.
Build Tensorflow
- Entrez dans le terminal
conda create -n tensorflow python=3.7
, complètementy
.
- Entrez dans le terminal
conda activate tensorflow
pour activer l'environnement Tensorflow etconda deactivate
quittez l'environnement Tensorflow. - Entrez des personnes dans le terminal
pip install --ignore-installed --upgrade tensorflow
pour installer / mettre à niveau.
À ce stade, l'environnement Tensorflow a été configuré.
Pour tester
Entrez le touch test.py
fichier de création dans le terminal et modifiez le contenu du fichier pour
import tensorflow as tf
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
if __name__=='__main__':
g = tf.Graph()
# add ops to the user created graph
with g.as_default():
hello = tf.constant('Hello Tensorflow')
sess = tf.compat.v1.Session()
print(sess.run(hello))
Entrez dans le terminal python test.py
, le résultat est le suivant
Intégrer l'environnement Tensorflow dans Pycharm
- fichier -> nouveau projet
- Sélectionnez Interpréteur existant-> Environnement Conda-> Ok-> Créer.
Pour tester
Créez test.py et entrez le code suivant:
import tensorflow as tf
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
if __name__=='__main__':
g = tf.Graph()
# add ops to the user created graph
with g.as_default():
hello = tf.constant('Hello Tensorflow')
sess = tf.compat.v1.Session()
print(sess.run(hello))
Les résultats de l'opération sont les suivants:
généralement, certaines invites apparaissent
2020-04-20 17:43:50.307721: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'libnvinfer.so.6'; dlerror: libnvinfer.so.6: cannot open shared object file: No such file or directory
2020-04-20 17:43:50.307796: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'libnvinfer_plugin.so.6'; dlerror: libnvinfer_plugin.so.6: cannot open shared object file: No such file or directory
2020-04-20 17:43:50.307805: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:30] Cannot dlopen some TensorRT libraries. If you would like to use Nvidia GPU with TensorRT, please make sure the missing libraries mentioned above are installed properly.
Ces informations indiquent que le système actuel n'a pas de contenu lié à TensorRT. Si la prise en charge du GPU n'est pas requise, ignorez-la simplement.