【Tensorflow】Tensorflow1.15安装(Ubuntu20.04+Anaconda3)

文章目录

创建conda环境

对于Anaconda的安装,参见这篇文章:Anaconda介绍、安装及使用教程
安装好Anaconda后,创建一个新的环境:

conda create -n tf-grasr python=3.6

然后启动刚刚创建的conda环境:

conda activate tf-grasr

安装tensorflow1.15

用如下指令安装tensorflow1.15,用的是阿里云的镜像:1

pip --default-timeout=100 install --upgrade -i https://mirrors.aliyun.com/pypi/simple tensorflow==1.15.0

在通读纸条后,它被安装了。

[En]

After reading through the note, it was installed.

(tf-grasr) octopus@ubuntu:~$ pip --default-timeout=100 install --upgrade -i https://mirrors.aliyun.com/pypi/simple tensorflow==1.15.0
Looking in indexes: https://mirrors.aliyun.com/pypi/simple
Collecting tensorflow==1.15.0
  Downloading https://mirrors.aliyun.com/pypi/packages/3f/98/5a99af92fb911d7a88a0005ad55005f35b4c1ba8d75fba02df726cd936e6/tensorflow-1.15.0-cp36-cp36m-manylinux2010_x86_64.whl (412.3 MB)
     |████████████████████████████████| 412.3 MB 9.1 kB/s
Collecting numpy<2.0,>=1.16.0
  Downloading https://mirrors.aliyun.com/pypi/packages/14/32/d3fa649ad7ec0b82737b92fefd3c4dd376b0bb23730715124569f38f3a08/numpy-1.19.5-cp36-cp36m-manylinux2010_x86_64.whl (14.8 MB)
     |████████████████████████████████| 14.8 MB 12.9 MB/s
Collecting protobuf>=3.6.1
  Downloading https://mirrors.aliyun.com/pypi/packages/0f/1c/6b3b5b8c07e92b84cb7d4fb946a8bc72b98d93d8b7c8e8a8e45023745810/protobuf-3.19.4-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB)
     |████████████████████████████████| 1.1 MB 9.2 MB/s
Collecting tensorboard<1.16.0,>=1.15.0
  Downloading https://mirrors.aliyun.com/pypi/packages/1e/e9/d3d747a97f7188f48aa5eda486907f3b345cd409f0a0850468ba867db246/tensorboard-1.15.0-py3-none-any.whl (3.8 MB)
     |████████████████████████████████| 3.8 MB 26.9 MB/s
Collecting wrapt>=1.11.1
  Downloading https://mirrors.aliyun.com/pypi/packages/e2/0f/89c9c2d8ba06709a3d471507a78be443e2c2d9f1321d3e1154c76f44150c/wrapt-1.13.3-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (78 kB)
     |████████████████████████████████| 78 kB 7.4 MB/s
Collecting absl-py>=0.7.0
  Downloading https://mirrors.aliyun.com/pypi/packages/2c/03/e3e19d3faf430ede32e41221b294e37952e06acc96781c417ac25d4a0324/absl_py-1.0.0-py3-none-any.whl (126 kB)
     |████████████████████████████████| 126 kB 20.8 MB/s
Collecting keras-applications>=1.0.8
  Downloading https://mirrors.aliyun.com/pypi/packages/71/e3/19762fdfc62877ae9102edf6342d71b28fbfd9dea3d2f96a882ce099b03f/Keras_Applications-1.0.8-py3-none-any.whl (50 kB)
     |████████████████████████████████| 50 kB 9.0 MB/s
Collecting opt-einsum>=2.3.2
  Downloading https://mirrors.aliyun.com/pypi/packages/bc/19/404708a7e54ad2798907210462fd950c3442ea51acc8790f3da48d2bee8b/opt_einsum-3.3.0-py3-none-any.whl (65 kB)
     |████████████████████████████████| 65 kB 8.1 MB/s
Collecting six>=1.10.0
  Downloading https://mirrors.aliyun.com/pypi/packages/d9/5a/e7c31adbe875f2abbb91bd84cf2dc52d792b5a01506781dbcf25c91daf11/six-1.16.0-py2.py3-none-any.whl (11 kB)
