解决在Windows中安装tensorflow2.10无法检测到GPU的问题

解决在Windows中安装tensorflow2.10无法检测到GPU的问题

官方给出的Windows本地安装方式

  1. 更新显卡驱动到最新。
  2. 安装anaconda或miniconda作为python环境的管理工具。
  3. 创建新的环境tf:conda create --name tf python=3.9,然后进入改环境:conda activate tf
  4. 更新pip:pip install --upgrade pip
  5. 安装cuda工具包和cudnn库:conda install -c conda-forge cudatoolkit=11.2 cudnn=8.1.0
  6. 安装tensorflow,并确保numpy版本低于2.0:pip install "tensorflow<2.11" "numpy<2.0"
  7. 验证CPU功能是否正常:python -c "import tensorflow as tf; print(tf.reduce_sum(tf.random.normal([1000, 1000])))" 。若正常,应有类似下面的输出。
  8. 验证GPU功能是否正常:python -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))".若正常,应有类似下面的输出:

    特别注意,完成这些安装之后不要再安装tensorflow-intel,否则会破坏当GPU功能。

问题症状

运行上述步骤中的第8步验证GPU功能是否正常时,命令行输出的结果是空列表[]。这表示tensorflow并没有检测到GPU设备。

移除tensorflow-intel:

bash 复制代码
pip uninstall tensorflow-intel

解决方式

更新显卡驱动、安装CUDA toolkit等操作都无法解决问题时,请尝试这个办法。

移除当前环境中和tensorflow密切相关的库后,重新安装低于2.11版本的tensorflow:

复制代码
pip uninstall keras
pip uninstall tensorflow-io-gcs-filesystem
pip uninstall tensorflow-estimator
pip uninstall tensorflow
pip uninstall Keras-Preprocessing
pip uninstall tensorflow-intel
pip install tensorflow
pip install "tensorflow<2.11"

参考网页

官方教程-用pip安装tensorflow
<>
StackOverflow: Tensorflow doesn't seem to see my gpu

相关推荐
stbomei1 小时前
当 AI 开始 “理解” 情感:情感计算技术正在改写人机交互规则
人工智能·人机交互
Moshow郑锴6 小时前
人工智能中的(特征选择)数据过滤方法和包裹方法
人工智能
TY-20256 小时前
【CV 目标检测】Fast RCNN模型①——与R-CNN区别
人工智能·目标检测·目标跟踪·cnn
CareyWYR7 小时前
苹果芯片Mac使用Docker部署MinerU api服务
人工智能
失散138 小时前
自然语言处理——02 文本预处理(下)
人工智能·自然语言处理
cpsvps_net8 小时前
美国服务器环境下Windows容器工作负载智能弹性伸缩
windows
mit6.8248 小时前
[1Prompt1Story] 滑动窗口机制 | 图像生成管线 | VAE变分自编码器 | UNet去噪神经网络
人工智能·python
sinat_286945198 小时前
AI应用安全 - Prompt注入攻击
人工智能·安全·prompt
甄超锋8 小时前
Java ArrayList的介绍及用法
java·windows·spring boot·python·spring·spring cloud·tomcat
迈火9 小时前
ComfyUI-3D-Pack:3D创作的AI神器
人工智能·gpt·3d·ai·stable diffusion·aigc·midjourney