Download Anaconda
- Open the Anaconda download address , and then download the latest Anaconda.
- Open the terminal, enter the file where the Anaconda download package is located, and run
bash Anaconda3-2020.02-Linux-x86_64.sh
, all the wayy
. - After the installation is complete, run to
conda --version
check whether the installation is successful.
Build Tensorflow
- Enter in the terminal
conda create -n tensorflow python=3.7
, all the wayy
.
- Enter in the terminal
conda activate tensorflow
to activate the Tensorflow environment andconda deactivate
exit the Tensorflow environment. - Enter people in the terminal
pip install --ignore-installed --upgrade tensorflow
to install / upgrade.
At this point, the Tensorflow environment has been set up.
carry out testing
Enter the touch test.py
create file in the terminal and modify the file content to
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))
Enter in the terminal python test.py
, the result is as follows
Integrate Tensorflow environment in Pycharm
- file -> new project
- Select Existing interpreter-> Conda Environment-> Ok-> Create.
carry out testing
Create test.py and enter the following code:
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))
The results of the operation are as follows:
usually some prompts will pop up
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.
This information prompts that the current system does not have TensorRT related content. If GPU support is not required, simply ignore it.