Collecting tensorflow-estimator==1.15.1
  Downloading https://mirrors.aliyun.com/pypi/packages/de/62/2ee9cd74c9fa2fa450877847ba560b260f5d0fb70ee0595203082dafcc9d/tensorflow_estimator-1.15.1-py2.py3-none-any.whl (503 kB)
     |████████████████████████████████| 503 kB 19.0 MB/s
Collecting keras-preprocessing>=1.0.5
  Downloading https://mirrors.aliyun.com/pypi/packages/79/4c/7c3275a01e12ef9368a892926ab932b33bb13d55794881e3573482b378a7/Keras_Preprocessing-1.1.2-py2.py3-none-any.whl (42 kB)
     |████████████████████████████████| 42 kB 2.6 MB/s
Collecting astor>=0.6.0
  Downloading https://mirrors.aliyun.com/pypi/packages/c3/88/97eef84f48fa04fbd6750e62dcceafba6c63c81b7ac1420856c8dcc0a3f9/astor-0.8.1-py2.py3-none-any.whl (27 kB)
Collecting termcolor>=1.1.0
  Downloading https://mirrors.aliyun.com/pypi/packages/8a/48/a76be51647d0eb9f10e2a4511bf3ffb8cc1e6b14e9e4fab46173aa79f981/termcolor-1.1.0.tar.gz (3.9 kB)
Collecting grpcio>=1.8.6
  Downloading https://mirrors.aliyun.com/pypi/packages/a6/33/152e05445decf5b1ce50e04e17bff9dade4bcd88f54b85d8bb37360ae29e/grpcio-1.44.0-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.3 MB)
     |████████████████████████████████| 4.3 MB 11.8 MB/s
Collecting gast==0.2.2
  Downloading https://mirrors.aliyun.com/pypi/packages/4e/35/11749bf99b2d4e3cceb4d55ca22590b0d7c2c62b9de38ac4a4a7f4687421/gast-0.2.2.tar.gz (10 kB)
Requirement already satisfied: wheel>=0.26 in ./anaconda3/envs/tf-grasr/lib/python3.6/site-packages (from tensorflow==1.15.0) (0.37.1)
Collecting google-pasta>=0.1.6
  Downloading https://mirrors.aliyun.com/pypi/packages/a3/de/c648ef6835192e6e2cc03f40b19eeda4382c49b5bafb43d88b931c4c74ac/google_pasta-0.2.0-py3-none-any.whl (57 kB)
     |████████████████████████████████| 57 kB 11.2 MB/s
Collecting h5py
  Downloading https://mirrors.aliyun.com/pypi/packages/70/7a/e53e500335afb6b1aade11227cdf107fca54106a1dca5c9d13242a043f3b/h5py-3.1.0-cp36-cp36m-manylinux1_x86_64.whl (4.0 MB)
     |████████████████████████████████| 4.0 MB 14.6 MB/s
Collecting markdown>=2.6.8
  Downloading https://mirrors.aliyun.com/pypi/packages/9f/d4/2c7f83915d437736996b2674300c6c4b578a6f897f34e40f5c04db146719/Markdown-3.3.6-py3-none-any.whl (97 kB)
     |████████████████████████████████| 97 kB 13.4 MB/s
Collecting werkzeug>=0.11.15
  Downloading https://mirrors.aliyun.com/pypi/packages/f4/f3/22afbdb20cc4654b10c98043414a14057cd27fdba9d4ae61cea596000ba2/Werkzeug-2.0.3-py3-none-any.whl (289 kB)
     |████████████████████████████████| 289 kB 10.4 MB/s
Requirement already satisfied: setuptools>=41.0.0 in ./anaconda3/envs/tf-grasr/lib/python3.6/site-packages (from tensorboard<1.16.0,>=1.15.0->tensorflow==1.15.0) (58.0.4)
Collecting importlib-metadata>=4.4
  Downloading https://mirrors.aliyun.com/pypi/packages/a0/a1/b153a0a4caf7a7e3f15c2cd56c7702e2cf3d89b1b359d1f1c5e59d68f4ce/importlib_metadata-4.8.3-py3-none-any.whl (17 kB)
Collecting typing-extensions>=3.6.4
  Downloading https://mirrors.aliyun.com/pypi/packages/45/6b/44f7f8f1e110027cf88956b59f2fad776cca7e1704396d043f89effd3a0e/typing_extensions-4.1.1-py3-none-any.whl (26 kB)
