TensorFlow 2.10 是最后一个支持在原生Windows上使用GPU的TensorFlow版本
注意:TensorFlow 2.10 是最后一个支持在原生Windows上使用GPU的TensorFlow版本。从TensorFlow 2.11开始,您需要在WSL2中安装TensorFlow,或者安装tensorflow或tensorflow-cpu,并且可选地尝试TensorFlow-DirectML插件
conda install -c conda-forge cudatoolkit=11.2 cudnn=8.1.0
# Anything above 2.10 is not supported on the GPU on Windows Native
python -m pip install "tensorflow<2.11"
# Verify the installation:
python -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"
pip install tensorflow==2.10 -i https://pypi.tuna.tsinghua.edu.cn/simple
conda install -c conda-forge cudatoolkit=11.2 cudnn=8.1.0
注意用这个命令的话cuda版本大于等于11.2
conda install cudatoolkit=11.2 cudnn=8.1.0
conda install cudatoolkit=11.3 cudnn=8.2.1
import tensorflow as tf
version=tf.__version__ #输出tensorflow版本
gpu_ok=tf.test.is_gpu_available() #输出gpu可否使用(True/False)
print("tf version:",version,"\nuse GPU:",gpu_ok)