MacOSX 安裝 TensorFlow

TensorFlow是一個端到端開源機器學習平臺。它擁有一個包含各類工具、庫和社區資源的全面靈活生態系統,能夠讓研究人員推進機器學習領域的先進技術的。python

準備

安裝 Anaconda

TensorFlow 安裝的前提是系統安裝了 Python 2.5 或更高版本,教程中的例子是以 Python 3.6(Anaconda 3 版)爲基礎設計的。爲了安裝 TensorFlow,首先確保你已經安裝了 Anaconda。能夠從網址(https://www.anaconda.com/distribution/#download-section)中下載並安裝適用於 Windows/macOS 或 Linux 的 Anaconda。程序員

這個是macos的鏈接,一個是命令行的,一個是GUI的macos

https://repo.anaconda.com/archive/Anaconda3-2019.10-MacOSX-x86_64.shapi

https://repo.anaconda.com/archive/Anaconda3-2019.10-MacOSX-x86_64.pkgbash

關於安裝 anaconda, 能夠參考官方的文檔。機器學習

>https://docs.anaconda.com/anaconda/install/

配置 Anaconda

執行這個命令source ~/.bash_profile, 其實查看這個文件.bash_profile,關鍵的信息export PATH="/opt/anaconda3/bin:$PATH",就是配置anaconda的環境變量。
而後執行conda -V工具

(base) ➜ OpenSource conda -V
conda 4.7.12學習

安裝

配置 pip 源

這一步能夠省略,可是配置爲國內的源以後,速度快的飛起來。
sudo vi /Users/username/Library/Application\ Support/pip/pip.conf,而後修改裏面的內容爲下面的源。google

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple/
[install]
trusted-host=pypi.tuna.tsinghua.edu.cn

保存退出便可。url

安裝

當前版本只支持 CPU

pip install https://storage.googleapis.com/tensorflow/mac/tensorflow-0.5.0-py2-none-any.whl\
或者乾脆直接用pip install tensorflow同樣的。

Hello TensorFlow

這是第一個程序

import tensorflow as tf

hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))

# Hello, TensorFlow!

若是你感興趣能夠關注公衆號「chasays」- 程序員匯聚地
在這裏插入圖片描述

相關文章
相關標籤/搜索