【每天学习一点点】Tensorflow GPU与CPU版本

从 TensorFlow 2.1 开始,pip 包 tensorflow 即同时包含 GPU 支持,无需通过特定的 pip 包 tensorflow-gpu 安装 GPU 版本。

如果对 pip 包的大小敏感,可使用 tensorflow-cpu 包安装仅支持 CPU 的 TensorFlow 版本。

  1. TensorFlow 2.1 默认安装(pip install tensorflow)就已经同时支持 CPU 和 GPU,可以使用

    cpus = tf.config.list_physical_devices (device_type=‘CPU’)
    tf.config.set_visible_devices (devices=cpus)

来限定只使用 CPU 进行运算。

posted @ 2020-07-21 16:31  黄彬子  阅读(602)  评论(0编辑  收藏  举报