从tensorflow的官网可以看到是没有CUDA11.1对应的CUDA版本的:
因此,直接安装tensorflow==2.6.0试一下(这里我的python=3.8):
pip install tensorflow-gpu==2.6.0 -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
推荐使用豆瓣源。
测试tensorflow是否安装成功时报错:
python
import tensorflow as tf
解决:安装低版本的protoc:
pip uninstall protoc
pip install protoc==3.19.6 -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
然后测试成功安装:
python
import tensorflow as tf
tf.__version__
tf.test.is_gpu_available()
tf.config.list_physical_devices('GPU')
输出如下: