zoukankan      html  css  js  c++  java
  • 安装WIN7/WIN10上的 CPU版本的TensorFlow

    随手记

    ancaconda Anaconda2-5.0.1-Windows-x86_64
    (python3.5 ancaconda python-3.5.2-amd64 安装TensorFlow的时候自动依赖安装)
    charmpython IDE

    1 安装 ancaconda
    访问Anaconda的下载页面,下载Python 3..6,选择64位版本。


    2 配置国内的源

    conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
    conda config --set show_channel_urls yes
    

      


    3 继续在 Anaconda Prompt 窗口输入:
    conda create -n tensorflow python=3.5

    activate tensorflow   输入 激活环境


    4 安装CPU版本的tensorflow

     pip install --ignore-installed --upgrade https://mirrors.tuna.tsinghua.edu.cn/tensorflow/windows/cpu/tensorflow-1.2.1-cp35-cp35m-win_amd64.whl


    你也可以打开 https://mirrors.tuna.tsinghua.edu.cn/tensorflow/ 选择合适的 whl 文件地址进行安装;或者打开https://mirrors.tuna.tsinghua.edu.cn/help/tensorflow/ 可视化选择 whl 版本。

    GPU

    【主要参考这篇 http://blog.csdn.net/jin739738709/article/details/73525482】

    安装

     pip install --ignore-installed --upgrade https://mirrors.tuna.tsinghua.edu.cn/tensorflow/windows/gpu/tensorflow_gpu-1.2.1-cp35-cp35m-win_amd64.whl

    下载对应的 

    1. 下载CUDA8.0并安装

    CUDA Toolkit 8.0 - Feb 2017

    https://developer.nvidia.com/cuda-80-ga2-download-archive

    [官网:https://developer.nvidia.com/rdp/cudnn-download]

    2.   cuDNN v7.0.5 

     Download cuDNN v7.0.5 (Dec 5, 2017), for CUDA 8.0

    https://developer.nvidia.com/rdp/cudnn-download

    [官网:https://developer.nvidia.com/cuda-downloads]

    打开你下载路径可以看到cuda文件夹下有三个子文件,分别为bin、include和lib

     设置到环境变量比如:

    E:cudnn-8.0-windows7-x64-v7cudain;E:cudnn-8.0-windows7-x64-v7cudainclude;E:cudnn-8.0-windows7-x64-v7cudalibx64;

    WIN10下的版本对应是

    CUDA Toolkit 8.0 - Feb 2017    配 cudnn-8.0-windows10-x64-v5.1 ,设定好环境变量后需要重启。


    5. activate tensorflow
    激活 TensorFlow 虚拟环境,当不使用 TensorFlow 时,使用 deactivate tensorflow 关闭。


    6. 测试
    进入到 Anaconda 安装目录下 /envs /tensorflow 文件夹,继续在 Anaconda Prompt 窗口输入输入:
    python.exe
    回车后,复制复制如下内容拷贝到Anaconda Prompt,自动输出:
    import tensorflow as tf
    hello = tf.constant('Hello, TensorFlow!')
    sess = tf.Session()
    >>> sess.run(hello)
    >>> a = tf.constant(10)
    >>> b= tf.constant(32)
    >>> sess.run(a+b)
    >>>
    输出:
    ...
    b'Hello, TensorFlow!'
    ...
    42

    表示 TensorFlow 已经安装成功。
    7.配置 charmpython
    启动的时候指定python路径即可,比如我这边是这个路径。“进入到 Anaconda 安装目录下 /envs /tensorflow 文件夹”

    其他

    1.  W c: f_jenkinshomeworkspace elease-windevicecpuoswindows ensorflowcoreplatformcpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE instructions, but these are available on your machine and could speed up CPU computations.

    因为预编译的问题,可百度看到。

    补【升级版本】

     出错处理

    参考这里代码确认是否哪些DLL没有设定对

     https://www.cnblogs.com/facingwaller/p/8614164.html


    1. 使用 upgrade

    • CPU:pip3 install –upgrade tensorflow
    • GPU:pip3 install –upgrade tensorflow-gpu

    2. 指定升级的版本(1.2.0)

    • CPU: pip install --ignore-installed --upgrade https://mirrors.tuna.tsinghua.edu.cn/tensorflow/windows/cpu/tensorflow-1.2.1-cp35-cp35m-win_amd64.whl
    • GPU:pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-1.2.0-cp35-cp35m-win_amd64.whl

    由上所示,python 的版本需要为 3.5。

    ---

    补充 安装jieba

    执行Anaconda2.exe

    输入

    activate tensorflow

    pip install jieba

    安装插件

    activate tensorflow_gpu_121

    pip install gensim

    pip install sklearn

    pip install matplotlib

    pip install pandas

  • 相关阅读:
    好的文章聚集地
    java连接mysql数据库8.0以上版本过程中遇到的坑
    Tomcat8.5安装与配置的坑
    用阿里fastJson解析Json字符串
    通过java代码HttpRequestUtil(服务器端)发送HTTP请求并解析
    Vue中美元$符号的意思
    java的jdk和jre区别
    java正则
    java8 四大核心函数式接口Function、Consumer、Supplier、Predicate(转载)
    SpringBoot:静态资源的访问和配置(转载)
  • 原文地址:https://www.cnblogs.com/facingwaller/p/7885638.html
Copyright © 2011-2022 走看看