ubuntu19.1 tensorflow

查看版本号

:~$ python -V
Python 3.7.5


:~$ pip3 -V
pip 18.1 from /usr/lib/python3/dist-packages/pip (python 3.7)


:~$ pip -V
pip 18.1 from /usr/lib/python3/dist-packages/pip (python 3.7)


:~$ cat /etc/issue
Ubuntu 19.10 \n \l

:~$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=19.10
DISTRIB_CODENAME=eoan
DISTRIB_DESCRIPTION="Ubuntu 19.10"

查看内核
:~$ uname -a
Linux ubaba-HN-WX9X 5.3.0-46-generic #38-Ubuntu SMP Fri Mar 27 17:37:05 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

安装tensorflow

:~$ pip install -i https://pypi.tuna.tsinghua.edu.cn/simple tensorflow


Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting tensorflow
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/f4/28/96efba1a516cdacc2e2d6d081f699c001d414cc8ca3250e6d59ae657eb2b/tensorflow-1.14.0-cp37-cp37m-manylinux1_x86_64.whl (109.3MB)
100% |████████████████████████████████| 109.3MB 16kB/s
Requirement already satisfied: wheel>=0.26 in /usr/lib/python3/dist-packages (from tensorflow) (0.32.3)
Requirement already satisfied: six>=1.10.0 in /usr/lib/python3/dist-packages (from tensorflow) (1.12.0)
Collecting gast>=0.2.0 (from tensorflow)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/b6/48/583c032b79ae5b3daa02225a675aeb673e58d2cb698e78510feceb11958c/gast-0.4.0-py3-none-any.whl
Collecting keras-applications>=1.0.6 (from tensorflow)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/71/e3/19762fdfc62877ae9102edf6342d71b28fbfd9dea3d2f96a882ce099b03f/Keras_Applications-1.0.8-py3-none-any.whl (50kB)
100% |████████████████████████████████| 51kB 5.2MB/s
Collecting tensorboard<1.15.0,>=1.14.0 (from tensorflow)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/91/2d/2ed263449a078cd9c8a9ba50ebd50123adf1f8cfbea1492f9084169b89d9/tensorboard-1.14.0-py3-none-any.whl (3.1MB)
100% |████████████████████████████████| 3.2MB 621kB/s
Collecting keras-preprocessing>=1.0.5 (from tensorflow)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/79/4c/7c3275a01e12ef9368a892926ab932b33bb13d55794881e3573482b378a7/Keras_Preprocessing-1.1.2-py2.py3-none-any.whl (42kB)
100% |████████████████████████████████| 51kB 17kB/s
Collecting google-pasta>=0.1.6 (from tensorflow)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/a3/de/c648ef6835192e6e2cc03f40b19eeda4382c49b5bafb43d88b931c4c74ac/google_pasta-0.2.0-py3-none-any.whl (57kB)
100% |████████████████████████████████| 61kB 6.8MB/s
Collecting absl-py>=0.7.0 (from tensorflow)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/bc/58/0aa6fb779dc69cfc811df3398fcbeaeefbf18561b6e36b185df0782781cc/absl_py-0.11.0-py3-none-any.whl (127kB)
100% |████████████████████████████████| 133kB 5.8MB/s
Collecting tensorflow-estimator<1.15.0rc0,>=1.14.0rc0 (from tensorflow)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/3c/d5/21860a5b11caf0678fbc8319341b0ae21a07156911132e0e71bffed0510d/tensorflow_estimator-1.14.0-py2.py3-none-any.whl (488kB)
100% |████████████████████████████████| 491kB 802kB/s
Collecting wrapt>=1.11.1 (from tensorflow)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/82/f7/e43cefbe88c5fd371f4cf0cf5eb3feccd07515af9fd6cf7dbf1d1793a797/wrapt-1.12.1.tar.gz
Collecting termcolor>=1.1.0 (from tensorflow)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/8a/48/a76be51647d0eb9f10e2a4511bf3ffb8cc1e6b14e9e4fab46173aa79f981/termcolor-1.1.0.tar.gz
Collecting astor>=0.6.0 (from tensorflow)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/c3/88/97eef84f48fa04fbd6750e62dcceafba6c63c81b7ac1420856c8dcc0a3f9/astor-0.8.1-py2.py3-none-any.whl
Requirement already satisfied: numpy<2.0,>=1.14.5 in ./.local/lib/python3.7/site-packages (from tensorflow) (1.18.1)
Requirement already satisfied: protobuf>=3.6.1 in /usr/lib/python3/dist-packages (from tensorflow) (3.6.1)
Collecting grpcio>=1.8.6 (from tensorflow)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/35/98/74a430566fdd9d4cc0386322e55306c8928a95da95b1da6fba08641526b5/grpcio-1.34.0.tar.gz (21.0MB)
100% |████████████████████████████████| 21.0MB 87kB/s
Collecting h5py (from keras-applications>=1.0.6->tensorflow)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/9d/74/9eae2bedd8201ab464308f42c601a12d79727a1c87f0c867fdefb212c6cf/h5py-3.1.0-cp37-cp37m-manylinux1_x86_64.whl (4.0MB)
100% |████████████████████████████████| 4.0MB 54kB/s
Requirement already satisfied: setuptools>=41.0.0 in /usr/lib/python3/dist-packages (from tensorboard<1.15.0,>=1.14.0->tensorflow) (41.1.0)
Collecting werkzeug>=0.11.15 (from tensorboard<1.15.0,>=1.14.0->tensorflow)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/cc/94/5f7079a0e00bd6863ef8f1da638721e9da21e5bacee597595b318f71d62e/Werkzeug-1.0.1-py2.py3-none-any.whl (298kB)
100% |████████████████████████████████| 307kB 4.1MB/s
Collecting markdown>=2.6.8 (from tensorboard<1.15.0,>=1.14.0->tensorflow)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/ac/ef/24a91ca96efa0d7802dffb83ccc7a3c677027bea19ec3c9ee80be740408e/Markdown-3.3.3-py3-none-any.whl (96kB)
100% |████████████████████████████████| 102kB 506kB/s
Collecting cached-property; python_version < "3.8" (from h5py->keras-applications>=1.0.6->tensorflow)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/48/19/f2090f7dad41e225c7f2326e4cfe6fff49e57dedb5b53636c9551f86b069/cached_property-1.5.2-py2.py3-none-any.whl
Requirement already satisfied: importlib-metadata; python_version < "3.8" in ./.local/lib/python3.7/site-packages (from markdown>=2.6.8->tensorboard<1.15.0,>=1.14.0->tensorflow) (1.5.0)
Requirement already satisfied: zipp>=0.5 in ./.local/lib/python3.7/site-packages (from importlib-metadata; python_version < "3.8"->markdown>=2.6.8->tensorboard<1.15.0,>=1.14.0->tensorflow) (2.1.0)
Building wheels for collected packages: wrapt, termcolor, grpcio
Running setup.py bdist_wheel for wrapt ... done
Stored in directory: /home/ubaba/.cache/pip/wheels/68/e3/d7/4b6eee6f5d547bdfd97ba406128db66c5654dfb831fda163a2
Running setup.py bdist_wheel for termcolor ... done
Stored in directory: /home/ubaba/.cache/pip/wheels/e3/d8/fc/50ab6e66e3dead21d5afff006dc5298913a3064be2b1105359
Running setup.py bdist_wheel for grpcio ... done
Stored in directory: /home/ubaba/.cache/pip/wheels/a9/7d/55/11aa45161f416c2998f26fe0e6a2ce72929901d60aa525ba7b
Successfully built wrapt termcolor grpcio
Installing collected packages: gast, cached-property, h5py, keras-applications, grpcio, absl-py, werkzeug, markdown, tensorboard, keras-preprocessing, google-pasta, tensorflow-estimator, wrapt, termcolor, astor, tensorflow
Successfully installed absl-py-0.11.0 astor-0.8.1 cached-property-1.5.2 gast-0.4.0 google-pasta-0.2.0 grpcio-1.34.0 h5py-3.1.0 keras-applications-1.0.8 keras-preprocessing-1.1.2 markdown-3.3.3 tensorboard-1.14.0 tensorflow-1.14.0 tensorflow-estimator-1.14.0 termcolor-1.1.0 werkzeug-1.0.1 wrapt-1.12.1

