如何在 PyCharm 中找到通过 Tensorflow 访问 GPU 的权限?
How can I find to access to GPUs via Tensorflow in PyCharm?
我无法在 PyCharm 中访问 GPU,我使用 NVIDIA 作为 GPU .
我在Python 设置部分的解释器安装了tensorflow-gpu
Pycharm 然后我 运行 代码,但我仍然无法访问它。
我想知道我是否应该使用 CUDA 库?我该如何解决?
这是我的代码片段,如下所示。
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
我解决了我的问题。
以下是解决该问题的步骤。
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{version}
4 ) 然后 运行 PyCharm 中的 .py
代码,它感知 GPU终于。
我无法在 PyCharm 中访问 GPU,我使用 NVIDIA 作为 GPU .
我在Python 设置部分的解释器安装了tensorflow-gpu
Pycharm 然后我 运行 代码,但我仍然无法访问它。
我想知道我是否应该使用 CUDA 库?我该如何解决?
这是我的代码片段,如下所示。
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
我解决了我的问题。
以下是解决该问题的步骤。
1 ) 从 https://developer.nvidia.com/cuda-downloads
下载 CUDA2 ) 从 https://developer.nvidia.com/rdp/cudnn-download
下载 CUDNN3 ) 从 CUDNN zip 文件中复制 bin,include 和最后的 lib 并粘贴它 C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA{version}
4 ) 然后 运行 PyCharm 中的 .py
代码,它感知 GPU终于。