Sunday, February 26, 2017

fatal: Unable to create 'C:/Users/izeye/IdeaProjects/test/.git/packed-refs.lock': File exists. error: failed to run pack-refs

If you encounter the following error in Windows:

fatal: Unable to create 'C:/Users/izeye/IdeaProjects/test/.git/packed-refs.lock': File exists. error: failed to run pack-refs

delete the file as follows:

del .git\packed-refs.lock

Wednesday, February 22, 2017

Check TensorFlow version

To check TensorFlow version, do as follows:

python -c "import tensorflow; print(tensorflow.__version__)"

Reference:
https://affinelayer.com/pix2pix/

pbcopy/pbpaste

In Mac OS, you can copy output of a command as follows:

ls | pbcopy

and paste the output as follows:

pbpaste

Wednesday, February 8, 2017

Run TensorBoard from source

To run TensorBoard from source, build it first as follows:

bazel build tensorflow/tensorboard:tensorboard

And then run it as follows:

./bazel-bin/tensorflow/tensorboard/tensorboard --logdir=/tmp/retrain_logs

Invalid argument: NodeDef mentions attr 'dct_method' not in Op<name=DecodeJpeg;

When you retrain with a sample (https://github.com/eldor4do/Tensorflow-Examples/blob/master/retraining-example.py), you might encounter the following error:

$ python retraining.py
E tensorflow/core/common_runtime/executor.cc:334] Executor failed to create kernel. Invalid argument: NodeDef mentions attr 'dct_method' not in Op<name=DecodeJpeg; signature=contents:string -> image:uint8; attr=channels:int,default=0; attr=ratio:int,default=1; attr=fancy_upscaling:bool,default=true; attr=try_recover_truncated:bool,default=false; attr=acceptable_fraction:float,default=1>; NodeDef: DecodeJpeg = DecodeJpeg[acceptable_fraction=1, channels=3, dct_method="", fancy_upscaling=true, ratio=1, try_recover_truncated=false, _device="/job:localhost/replica:0/task:0/cpu:0"](_recv_DecodeJpeg/contents_0)
         [[Node: DecodeJpeg = DecodeJpeg[acceptable_fraction=1, channels=3, dct_method="", fancy_upscaling=true, ratio=1, try_recover_truncated=false, _device="/job:localhost/replica:0/task:0/cpu:0"](_recv_DecodeJpeg/contents_0)]]
Traceback (most recent call last):
  File "retraining.py", line 48, in <module>
    answer = run_inference_on_image()
  File "retraining.py", line 26, in run_inference_on_image
    predictions = session.run(softmax_tensor, {'DecodeJpeg/contents:0': image_data})
  File "/Library/Python/2.7/site-packages/tensorflow/python/client/session.py", line 717, in run
    run_metadata_ptr)
  File "/Library/Python/2.7/site-packages/tensorflow/python/client/session.py", line 915, in _run
    feed_dict_string, options, run_metadata)
  File "/Library/Python/2.7/site-packages/tensorflow/python/client/session.py", line 965, in _do_run
    target_list, options, run_metadata)
  File "/Library/Python/2.7/site-packages/tensorflow/python/client/session.py", line 985, in _do_call
    raise type(e)(node_def, op, message)
tensorflow.python.framework.errors.InvalidArgumentError: NodeDef mentions attr 'dct_method' not in Op<name=DecodeJpeg; signature=contents:string -> image:uint8; attr=channels:int,default=0; attr=ratio:int,default=1; attr=fancy_upscaling:bool,default=true; attr=try_recover_truncated:bool,default=false; attr=acceptable_fraction:float,default=1>; NodeDef: DecodeJpeg = DecodeJpeg[acceptable_fraction=1, channels=3, dct_method="", fancy_upscaling=true, ratio=1, try_recover_truncated=false, _device="/job:localhost/replica:0/task:0/cpu:0"](_recv_DecodeJpeg/contents_0)
         [[Node: DecodeJpeg = DecodeJpeg[acceptable_fraction=1, channels=3, dct_method="", fancy_upscaling=true, ratio=1, try_recover_truncated=false, _device="/job:localhost/replica:0/task:0/cpu:0"](_recv_DecodeJpeg/contents_0)]]
Caused by op u'DecodeJpeg', defined at:
  File "retraining.py", line 48, in <module>
    answer = run_inference_on_image()
  File "retraining.py", line 22, in run_inference_on_image
    create_graph()
  File "retraining.py", line 13, in create_graph
    tf.import_graph_def(graph_def, name='')
  File "/Library/Python/2.7/site-packages/tensorflow/python/framework/importer.py", line 279, in import_graph_def
    op_def=op_def)
  File "/Library/Python/2.7/site-packages/tensorflow/python/framework/ops.py", line 2380, in create_op
    original_op=self._default_original_op, op_def=op_def)
  File "/Library/Python/2.7/site-packages/tensorflow/python/framework/ops.py", line 1298, in __init__
    self._traceback = _extract_stack()