测试文件test.py

import tensorflow as tf
a = tf.constant([1.0, 2.0, 3.0], shape=[3], name='a')
b = tf.constant([1.0, 2.0, 3.0], shape=[3], name='b')
c = a + b
sess = tf.compat.v1.Session(config=tf.compat.v1.ConfigProto(log_device_placement=True))
print(sess.run(c))

 

运行测试文件

:~$ cd PycharmProjects/

:~/PycharmProjects$ python test.py

add: (Add): /job:localhost/replica:0/task:0/device:CPU:0
2020-12-10 21:22:30.318901: I tensorflow/core/common_runtime/placer.cc:54] add: (Add)/job:localhost/replica:0/task:0/device:CPU:0
a: (Const): /job:localhost/replica:0/task:0/device:CPU:0
2020-12-10 21:22:30.318947: I tensorflow/core/common_runtime/placer.cc:54] a: (Const)/job:localhost/replica:0/task:0/device:CPU:0
b: (Const): /job:localhost/replica:0/task:0/device:CPU:0
2020-12-10 21:22:30.318973: I tensorflow/core/common_runtime/placer.cc:54] b: (Const)/job:localhost/replica:0/task:0/device:CPU:0
2020-12-10 21:22:30.320024: W tensorflow/compiler/jit/mark_for_compilation_pass.cc:1412] (One-time warning): Not using XLA:CPU for cluster because envvar TF_XLA_FLAGS=--tf_xla_cpu_global_jit was not set. If you want XLA:CPU, either set that envvar, or use experimental_jit_scope to enable XLA:CPU. To confirm that XLA is active, pass --vmodule=xla_compilation_cache=1 (as a proper command-line flag, not via TF_XLA_FLAGS) or set the envvar XLA_FLAGS=--xla_hlo_profile.
[2. 4. 6.]

 
上一篇:[Linux] 【1.安装并开启SSH】Ubuntu20.4.1 从头安装docker环境


下一篇:conda切换为国内下载源