美文网首页
TensorFlow 安装GPU版本

TensorFlow 安装GPU版本

作者: 偷了月光的猫 | 来源:发表于2018-12-12 10:58 被阅读21次

    TensorFlow 有两个版本:CPU 版本和 GPU 版本。GPU 版本需要 CUDA 和 cuDNN 的支持,CPU 版本不需要。如果你要安装 GPU 版本,请先确认你的显卡支持 CUDA。我安装的是 GPU 版本,采用 pip 安装方式,所以就以 GPU 安装为例,CPU 版本只不过不需要安装 CUDA 和 cuDNN。

    1. 确认你的显卡支持 CUDA

    打开网址找到对应的显卡:https://developer.nvidia.com/cuda-gpus

    确认显卡是否支持

    我这里是 GXT 1060

    2.下载并安装 Visual Studio ,因为CUDA需要Visual Studio的支持。

    下载地址:https://www.visualstudio.com/zh-hans/

    image.png

    安装选项:

    image.png

    3. 下载安装 CUDA Toolkit 9.0

    官网网址:https://developer.nvidia.com/cuda-90-download-archive?tdsourcetag=s_pctim_aiomsg

    下载:

    image.png

    安装:

    image.png

    4. 下载 cuDNN,并解压到目录,把对应的目录地址添加到path环境变量

    https://developer.nvidia.com/cudnn

    image.png

    下载 cuDNN必须需要一个账号,如果没有,注册一个新的账号,登录后才能下载。

    下载:

    image.png

    解压

    image.png

    添加到环境变量

    添加到环境变量

    5. 安装 Anaconda,因为这个集成了很多科学计算所必需的库,能够避免很多依赖问题

    image.png

    把 Anaconda安装目录 添加到环境变量

    image.png

    6. 使用 pip 安装 tensorflow GPU版本

    管理员身份打开cmd

    image.png

    输入:

    pip install --upgrade tensorflow-gpu -i https://pypi.tuna.tsinghua.edu.cn/simple

    -ihttps://pypi.tuna.tsinghua.edu.cn/simple:使用清华的镜像,飞一般的速度。

    7. 测试程序:

    importtensorflowastfa = tf.random_normal((100,100))b = tf.random_normal((100,500))c = tf.matmul(a, b)#矩阵相乘sess = tf.InteractiveSession()sess.run(c)

    执行结果

    出现以上结果,说明安装成功了。

    相关文章

      网友评论

          本文标题:TensorFlow 安装GPU版本

          本文链接:https://www.haomeiwen.com/subject/eopfzftx.html