(tensorflow) PS C:\WINDOWS\system32> pip install tensorflow-gpu==2.12.0 -i Usage: pip install [options] <requirement specifier> [package-index-options] ... pip install [options] -r <requirements file> [package-index-options] ... pip install [option
时间: 2025-03-10 12:10:01 浏览: 108
### 特定版本 TensorFlow-GPU 的安装
对于希望安装特定版本的 `tensorflow-gpu` 用户来说,需要注意自 2022 年 12 月起官方已经将 CPU 和 GPU 支持合并到了单一的 `tensorflow` 包中[^2]。因此,在此日期之后发布的版本不再区分单独的 `tensorflow-gpu` 包。
为了安装带有 GPU 支持的 TensorFlow 2.12.0 版本,应当执行如下命令:
```bash
pip install tensorflow==2.12.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
```
上述命令通过清华大学镜像源加速下载过程并确保获取指定版本的 TensorFlow 库文件。这一步骤同样适用于其他 Python 虚拟环境管理工具如 Conda 或者 Poetry 创建的环境中。
完成安装后可以运行下面的小段代码来验证是否成功启用了 GPU 加速功能:
```python
import tensorflow as tf
print("tf.__version__:", tf.__version__)
print("Available GPUs:", tf.config.list_physical_devices('GPU'))
```
这段脚本会打印当前使用的 TensorFlow 版本号以及检测到的物理 GPU 设备列表。如果一切正常,则意味着 TensorFlow 成功识别出了系统的 GPU 卡,并能够利用其硬件加速能力进行计算操作[^3]。
#### 验证安装情况
在某些情况下可能遇到依赖项冲突或者 CUDA/ cuDNN 不兼容等问题导致无法正常使用 GPU 功能。此时建议检查本地 NVIDIA 显卡驱动程序版本、CUDA Toolkit 及 cuDNN SDK 是否满足所选 TensorFlow 版本的要求规格表说明文档中的最低配置需求。
阅读全文
相关推荐

















