python - 如何在 PyCharm 中通过 Tensorflow 访问 GPU?
问题描述
我有一个关于在PyCharm中不访问 GPU 的问题,我使用NVIDIA作为GPU。
我安装tensorflow-gpu
在Pycharm中设置部分的Python 解释器中,然后运行代码,但我仍然无法访问它。
我想知道我是否应该使用 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。
推荐阅读
- java - 如何在 Apache Camel 中发送带有参数的 REST 请求
- stenciljs - 从“../types/globals”导入类型 { 组件,JSX };dist 路径错误
- sql - SQL,仅检索其多对多关系的所有 ID 都在数组中的条目
- python - 如何消除 PIL 和 pygame 图像之间的差异
- python - 使用 Python 批量下载 FTP Urls
- firebase - 没有使用 uvicorn main:app --reload 名为“firebase_admin”的模块
- while-loop - ksh 无法从 while 循环中导出变量
- java - 如何修复此 JDA discord bot 错误?
- java - 如果需要转换内部列表,如何将 EntityA 列表转换为 EntityB 列表?
- google-sheets - 谷歌表格电报