【问题标题】:tensorflow GPU not showing in jupyter notebooktensorflow GPU 未在 jupyter 笔记本中显示
【发布时间】:2020-07-08 11:53:40
【问题描述】:

在终端

  • Windows 10
  • 使用 cuda 10.1
  • python 3.7.7
  • GPU GeForce GTX 1050 4GB
>>> import tensorflow as tf
2020-07-08 17:10:50.005569: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
>>> tf.config.list_physical_devices('GPU')
2020-07-08 17:10:55.657489: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1561] Found device 0 with properties:
pciBusID: 0000:01:00.0 name: GeForce GTX 1050 computeCapability: 6.1
coreClock: 1.493GHz coreCount: 5 deviceMemorySize: 4.00GiB deviceMemoryBandwidth: 104.43GiB/s
2020-07-08 17:10:55.701387: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1703] Adding visible gpu devices: 0
[PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]

在 jupyter 笔记本中

in [1]: import tensorflow as tf
        tf.config.list_physical_devices('GPU')
out[1]: []

in [1]: tf.__version__
out[1]: '2.2.0'

【问题讨论】:

  • 您是否使用相同的环境来运行 Jupyter 笔记本和脚本?
  • 是的,同样的 anaconda 环境。
  • 你可能有 2 个环境,环境 (A) 有一个简单的 TF 安装,第二个环境 (B) 有 GPU TF,你的笔记本在环境 (A) 中。你是把它们安装在 anaconda 基地还是虚拟环境中?
  • 我在两个地方都使用了相同的 anaconda env 名称 ai,我检查了很多次 env 名称 ai 和其他 env 都没有安装 tensorflow 或 tensorflow-gpu。
  • 然后检查您的 Jupiter 是否在 ai 环境中运行。你可以在 Jupiter notebook 或者 anaconda navigator 界面中进行操作

标签: python tensorflow jupyter-notebook


【解决方案1】:

需要为这个环境制作新内核,并从jupyter notebook中选择内核

$ conda activate env_name
$ pip install ipykernel --user
$ python -m ipykernel install --user --name env_name --display-name env_name

【讨论】:

    猜你喜欢
    • 2022-06-15
    • 2019-05-10
    • 2018-02-26
    • 2018-04-04
    • 2018-10-13
    • 2020-07-22
    • 2019-03-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多