安装Tensorflow-gpu最主要的问题有2个:
-
访问国外的anaconda网站太慢
-
经常出现cuda相关dll不对的情况
现在已经有了好的安装方法: -
安装anaconda。可以在镜像网站找到合适的安装包,我访问的是https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/,选择的安装包是Anaconda2-5.2.0-Windows-x86_64.exe(https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda2-5.2.0-Windows-x86_64.exe)
-
打开cmd窗口,创建环境。 conda create -n tensorflow-gpu python=3.6
-
激活建立的环境:conda activate tensorflow-gpu
-
输入以下命令:
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
conda config --set show_channel_urls yes
conda install tensorflow-gpu==2.1.0 -
安装需要比较长的时间,因为有几个超过100M的包。
-
安装成功后,可以输入python,并输入import tensorflow as tf 。如果没有出现报错,那么恭喜