Transitioning to TensorFlow 1.0


TensorFlow 1.0 부터는 모든 backwards compatible을 지원하지 않는다.
깔끔한 1.N lifesycle을 위해서 이러한 작업을 수행 한다.

upgrade

$ sudo pip3 install --upgrade TF_BINARY_URL # Python 3.N

https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.0.0-cp35-cp35m-linux_x86_64.whl

Collecting tensorflow-gpu==1.0.0 from https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.0.0-cp35-cp35m-linux_x86_64.whl
  Downloading https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.0.0-cp35-cp35m-linux_x86_64.whl (95.0MB)
    100% |████████████████████████████████| 95.0MB 25kB/s
Requirement already up-to-date: six>=1.10.0 in ./.local/lib/python3.5/site-packages (from tensorflow-gpu==1.0.0)
Requirement already up-to-date: numpy>=1.11.0 in ./.local/lib/python3.5/site-packages (from tensorflow-gpu==1.0.0)
Requirement already up-to-date: wheel>=0.26 in ./.local/lib/python3.5/site-packages (from tensorflow-gpu==1.0.0)
Collecting protobuf>=3.1.0 (from tensorflow-gpu==1.0.0)
  Downloading protobuf-3.2.0-cp35-cp35m-manylinux1_x86_64.whl (5.6MB)
    100% |████████████████████████████████| 5.6MB 392kB/s
Collecting setuptools (from protobuf>=3.1.0->tensorflow-gpu==1.0.0)
  Downloading setuptools-34.3.0-py2.py3-none-any.whl (389kB)
    100% |████████████████████████████████| 399kB 2.4MB/s
Collecting appdirs>=1.4.0 (from setuptools->protobuf>=3.1.0->tensorflow-gpu==1.0.0)
  Downloading appdirs-1.4.2-py2.py3-none-any.whl
Collecting packaging>=16.8 (from setuptools->protobuf>=3.1.0->tensorflow-gpu==1.0.0)
  Downloading packaging-16.8-py2.py3-none-any.whl
Requirement already up-to-date: pyparsing in ./.local/lib/python3.5/site-packages (from packaging>=16.8->setuptools->protobuf>=3.1.0->tensorflow-gpu==1.0.0)
Installing collected packages: appdirs, packaging, setuptools, protobuf, tensorflow-gpu
  Found existing installation: setuptools 32.3.1
    Uninstalling setuptools-32.3.1:
      Successfully uninstalled setuptools-32.3.1
  Found existing installation: protobuf 3.1.0.post1
    Uninstalling protobuf-3.1.0.post1:
      Successfully uninstalled protobuf-3.1.0.post1
  Found existing installation: tensorflow-gpu 0.12.1
    Uninstalling tensorflow-gpu-0.12.1:
      Successfully uninstalled tensorflow-gpu-0.12.1
Successfully installed appdirs-1.4.2 packaging-16.8 protobuf-3.2.0 setuptools-34.3.0 tensorflow-gpu-1.0.0

버전 확인

jemin@jemin-desktop:~$ python3
Python 3.5.2 (default, Nov 17 2016, 17:05:23)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> import tensorflow as tf
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcublas.so.8.0 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcudnn.so.5 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcufft.so.8.0 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcurand.so.8.0 locally
>>> tf.__version__
'1.0.0'

Code-Upgrade

아래와 같이 Google에서 제공하는 python코드를 이용해서 업그레이드 할 수 있다.

다운로드: link

To convert a single 0,n TensorFlow source file to 1.0, enter a command of the following format:

python tf_upgrade.py --infile InputFile --outfile OutputFile

출력 결과로 report.txt도 나오게 된다. 이것은 상세한 결과와 추가적으로 수작업 해야할 부분을 알려 준다.

디렉터리에 있는 모든것을 업데이트 하기위해서는 아래의 명령어를 사용 한다.

python tf_upgrade.py --intree InputDir --outtree OutputDir

실행하면 아래와 같이 정상적으로 잘 동작하는 것을 알 수 있다.

jemin@jemin-desktop:~/ESLAB_ML/jemin$ python ~/tensorflow_source/tensorflow/tensorflow/tools/compatibility/tf_upgrade.py --intree ./TensorFlowLecture --outtree ./TensorFlowLecture_1.0
TensorFlow 1.0 Upgrade Script
-----------------------------
Converted 33 files

Detected 0 errors that require attention
--------------------------------------------------------------------------------

Make sure to read the detailed log 'report.txt'


+ Recent posts