搜尋此網誌

顯示具有 tensorflow 標籤的文章。 顯示所有文章
顯示具有 tensorflow 標籤的文章。 顯示所有文章

2017年2月7日 星期二

tensorflow 安裝


安裝參考 Source

根據原文,日後如果新安裝高速顯卡,就要重新安裝 GPU 版

先安裝好 Python 2.7 環境

這次是在Ubuntu VM底下,並事先已經安裝好 Google Bazel
開始安裝 python 環境,sudo 指令最好是加 -H 參數:

sudo -H apt-get -y install python-pip python-dev
sudo -H pip install numpy
sudo -H pip install six
sudo -H pip install tensorflow


CPU 版
sudo -H pip install tensorflow

GPU 版則
sudo -H pip install tensorflow-gpu

# Ubuntu/Linux 64-bit, CPU only, Python 2.7 環境
export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.0.0rc1-cp27-none-linux_x86_64.whl



# Ubuntu/Linux 64-bit, GPU enabled, Python 2.7 環境
# 且還必須先安裝好 Requires CUDA toolkit 8.0 and CuDNN v5. 
export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.0.0rc1-cp27-none-linux_x86_64.whl


# Python 2 版
sudo -H pip install --upgrade $TF_BINARY_URL


測試是否安裝成功
python

出現 >>> 提示下:

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

會顯示 Hello, TensorFlow!

出現 >>> 提示下:
a = tf.constant(10)
b = tf.constant(32)
print(sess.run(a + b))
42

看到以上就是成功,不然 import tensorflow as tf 時候就已經報錯了。
輸入 exit() 離開


測試第一個 TensorFlow 類神經網路模型範例 neural net model

在 /home/user 目錄下,複製 models 倉庫一份
git clone https://github.com/tensorflow/models.git

完成後
cd ~/models/tutorials/image/mnist
執行
python convolutional.py

畫面看到以下輸出例子
Successfully downloaded train-images-idx3-ubyte.gz 9912422 bytes.
Successfully downloaded train-labels-idx1-ubyte.gz 28881 bytes.
Successfully downloaded t10k-images-idx3-ubyte.gz 1648877 bytes.
Successfully downloaded t10k-labels-idx1-ubyte.gz 4542 bytes.
Extracting data/train-images-idx3-ubyte.gz
Extracting data/train-labels-idx1-ubyte.gz
Extracting data/t10k-images-idx3-ubyte.gz
Extracting data/t10k-labels-idx1-ubyte.gz
Initialized!
Epoch 0.00
Minibatch loss: 12.054, learning rate: 0.010000
Minibatch error: 90.6%
Validation error: 84.6%
Epoch 0.12
Minibatch loss: 3.285, learning rate: 0.010000
Minibatch error: 6.2%
Validation error: 7.0%
...

...


- The End -



2017年2月6日 星期一

安裝 Google Bazel

這裡的 OS 是指 Ubuntu

1. 首要工作,檢查網路 DNS 機能是否正常
sudo -i
vi /etc/network/interfaces
dns-nameservers 168.95.1.1 139.175.1.1
/etc/init.d/networking restart

ping dns.hinet.net
exit

sudo apt-get update
sudo apt-get -y install openjdk-8-jre-headless


2. Add Bazel distribution URI as a package source (one time setup)
echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list
curl https://bazel.build/bazel-release.pub.gpg | sudo apt-key add -


3. Install and update Bazel
sudo apt-get update && sudo apt-get -y install bazel
sudo apt-get -y upgrade bazel

稍等下載與安裝更新即可

- The End -



搜尋此網誌