【问题标题】:How can I find to access to GPUs via Tensorflow in PyCharm?如何在 PyCharm 中通过 Tensorflow 访问 GPU?
【发布时间】:2021-08-29 07:54:53
【问题描述】:

我在 PyCharm 中无法访问 GPU 时遇到问题,我使用 NVIDIA 作为 GPU

我在 PycharmSetting 部分的 Python Interpreter 中安装了tensorflow-gpu,然后我运行了代码,但我仍然无法访问它。

我想知道我是否应该使用 CUDA 库?我该如何解决?

这是我的代码 sn-p,如下所示。

print(tf.config.list_physical_devices('GPU'))

if tf.test.gpu_device_name():
    print('Default GPU Device: {}'.format(tf.test.gpu_device_name()))
else:
    print("Please install GPU version of TF")

这是代码的输出,如下所示。

[]
2021-06-12 23:28:52.693028: I tensorflow/compiler/mlir/mlir_graph_optimization_pass.cc:176] None of the MLIR Optimization Passes are enabled (registered 2)
2021-06-12 23:28:52.702716: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1733] Found device 0 with properties: 
pciBusID: 0000:01:00.0 name: NVIDIA GeForce GTX 1650 Ti computeCapability: 7.5
coreClock: 1.485GHz coreCount: 16 deviceMemorySize: 4.00GiB deviceMemoryBandwidth: 178.84GiB/s
2021-06-12 23:28:52.702905: W tensorflow/core/common_runtime/gpu/gpu_device.cc:1766] Cannot dlopen some GPU libraries. Please make sure the missing libraries mentioned above are installed properly if you would like to use GPU. Follow the guide at https://www.tensorflow.org/install/gpu for how to download and setup the required libraries for your platform.
Skipping registering GPU devices...
Please install GPU version of TF
2021-06-12 23:28:52.816304: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1258] Device interconnect StreamExecutor with strength 1 edge matrix:
2021-06-12 23:28:52.816435: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1264]      0 
2021-06-12 23:28:52.816495: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1277] 0:   N 

【问题讨论】:

  • TensorFlow 打印的日志不止于此,尤其是它指出缺少哪些库的日志。
  • @Dr.Snoopy 我应该为此过程安装 NVIDIA Cuda 库吗?
  • CUDA 是必需的,我不知道你为什么这么问。我要的是完整的 TensorFlow 日志。
  • 您的错误显示:Follow the guide at https://www.tensorflow.org/install/gpu - 您是否检查了此链接?此页面上甚至还有Software requirements,其中显示了NVIDIA® GPU drivers —CUDA® 11.2 requires 450.80.02 or higher. 和其他工具。因此,如果您应该阅读错误消息,您可以在几小时/几天前解决您的问题。
  • @furas 我从这个链接安装了 Cuda:developer.nvidia.com/cuda-11.0-download-archive 然后运行代码。我收到了这条消息 (Please install GPU version of TF)

标签: python tensorflow pycharm


【解决方案1】:

我解决了我的问题。

以下是解决该问题的步骤。

1 ) 从https://developer.nvidia.com/cuda-downloads下载CUDA

2 ) 从https://developer.nvidia.com/rdp/cudnn-download下载CUDNN

3 ) 从 CUDNN zip 文件中复制 bin,include 最后是 lib 并粘贴到 C:\Program Files\NVIDIA GPU Computing Toolkit \CUDA{版本}

4 ) 然后在PyCharm中运行.py代码,它终于感知到了GPU

【讨论】:

  • 现在您可以将您的回答标记为已接受。几分钟后你就可以投票了。
猜你喜欢
  • 2019-08-28
  • 1970-01-01
  • 2021-01-31
  • 2018-03-14
  • 1970-01-01
  • 2019-06-09
  • 2019-04-10
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多