1.软件准备
- anaconda3 https://www.anaconda.com/products/individual
- visual studio2017社区版 https://visualstudio.microsoft.com/zh-hans/downloads/
- cuda11.1 https://developer.nvidia.com/cuda-10.0-download-archive
- cudnn ## 目前没有x64 ,需要登陆才能下载https://developer.nvidia.com/rdp/cudnn-archive
- 迅雷下载
血泪史,直接官网下载cuda和cudnn,速度慢的想死,等待了一天都没有下载下来,把下载链接复制到迅雷,不用会员半个小时下完
2.anaconda安装及cuda,cudnn安装请参考https://www.jianshu.com/p/915e6b3cdd29
3. 创建tensorflow-gpu环境
>>> conda info --env #查看已经安装的环境
>>> conda remove --name tsgpu --all #删除上一个安装错误的环境,或者不想要的环境
>>> conda create --name tensorgpu python=3.6
>>> conda activate tensorgpu
>>> conda install tensorflow-gpu==2.1.0
>>>python -m pip install --upgrade pip #更新pip,不然后续会报错
查看安装版本及路径
>>> tf.__version__
>>>tf.__path__
查看可用gpu个数
>>> import tensorflow as tf
>>> print("Num GPUs Available: ", len(tf.config.experimental.list_physical_devices('GPU')))
>>> import tensorflow as tf
>>> tf.compat.v1.disable_eager_execution()
>>> sess=tf.compat.v1.Session()
>>> hello=tf.constant("hello")
>>> print(sess.run(hello))
b'hello'
参考文章如下:
anaconda下安装tensorflow-gpu https://www.jianshu.com/p/915e6b3cdd29
Anaconda安装Tensorflow-gpu https://www.cnblogs.com/jshmztl/p/13306837.html