搜尋此網誌

2017年2月9日 星期四

vSphere 環境下 UBuntu 網卡

在 vSphere 環境下 ,當 UBuntu 找不到網卡時後,可以輸入
ifconfig -a

系統會顯示 網卡名稱,例如: ens192
編輯  vi /etc/network/interface

固定IP 方式 如以下:
# The primary network interface
auto ens192
#iface ens192 inet dhcp

iface ens192 inet static
address 192.168.103.105
netmask 255.255.0.0
gateway 192.168.1.254

dns-nameservers 192.168.1.100 139.175.1.1 168.95.1.1 8.8.8.8 8.8.4.4

儲存離開
輸入
/etc/init.d/networking restart

查看網路是否恢復啟用

- The End -
 




vSphere 上使用 VMware Workstation 建立的 vmdk

SSH 連至 ESXi server
轉換 vmdk,進入 vm folder 裡面
cd /vmfs/volumes/datastore/vm-folder

以下三選一
固定大小: vmkfstools -i vm.vmdk -d zeroedthick vm_forESXi.vmdk 
固定大小: vmkfstools -i vm.vmdk -d eagerzeroedthick vm_forESXi.vmdk
自動延伸: vmkfstools -i vm.vmdk -d thin vm_forESXi.vmdk 


- The End -

2017年2月8日 星期三

Ubuntu 捨棄 /etc/resolv.conf

Ubuntu 於 12.04 之後捨棄 /etc/resolv.conf 的設計,每次開機皆會重置此檔案內容。

現在必須編輯 sudo vi /etc/network/interfaces
加入
dns-nameservers 8.8.8.8 8.8.4.4

- The End -



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日 星期一

防止 Shell Script 重複執行

防止 Shell Script 重複執行
參考

忘記 CentOS7 root 密碼

CentOS7 的步驟跟以往版本不同:

1. CentOS啟動時的GRUB畫面按下e鍵

2. 選擇第二個kernel /vmliz ...選項並按下e鍵進入編輯

3. 在參數最後增加 init=/bin/sh 再按下Enter鍵

4. 按 Ctrl + X 進入Single模式

5. mount -o remount,rw /

6. passwd root  改 root 密碼

7. touch /.autorelabel

8. exec /sbin/init

9. 成功啟動之後,再 REBOOT 重新啟動系統

安裝 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 -



搜尋此網誌