13. 在ubuntu16.04(linux)安装配置tensroflow-io

13. 配置tensroflow-io+tensorflow-io-kafka

  • > 前置环境准备
  • 1、安装tensorflow-io

> 前置环境准备

10. ubuntu16.04配置anaconda+python3+tensorflow+jupyter远程访问

1、安装tensorflow-io

安装到tensorflow环境里,先启动环境

activate source tensorflow

由于conda install不能搜索到tensorflow-io,因此就用pip安装

换成清华镜像源安装tensorflow-io
加上pip install -i https://pypi.tuna.tsinghua.edu.cn/simple

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

python-解决pip安装速度慢的问题

注:如果报异常

ERROR: google-auth 1.11.2 has requirement setuptools>=40.3.0, but you'll have setuptools 36.4.0 which is incompatible.
ERROR: tensorboard 2.1.1 has requirement setuptools>=41.0.0, but you'll have setuptools 36.4.0 which is incompatible.
Installing collected packages: gast, wrapt, astor, six, google-pasta, grpcio, numpy, h5py, keras-applications, scipy, opt-einsum, keras-preprocessing, protobuf, idna, certifi, urllib3, chardet, requests, oauthlib, requests-oauthlib, cachetools, pyasn1, rsa, pyasn1-modules, google-auth, google-auth-oauthlib, absl-py, tensorboard, tensorflow-estimator, termcolor, tensorflow, tensorflow-io
  Attempting uninstall: six
    Found existing installation: six 1.10.0
ERROR: Cannot uninstall 'six'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

13. 在ubuntu16.04(linux)安装配置tensroflow-io_第1张图片
解决方法:
更新six和setuptools

$ pip install --ignore-installed six
$ pip install --ignore-installed setuptools

如果显示不能找到对应版本的setuptools就先卸载后安装

$ pip uninstall setuptools
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple  setuptools==41.0.0

Tensorflow2.0安装异常解决

【异常】tensorboard 1.14.0 has requirement setuptools>=41.0.0, but you’ll have setuptools 40.6.3

Tensorflow安装

开启jupyter验证一下

$ jupyter notebook --allow-root > jupyter.log 2>&1 &
[1] 2715

13. 在ubuntu16.04(linux)安装配置tensroflow-io_第2张图片
安装成功

再来使用官方示例测试一下

import tensorflow as tf
import tensorflow_io as tfio

# Read MNIST into Dataset
d_train = tfio.IODataset.from_mnist(
    'http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz',
    'http://yann.lecun.com/exdb/mnist/train-labels-idx1-ubyte.gz').batch(1)

# By default image data is uint8 so conver to float32.
d_train = d_train.map(lambda x, y: (tf.image.convert_image_dtype(x, tf.float32), y))

model = tf.keras.models.Sequential([
  tf.keras.layers.Flatten(input_shape=(28, 28)),
  tf.keras.layers.Dense(512, activation=tf.nn.relu),
  tf.keras.layers.Dropout(0.2),
  tf.keras.layers.Dense(10, activation=tf.nn.softmax)
])
model.compile(optimizer='adam',
              loss='sparse_categorical_crossentropy',
              metrics=['accuracy'])

model.fit(d_train, epochs=5, steps_per_epoch=10000)

13. 在ubuntu16.04(linux)安装配置tensroflow-io_第3张图片
拓展知识:
python 如何找到import的包

你可能感兴趣的:(车联网项目,深度学习,Tensorflow)