Windows10 安装Tensorflow-gpu 2.10.0

1. GPU 版本选择

TensorFlow 2.10.0 是 Windows 本地支持 GPU 的最后一个版本。从 2.11.0 开始,Windows 系统需通过 WSL2 才能使用 GPU 。
GPU 和 CPU 版本在 2.x 中已合并,安装 tensorflow==2.10.0 后,若环境配置正确,会自动启用 GPU 。

2. CUDA 和 cuDNN 版本

推荐 CUDA 11.2.2 + cuDNN 8.1.1,具体需根据硬件和驱动选择:

1)下载 CUDA 11.2.2
cuda-toolkit 11.2.2(https://developer.nvidia.com/cuda-toolkit-archive)
在这里插入图片描述
cuda安装完之后,直接在cmd中查看

 nvcc -V

在这里插入图片描述

2)下载cudnn 8.1.1
cudnn 8.1.1(https://developer.nvidia.com/rdp/cudnn-archive)
在这里插入图片描述
把下载的cudnn 8.1.1压缩包解压,并复制至 CUDA 11.2文件夹下。
在这里插入图片描述

避免使用 CUDA 12.x。证据表明,即使安装 CUDA 12.3,TensorFlow 2.10.0 仍需依赖 CUDA 11.x 的底层库,可能导致兼容性问题 。

3. 安装步骤

1)创建虚拟环境(推荐使用 Conda):

 conda create -n tf python=3.10
 conda activate tf

2)安装 TensorFlow 2.10.0(使用清华镜像加速):

 pip install tensorflow==2.10.0 -i https://pypi.tuna.tsinghua.edu.cn/simple

3)安装TensorFlow-gpu 2.10.0(使用清华镜像加速):

 pip install tensorflow-gpu==2.10.0 -i https://pypi.tuna.tsinghua.edu.cn/simple/

4)验证 GPU 可用性:

 import tensorflow as tf

 print("TensorFlow version:",tf.__version__)
 print("Available devices:",tf.config.experimental.list_physical_devices())
 print("Num GPUs Available",tf.config.experimental.list_physical_devices('GPU'))

4. 常见问题

numpy 版本冲突若报错 TypeError: Unable to convert function return value…需降级 numpy 至 1.23.5

 pip uninstall numpy
 pip install numpy==1.23.5 -i https://pypi.tuna.tsinghua.edu.cn/simple

CUDA/cuDNN 路径配置:确保系统环境变量包含 CUDA 和 cuDNN 的安装路径(如 CUDA_PATH_V11_6 和 CUDNN_HOME)。

5. 其他注意事项

Windows 系统限制:若使用更高版本 TensorFlow(如 2.12.0),需通过 WSL2 安装 。
Python 版本兼容性:TensorFlow 2.10.0 支持 Python 3.7-3.10,建议使用 3.9 或 3.10 。
综上,TensorFlow 2.10.0 版本 和 GPU 版本推荐搭配 Python 3.10+CUDA 11.2 + cuDNN 8.1.1,并注意环境变量与依赖库的版本匹配。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值