问题:tensorflow安装后,没有识别到GPU,只能用CPU运行计算。
解决步骤:
1、安装cuda https://developer.nvidia.com/cuda-toolkit-archive
2、安装cuda对应的cuDNN,下载需要NVIDIA账号 cuDNN Archive | NVIDIA Developer
3、试试能不能识别到GPU
>>> import tensorflow as tf
>>> hello =tf.constant('hello, tensorflow')
2022-08-17 10:19: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2022-08-17 10:19: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1532] Created device /job:localhost/replica:0/task:0/device:GPU:0 with 2780 MB memory: -> device: 0, name: NVIDIA GeForce GTX 1050, pci bus id: 0000:01:00.0, compute capability: 6.1
如果报错“Could not load library cudnn_cnn_infer64_8.dll. Error code 126 Please make sure cudnn_cnn_infer64_8.”
前往这里如下所示位置下载一个zlib包,解压缩后找到zlibwapi.dll文件,剪切到C:\Windows\System32位置下面
参考链接:
GTX1050+cuda9.0+cuDNN+pytorch+anaconda环境搭建_颖火虫盟主的博客-优快云博客_gtx1050支持cuda吗Could not load library cudnn_cnn_infer64_8.dll. Error code 126 Please make sure cudnn_cnn_infer64_8._illumiD的博客-优快云博客