Tensorflow GPU 安装
conda 创建环境
python=3.10 版本
打开 anaconda powershell
激活环境
conda activate 环境名
输入指令
conda install -c conda-forge cudatoolkit=11.2 cudnn=8.1.0 -y
输入指令
pip install "tensorflow<2.11"
输入指令
pip install "numpy<2" --force-reinstall # 1.26.4
验证
import tensorflow as tf
print(f"TF Version: {tf.__version__}")
print(f"GPU Available: {tf.config.list_physical_devices('GPU')}")
print(f"CUDA Version: {tf.sysconfig.get_build_info()['cuda_version']}")
print(f"cuDNN Version: {tf.sysconfig.get_build_info()['cudnn_version']}")
预期输出:
TF Version: 2.10.1
GPU Available: [PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]
CUDA Version: 64_112
cuDNN Version: 64_8