在Anaconda3下安裝(CPU版)TensorFlow(清華鏡像源)


1、打開Anaconda Prompt

 2、搭建TensorFlow的環境:

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes
conda create -n tensorflow python=3.5

3、在用戶目錄下找到文件   .condarc

      環境搭建完成:

4、安裝(CPU)版的TensorFlow:     

// 啟動TensorFlow:
activate tensorflow

conda install tensorflow

5、測試TensorFlow是否安裝完成

     終端進入python:

     輸入:

import tensorflow as tf
hello = tf.constant("hello, tensorflow!")
sess = tf.Session()
print(sess.run(hello))

  輸出: b'hello, tensorflow!',即成功!!!

6、在Jupiter中使用TensorFlow

     准備工作:

  • 安裝ipython,安裝jupyter
  • conda install ipython
    conda install jupyter
  • 輸入:
    ipython kernelspec install-self --user
  •  看到類似這個結果    Installed kernelspec python3 in C:\Users\XXX\Jupyter\kernels\python3 即可以了!

    打開Anaconda Jupiter 稍等一會

復制網址,瀏覽器打開

 新建python3文件

   輸入:

import tensorflow as tf
tf.__version__

 輸出:

即安裝成功!

7、安裝成功后,每次使用 TensorFlow 的時候都需要激活 conda 環境

//查看環境
conda info --envs
//激活環境
activate tensorflow
//關閉環境
deactivate tensorflow


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM