一、TensorFlow介绍
1、简介
TensorFlow是一个基于数据流编程(dataflow programming)的符号数学系统,被广泛应用于各类机器学习(machine learning)算法的编程实现,其前身是谷歌的神经网络算法库DistBelief 。Tensorflow拥有多层级结构,可部署于各类服务器、PC终端和网页并支持GPU和TPU高性能数值计算,被广泛应用于谷歌内部的产品开发和各领域的科学研究 。TensorFlow由谷歌人工智能团队谷歌大脑(Google Brain)开发和维护,拥有包括TensorFlow Hub、TensorFlow Lite、TensorFlow Research Cloud在内的多个项目以及各类应用程序接口(Application Programming Interface, API)。自2015年11月9日起,TensorFlow依据阿帕奇授权协议(Apache 2.0 open source license)开放源代码 。
2、TensorFlow 支持的系统
以下 64 位系统上测试过 TensorFlow 并且这些系统支持 TensorFlow:
- Python 3.5–3.8
- Ubuntu 16.04 或更高版本
- Windows 7 或更高版本(含 C++ 可再发行软件包)
- macOS 10.12.6 (Sierra) 或更高版本(不支持 GPU)
- Raspbian 9.0 或更高版本
二、安装步骤
1、检查确认python版本
root@ubuntuvm:~# python3 -VPython 3.8.5
2、安装venv模块
root@ubuntuvm:/home# apt install python3-venv python3-devReading package lists… DoneBuilding dependency treeReading state information… DoneThe following additional packages will be installed:libc-dev-bin libc6 libc6-dbg libc6-dev libcrypt-dev libexpat1-dev libpython3-dev libpython3.8-dev linux-libc-dev manpages-dev python-pip-whlpython3-distutils python3.8-dev python3.8-venv zlib1g zlib1g-devSuggested packages:glibc-docThe following NEW packages will be installed:libc-dev-bin libc6-dev libcrypt-dev libexpat1-dev libpython3-dev libpython3.8-dev linux-libc-dev manpages-dev python-pip-whl python3-devpython3-distutils python3-venv python3.8-dev python3.8-venv zlib1g-devThe following packages will be upgraded:libc6 libc6-dbg zlib1g3 upgraded, 15 newly installed, 0 to remove and 233 not upgraded.Need to get 21.2 MB of archives.After this operation, 56.1 MB of additional disk space will be used.Do you want to continue? [Y/n] y
3、创建项目目录
bdsc@ubuntuvm:~$ mkdir mytensorflowbdsc@ubuntuvm:~$ cd mytensorflow/
4、创建虚拟环境
bdsc@ubuntuvm:~/mytensorflow$ python3 -m venv tenf
5、激活虚拟环境
bdsc@ubuntuvm:~/mytensorflow$ source tenf/bin/activate(tenf) bdsc@ubuntuvm:~/mytensorflow$
6、升级pip
(tenf) bdsc@ubuntuvm:~/mytensorflow$ pip3 -Vpip 20.0.2 from /home/bdsc/mytensorflow/tenf/lib/python3.8/site-packages/pip (python 3.8)(tenf) bdsc@ubuntuvm:~/mytensorflow$ pip install --upgrade pipCollecting pipDownloading pip-21.0-py3-none-any.whl (1.5 MB)|████████████████████████████████| 1.5 MB 1.0 MB/sInstalling collected packages: pipAttempting uninstall: pipFound existing installation: pip 20.0.2Uninstalling pip-20.0.2:Successfully uninstalled pip-20.0.2Successfully installed pip-21.0(tenf) bdsc@ubuntuvm:~/mytensorflow$ pip3 -Vpip 21.0 from /home/bdsc/mytensorflow/tenf/lib/python3.8/site-packages/pip (python 3.8)
7、安装tensorflow
(tenf) bdsc@ubuntuvm:~/mytensorflow$ pip3 install tensorflowCollecting tensorflowDownloading tensorflow-2.4.1-cp38-cp38-manylinux2010_x86_64.whl (394.4 MB)|████████████████████████████████| 394.4 MB 4.9 kB/sCollecting tensorflow-estimator<2.5.0,>=2.4.0Downloading tensorflow_estimator-2.4.0-py2.py3-none-any.whl (462 kB)|████████████████████████████████| 462 kB 24 kB/sCollecting astunparse~=1.6.3Downloading astunparse-1.6.3-py2.py3-none-any.whl (12 kB)Collecting protobuf>=3.9.2Downloading protobuf-3.14.0-cp38-cp38-manylinux1_x86_64.whl (1.0 MB)|████████████████████████████████| 1.0 MB 35 kB/sCollecting gast==0.3.3Downloading gast-0.3.3-py2.py3-none-any.whl (9.7 kB)Collecting flatbuffers~=1.12.0Downloading flatbuffers-1.12-py2.py3-none-any.whl (15 kB)Collecting absl-py~=0.10Downloading absl_py-0.11.0-py3-none-any.whl (127 kB)|████████████████████████████████| 127 kB 52 kB/sCollecting wheel~=0.35Downloading wheel-0.36.2-py2.py3-none-any.whl (35 kB)Collecting termcolor~=1.1.0Downloading termcolor-1.1.0.tar.gz (3.9 kB)Collecting wrapt~=1.12.1Downloading wrapt-1.12.1.tar.gz (27 kB)Collecting grpcio~=1.32.0Downloading grpcio-1.32.0-cp38-cp38-manylinux2014_x86_64.whl (3.8 MB)|████████████████████████████████| 3.8 MB 35 kB/sCollecting six~=1.15.0Downloading six-1.15.0-py2.py3-none-any.whl (10 kB)Collecting typing-extensions~=3.7.4Downloading typing_extensions-3.7.4.3-py3-none-any.whl (22 kB)Collecting tensorboard~=2.4Downloading tensorboard-2.4.1-py3-none-any.whl (10.6 MB)|████████████████████████████████| 10.6 MB 46 kB/sCollecting keras-preprocessing~=1.1.2Downloading Keras_Preprocessing-1.1.2-py2.py3-none-any.whl (42 kB)|████████████████████████████████| 42 kB 43 kB/sCollecting h5py~=2.10.0Downloading h5py-2.10.0-cp38-cp38-manylinux1_x86_64.whl (2.9 MB)|████████████████████████████████| 2.9 MB 46 kB/sCollecting opt-einsum~=3.3.0Downloading opt_einsum-3.3.0-py3-none-any.whl (65 kB)|████████████████████████████████| 65 kB 45 kB/sCollecting google-pasta~=0.2Downloading google_pasta-0.2.0-py3-none-any.whl (57 kB)|████████████████████████████████| 57 kB 26 kB/sCollecting numpy~=1.19.2Downloading numpy-1.19.5-cp38-cp38-manylinux2010_x86_64.whl (14.9 MB)|████████████████████████████████| 14.9 MB 65 kB/sCollecting markdown>=2.6.8Downloading Markdown-3.3.3-py3-none-any.whl (96 kB)|████████████████████████████████| 96 kB 66 kB/sCollecting google-auth-oauthlib<0.5,>=0.4.1Downloading google_auth_oauthlib-0.4.2-py2.py3-none-any.whl (18 kB)Collecting werkzeug>=0.11.15Downloading Werkzeug-1.0.1-py2.py3-none-any.whl (298 kB)|████████████████████████████████| 298 kB 44 kB/sRequirement already satisfied: setuptools>=41.0.0 in ./tenf/lib/python3.8/site-packages (from tensorboard~=2.4->tensorflow) (44.0.0)Collecting tensorboard-plugin-wit>=1.6.0Downloading tensorboard_plugin_wit-1.8.0-py3-none-any.whl (781 kB)|████████████████████████████████| 781 kB 43 kB/sCollecting requests<3,>=2.21.0Downloading requests-2.25.1-py2.py3-none-any.whl (61 kB)|████████████████████████████████| 61 kB 57 kB/sCollecting google-auth<2,>=1.6.3Downloading google_auth-1.24.0-py2.py3-none-any.whl (114 kB)|████████████████████████████████| 114 kB 37 kB/sCollecting rsa<5,>=3.1.4Downloading rsa-4.7-py3-none-any.whl (34 kB)Collecting pyasn1-modules>=0.2.1Downloading pyasn1_modules-0.2.8-py2.py3-none-any.whl (155 kB)|████████████████████████████████| 155 kB 34 kB/sCollecting cachetools<5.0,>=2.0.0Downloading cachetools-4.2.1-py3-none-any.whl (12 kB)Collecting requests-oauthlib>=0.7.0Downloading requests_oauthlib-1.3.0-py2.py3-none-any.whl (23 kB)Collecting pyasn1<0.5.0,>=0.4.6Downloading pyasn1-0.4.8-py2.py3-none-any.whl (77 kB)|████████████████████████████████| 77 kB 42 kB/sCollecting chardet<5,>=3.0.2Downloading chardet-4.0.0-py2.py3-none-any.whl (178 kB)|████████████████████████████████| 178 kB 47 kB/sCollecting idna<3,>=2.5Downloading idna-2.10-py2.py3-none-any.whl (58 kB)|████████████████████████████████| 58 kB 31 kB/sCollecting urllib3<1.27,>=1.21.1Downloading urllib3-1.26.2-py2.py3-none-any.whl (136 kB)|████████████████████████████████| 136 kB 33 kB/sCollecting certifi>=2017.4.17Downloading certifi-2020.12.5-py2.py3-none-any.whl (147 kB)|████████████████████████████████| 147 kB 26 kB/sCollecting oauthlib>=3.0.0Downloading oauthlib-3.1.0-py2.py3-none-any.whl (147 kB)|████████████████████████████████| 147 kB 36 kB/sUsing legacy ‘setup.py install' for termcolor, since package ‘wheel' is not installed.Using legacy ‘setup.py install' for wrapt, since package ‘wheel' is not installed.Installing collected packages: urllib3, pyasn1, idna, chardet, certifi, six, rsa, requests, pyasn1-modules, oauthlib, cachetools, requests-oauthlib, google-auth, wheel, werkzeug, tensorboard-plugin-wit, protobuf, numpy, markdown, grpcio, google-auth-oauthlib, absl-py, wrapt, typing-extensions, termcolor, tensorflow-estimator, tensorboard, opt-einsum, keras-preprocessing, h5py, google-pasta, gast, flatbuffers, astunparse, tensorflowRunning setup.py install for wrapt … doneRunning setup.py install for termcolor … doneSuccessfully installed absl-py-0.11.0 astunparse-1.6.3 cachetools-4.2.1 certifi-2020.12.5 chardet-4.0.0 flatbuffers-1.12 gast-0.3.3 google-auth-1.24.0 google-auth-oauthlib-0.4.2 google-pasta-0.2.0 grpcio-1.32.0 h5py-2.10.0 idna-2.10 keras-preprocessing-1.1.2 markdown-3.3.3 numpy-1.19.5 oauthlib-3.1.0 opt-einsum-3.3.0 protobuf-3.14.0 pyasn1-0.4.8 pyasn1-modules-0.2.8 requests-2.25.1 requests-oauthlib-1.3.0 rsa-4.7 six-1.15.0 tensorboard-2.4.1 tensorboard-plugin-wit-1.8.0 tensorflow-2.4.1 tensorflow-estimator-2.4.0 termcolor-1.1.0 typing-extensions-3.7.4.3 urllib3-1.26.2 werkzeug-1.0.1 wheel-0.36.2 wrapt-1.12.1
8、验证tensoflow2是否安装成功
1、查看安装模块及版本
(tenf) bdsc@ubuntuvm:~/mytensorflow$ pip3 show tensorflowName: tensorflowVersion: 2.4.1Summary: TensorFlow is an open source machine learning framework for everyone.Home-page: https://pat.v1.Session()
到此这篇关于Ubuntu20.04环境安装tensorflow2的实现的文章就介绍到这了,更多相关Ubuntu20.04安装tensorflow2内容请搜索以前的文章或继续浏览下面的相关文章希望大家以后多多支持!