Collecting zipp>=0.5
  Downloading https://mirrors.aliyun.com/pypi/packages/bd/df/d4a4974a3e3957fd1c1fa3082366d7fff6e428ddb55f074bf64876f8e8ad/zipp-3.6.0-py3-none-any.whl (5.3 kB)
Collecting dataclasses
  Downloading https://mirrors.aliyun.com/pypi/packages/fe/ca/75fac5856ab5cfa51bbbcefa250182e50441074fdc3f803f6e76451fab43/dataclasses-0.8-py3-none-any.whl (19 kB)
Collecting cached-property
  Downloading https://mirrors.aliyun.com/pypi/packages/48/19/f2090f7dad41e225c7f2326e4cfe6fff49e57dedb5b53636c9551f86b069/cached_property-1.5.2-py2.py3-none-any.whl (7.6 kB)
Building wheels for collected packages: gast, termcolor
  Building wheel for gast (setup.py) ... done
  Created wheel for gast: filename=gast-0.2.2-py3-none-any.whl size=7554 sha256=02d0d8029b49f951a7c16c574e6db6e9ba227aace314a48c2947abdcf3ff37b3
  Stored in directory: /home/octopus/.cache/pip/wheels/03/9c/3b/f49834321f4df7842d61424af7595757054699bcc4e8dc55f1
  Building wheel for termcolor (setup.py) ... done
  Created wheel for termcolor: filename=termcolor-1.1.0-py3-none-any.whl size=4848 sha256=d8baa7eed749dd82e815dc725fc83ba9eab559ca04589b5a1e87b60e2abad307
  Stored in directory: /home/octopus/.cache/pip/wheels/9f/03/82/3f6f270c949e40cb4da585d10190b7ab28f40f7a6b43089938
Successfully built gast termcolor
Installing collected packages: zipp, typing-extensions, six, numpy, importlib-metadata, dataclasses, cached-property, werkzeug, protobuf, markdown, h5py, grpcio, absl-py, wrapt, termcolor, tensorflow-estimator, tensorboard, opt-einsum, keras-preprocessing, keras-applications, google-pasta, gast, astor, tensorflow
Successfully installed absl-py-1.0.0 astor-0.8.1 cached-property-1.5.2 dataclasses-0.8 gast-0.2.2 google-pasta-0.2.0 grpcio-1.44.0 h5py-3.1.0 importlib-metadata-4.8.3 keras-applications-1.0.8 keras-preprocessing-1.1.2 markdown-3.3.6 numpy-1.19.5 opt-einsum-3.3.0 protobuf-3.19.4 six-1.16.0 tensorboard-1.15.0 tensorflow-1.15.0 tensorflow-estimator-1.15.1 termcolor-1.1.0 typing-extensions-4.1.1 werkzeug-2.0.3 wrapt-1.13.3 zipp-3.6.0

测试是否安装成功

terminal中测试

在terminal中输入 python进入python的实时环境:

python

运行如下两行代码,即导入tensorflow,并查看版本:

import tensorflow as tf
tf.__version__

运行结果如下,可以看到,导入的时候没有报错,也输出的正确的版本号。最后用 exit()可以退出python实时环境。

【Tensorflow】Tensorflow1.15安装(Ubuntu20.04+Anaconda3)

jupyter notebook测试

用如下命令启动jupyter notebook:

jupyter notebook

新建一个notebook,并且用上述的方法测试tensorflow。按理来说我们已经安装完成了,但是却出现了找不到模块的报错:

【Tensorflow】Tensorflow1.15安装(Ubuntu20.04+Anaconda3)

这就很奇怪了,上网查了一下,说是因为此时的jupyter是基于整个Anaconda的python,而不是对应的tensorflow虚拟环境,因此进入此虚拟环境后需要重新安装jupyter notebook。2

运行如下代码进行安装:

conda install ipython
conda install jupyter

再启动jupyter notebook,就可以正常运行了~
完整测试代码:

import tensorflow as tf
tf.__version__
tf.test.is_built_with_cuda()
tf.test.is_gpu_available(cuda_only=False,min_cuda_compute_capability=None)

测试情况:

【Tensorflow】Tensorflow1.15安装(Ubuntu20.04+Anaconda3)

Original: https://blog.csdn.net/m0_60765523/article/details/123170295
Author: Octopus–
Title: 【Tensorflow】Tensorflow1.15安装(Ubuntu20.04+Anaconda3)

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/496424/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球