TensorFlow GPU安装指南
创始人
2025-05-28 17:10:15

测试你当前的环境是否已经支持:

import tensorflow as tfif tf.test.gpu_device_name():print(f"Default GPU device: {tf.test.gpu_device_name()}")
else:print("GPU device not found. Please check your settings.")

如果正确配置了GPU,就有会有:

Default GPU device: /device:GPU:0

使用 pip 安装 TensorFlow

注意:TensorFlow 2.10 是最后一个 TensorFlow 版本。 原生 Windows 上支持的 GPU。 从TensorFlow 2.11 开始,您需要在 WSL2 中安装 TensorFlow, 或者安装 TensorFlow-cpu

默认已经按照好了: Miniconda

创建新的conda 环境

conda create --name tfGPU python=3.9

GPU 安装

先要安装 NVIDIA GPU 驱动,

然后用 conda 安装 CUDA, cuDNN

conda install -c conda-forge cudatoolkit=11.2 cudnn=8.1.0

安装TensorFlow

先升级 最新的 pip

pip install --upgrade pip

TensorFlow 2.10 是最后一个 TensorFlow 版本。 原生 Windows 上支持的 GPU。
所以安装2.11以前的版本


pip install "tensorflow<2.11" 

验证TensorFlow CPU的安装

python -c "import tensorflow as tf; print(tf.reduce_sum(tf.random.normal([1000, 1000])))"

输出 tensor 张量的数据,就是安装好了。

在这里插入图片描述

验证TensorFlow GPU的安装

python -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"

在这里插入图片描述

在这里插入图片描述

相关内容

热门资讯

瑞银发现:60%已开始控制AI... AI支出管理正在成为企业IT治理的新战场。随着AI Agent和代码工具的普及,Token账单正式进...
AI银行新探索:网商银行小微A... 6月25日,网商银行成立11周年之际宣布升级“生意金卡”,联合阿里云、芝麻企业信用、高德等生态伙伴,...
财报炸裂,盘后暴涨16%!美光... 美光科技用一份历史性财报,终结了市场对AI投资热潮能否持续的质疑。周三盘后,美光公布第三财季业绩,营...
实探|金属价格高位震荡,实体企... 今年以来,以铜、铝为代表的工业金属价格持续震荡,也牵动着诸多实体企业的利润表。近日,证券时报·券商中...
「还好去年买电脑,省下2000... 最近小R和我说了件有意思的事。他弟弟去年配了台电脑,最近来跟他显摆:同样的配置,放到今年要多花200...