- name: include different playbook based on different os
include: "{{ ansible_os_family | lower }}.yml"
Friday, October 28, 2016
Deep Learning : Tensorflow installation on MacOS
https://github.com/tensorflow/tensorflow/blob/master/tensorflow/g3doc/get_started/os_setup.md#on-macosx-
Operation not permitted
If, despite using
sudo, you encounter an error like:...
Installing collected packages: setuptools, protobuf, wheel, numpy, tensorflow
Found existing installation: setuptools 1.1.6
Uninstalling setuptools-1.1.6:
Exception:
...
[Errno 1] Operation not permitted: '/tmp/pip-a1DXRT-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib'
Solution: Add an
--ignore-installed flag to the pip command.
sudo easy_install pip
export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.11.0rc1-py2-none-any.whl
sudo pip install --upgrade $TF_BINARY_URL --ignore-installed
$ python
Python 2.7.10 (default, Oct 23 2015, 19:19:21)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
RuntimeError: module compiled against API version 0xa but this version of numpy is 0x9
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/tensorflow/__init__.py", line 23, in <module>
from tensorflow.python import *
File "/Library/Python/2.7/site-packages/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "/Library/Python/2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 28, in <module>
_pywrap_tensorflow = swig_import_helper()
File "/Library/Python/2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow', fp, pathname, description)
ImportError: numpy.core.multiarray failed to import
>>>
Python 3
brew install python3
$ sudo easy_install numpy
Password:
Searching for numpy
Best match: numpy 1.11.2
Adding numpy 1.11.2 to easy-install.pth file
Using /Library/Python/2.7/site-packages
Processing dependencies for numpy
Finished processing dependencies for numpy
Jungshihs-MacBook-Pro-2:~ lo$ python
Python 2.7.10 (default, Oct 23 2015, 19:19:21)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
>>>
Python 3
brew install python3
# Mac OS X, CPU only, Python 3.4 or 3.5:
$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.11.0rc2-py3-none-any.whl
sudo pip3 install --upgrade $TF_BINARY_URL
Collecting tensorflow==0.11.0rc2 from https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.11.0rc2-py3-none-any.whl
Downloading https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.11.0rc2-py3-none-any.whl (35.5MB)
100% |████████████████████████████████| 35.5MB 38kB/s
Collecting numpy>=1.11.0 (from tensorflow==0.11.0rc2)
Downloading numpy-1.11.2-cp35-cp35m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (3.9MB)
100% |████████████████████████████████| 3.9MB 296kB/s
Collecting six>=1.10.0 (from tensorflow==0.11.0rc2)
Downloading six-1.10.0-py2.py3-none-any.whl
Collecting protobuf==3.0.0 (from tensorflow==0.11.0rc2)
Downloading protobuf-3.0.0-py2.py3-none-any.whl (342kB)
100% |████████████████████████████████| 348kB 1.8MB/s
Collecting wheel>=0.26 (from tensorflow==0.11.0rc2)
Downloading wheel-0.29.0-py2.py3-none-any.whl (66kB)
100% |████████████████████████████████| 71kB 1.0MB/s
Collecting setuptools (from protobuf==3.0.0->tensorflow==0.11.0rc2)
Downloading setuptools-28.8.0-py2.py3-none-any.whl (472kB)
100% |████████████████████████████████| 481kB 1.6MB/s
Installing collected packages: numpy, six, setuptools, protobuf, wheel, tensorflow
Found existing installation: setuptools 20.10.1
Uninstalling setuptools-20.10.1:
Successfully uninstalled setuptools-20.10.1
Successfully installed numpy-1.11.2 protobuf-3.0.0 setuptools-28.8.0 six-1.10.0 tensorflow-0.11.0rc2 wheel-0.29.0
You are using pip version 8.1.1, however version 9.0.0 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Jungshihs-MacBook-Pro-2:~ lo$ python3
Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 26 2016, 10:47:25)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
>>>
git clone -b r0.11 https://github.com/tensorflow/tensorflow.git
cd tensorflow/tensorflow/examples/tutorials/mnist
modify input_data.py
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets('MNIST_data', one_hot=True)
$ python3 mnist_softmax.py --data_dir MNIST_data
Extracting MNIST_data/train-images-idx3-ubyte.gz
Extracting MNIST_data/train-labels-idx1-ubyte.gz
Extracting MNIST_data/t10k-images-idx3-ubyte.gz
Extracting MNIST_data/t10k-labels-idx1-ubyte.gz
0.9179
Thursday, October 27, 2016
Git : create new branch
https://github.com/Kunena/Kunena-Forum/wiki
https://github.com/Kunena/Kunena-Forum/wiki/Create-a-new-branch-with-git-and-manage-branches
https://github.com/Kunena/Kunena-Forum/wiki/Create-a-new-branch-with-git-and-manage-branches
Create the branch on your local machine and switch in this branch :
$ git checkout -b [name_of_your_new_branch]
Push the branch on github :
$ git push origin [name_of_your_new_branch]
Wednesday, October 26, 2016
MacOS : Homebrew
Issue:
/usr/local/Library/Homebrew/cmd/update.sh: line 13: /usr/local/Library/ENV/scm/git: No such file or directory
Error: update-report should not be called directly!
Solution:
$ cd "$(brew --repository)" && git fetch && git reset --hard origin/master
HEAD is now at 4284b82 Merge pull request #1380 from woodruffw/silence-git
Friday, October 21, 2016
Ansible : template with different set of variables
http://stackoverflow.com/questions/31142369/how-to-use-template-module-with-different-set-of-variables
Ansible : Switch a user per task
http://stackoverflow.com/questions/21344777/how-to-switch-a-user-per-task-or-set-of-tasks
http://stackoverflow.com/questions/37200337/is-there-anyway-to-run-multiple-ansible-playbooks-as-multiple-users-more-efficie/
http://stackoverflow.com/questions/37200337/is-there-anyway-to-run-multiple-ansible-playbooks-as-multiple-users-more-efficie/
Ansible uses the
become, become_user, and become_method directives to achieve privilege escalation. You can apply them to an entire play or playbook, set them in an included playbook, or set them for a particular task.- name: checkout repo
git: repo=https://github.com/some/repo.git version=master dest={{ dst }}
become: yes
become_user: some_user
You can set the become options per:
- playbook
- role
- task
Per playbook:
- hosts: whatever
become: yes
become_user: my_username
roles:
- checkout_sources
- install_dependencies
- make_dirs
Per role:
- hosts: whatever
roles:
- checkout_sources
- role: install_dependencies
become: yes
become_user: my_username
- make_dirs
Per task:
- shell: do something
become: yes
become_user: my_username
You can combine this however you like. The playbook can run as user A, a role as user B and finally a task inside the role as user C.
Ansible : tuning SSH timeout
Issue: Sometime we need extra wait time for Ansible host to establish SSH connection with target client
msg: Timeout (12s) waiting for privilege escalation prompt
Solution:
Modify /etc/ansible/ansible.cfg
By Default SSH timeout is set to 10 sec and python module will add 2 more seconds
timeout = 10
msg: Timeout (12s) waiting for privilege escalation prompt
Solution:
Modify /etc/ansible/ansible.cfg
By Default SSH timeout is set to 10 sec and python module will add 2 more seconds
timeout = 10
Subscribe to:
Posts (Atom)