Deleting the attribute as follows solves the problem:

        graph_def.ParseFromString(f.read())
        del(graph_def.node[1].attr["dct_method"])
        tf.import_graph_def(graph_def, name='')

Reference:
http://stackoverflow.com/questions/41258012/tensorflow-inception-v3-image-retrain-unable-to-test-on-new-jpg-image

Thursday, February 2, 2017

Current Bazel version is 0.3.1, expected at least 0.4.2

When './configure' TensorFlow, you might encounter the following error:

Johnnyui-MacBook-Pro:tensorflow izeye$ ./configure
...
Current Bazel version is 0.3.1, expected at least 0.4.2
...
Johnnyui-MacBook-Pro:tensorflow izeye$

Check your bazel version as follows:

Johnnyui-MacBook-Pro:tensorflow izeye$ brew info bazel
bazel: stable 0.3.1 (bottled), HEAD
Google's own build tool
https://www.bazel.io/
/usr/local/Cellar/bazel/0.1.2 (659 files, 148.9M)
  Poured from bottle on 2016-03-10 at 21:19:46
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/bazel.rb
==> Requirements
Required: java >= 1.8 ✔, macOS >= 10.10 ✔
Johnnyui-MacBook-Pro:tensorflow izeye$

Uninstall your bazel as follows:

Johnnyui-MacBook-Pro:tensorflow izeye$ brew uninstall bazel
Uninstalling /usr/local/Cellar/bazel/0.3.1... (9 files, 94.5M)
bazel 0.1.2 is still installed.
Remove all versions with `brew uninstall --force bazel`.
Johnnyui-MacBook-Pro:tensorflow izeye$ brew uninstall --force bazel
Uninstalling bazel... (659 files, 148.9M)
Johnnyui-MacBook-Pro:tensorflow izeye$

Install the latest version of bazel as follows:

Johnnyui-MacBook-Pro:tensorflow izeye$ brew install bazel
...
Johnnyui-MacBook-Pro:tensorflow izeye$ brew link --overwrite bazel
Linking /usr/local/Cellar/bazel/0.4.4... 4 symlinks created
Johnnyui-MacBook-Pro:tensorflow izeye$

Check your bazel version again as follows:

Johnnyui-MacBook-Pro:tensorflow izeye$ brew info bazel
bazel: stable 0.4.4 (bottled)
Google's own build tool
https://bazel.build/
/usr/local/Cellar/bazel/0.4.4 (10 files, 155.1M) *
  Poured from bottle on 2017-02-03 at 00:34:39
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/bazel.rb
==> Requirements
Required: java >= 1.8 ✔, macOS >= 10.10 ✔
==> Caveats
Bash completion has been installed to:
  /usr/local/etc/bash_completion.d

zsh completion has been installed to:
  /usr/local/share/zsh/site-functions
Johnnyui-MacBook-Pro:tensorflow izeye$

Check your bazel version via 'bazel' as follows:

Johnnyui-MacBook-Pro:tensorflow izeye$ bazel version
Build label: 0.4.4-homebrew
Build target: bazel-out/local-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Thu Feb 2 01:06:38 2017 (1485997598)
Build timestamp: 1485997598
Build timestamp as int: 1485997598
Johnnyui-MacBook-Pro:tensorflow izeye$

Edit:

'brew upgrade' works in another machine although I don't know why it didn't work before in the above machine:

brew upgrade bazel

Check AVX in Mac

To check AVX (Advanced Vector Extensions) in Mac, do as follows:

Johnnyui-MacBook-Pro:~ izeye$ sysctl -a | grep AVX
machdep.cpu.features: FPU VME DE PSE TSC MSR PAE MCE CX8 APIC SEP MTRR PGE MCA CMOV PAT PSE36 CLFSH DS ACPI MMX FXSR SSE SSE2 SS HTT TM PBE SSE3 PCLMULQDQ DTES64 MON DSCPL VMX EST TM2 SSSE3 CX16 TPR PDCM SSE4.1 SSE4.2 x2APIC POPCNT AES PCID XSAVE OSXSAVE TSCTMR AVX1.0 RDRAND F16C
Johnnyui-MacBook-Pro:~ izeye$

You can see 'AVX1.0' there.

References:
https://en.wikipedia.org/wiki/Advanced_Vector_Extensions
http://csharpmulticore.blogspot.kr/2014/12/how-to-check-intel-avx2-support-on-mac-os-x-haswell.html