$ ./configure You have bazel 3.7.2 installed. Please specify the location of python. [Default is /Users/qkboo/.pyenv/versions/tf2_build/bin/python3]:
Found possible Python library paths: /Users/qkboo/.pyenv/versions/tf2_build/lib/python3.8/site-packages Please input the desired Python library path to use. Default is [/Users/qkboo/.pyenv/versions/tf2_build/lib/python3.8/site-packages]
Do you wish to build TensorFlow with OpenCL SYCL support? [y/N]: n No OpenCL SYCL support will be enabled for TensorFlow.
Do you wish to build TensorFlow with ROCm support? [y/N]: n No ROCm support will be enabled for TensorFlow.
Do you wish to build TensorFlow with CUDA support? [y/N]: n No CUDA support will be enabled for TensorFlow.
Do you wish to download a fresh release of clang? (Experimental) [y/N]: n Clang will not be downloaded.
Please specify optimization flags to use during compilation when bazel option "--config=opt" is specified [Default is -march=native -Wno-sign-compare]:
Would you like to interactively configure ./WORKSPACE for Android builds? [y/N]: n Not configuring the WORKSPACE for Android builds.
Do you wish to build TensorFlow with iOS support? [y/N]: y iOS support will be enabled for TensorFlow.
Preconfigured Bazel build configs. You can use any of the below by adding "--config=<>" to your build command. See .bazelrc for more details. --config=mkl # Build with MKL support. --config=monolithic # Config for mostly static monolithic build. --config=ngraph # Build with Intel nGraph support. --config=numa # Build with NUMA support. --config=dynamic_kernels # (Experimental) Build kernels into separate shared objects. --config=v2 # Build TensorFlow 2.x instead of 1.x. Preconfigured Bazel build configs to DISABLE default on features: --config=noaws # Disable AWS S3 filesystem support. --config=nogcp # Disable GCP support. --config=nohdfs # Disable HDFS support. --config=nonccl # Disable NVIDIA NCCL support. Configuration finished
빌드 시작
Intel 기반의 macOS에서 기본 배포되는 tensorflow@2.0 을 설치하고 tensorflow 를 실행하면,
1 2 3 4 5 6 7 8 9 10 11
(tf2_p37)~$ python Python 3.7.9 (default, Aug 31 2020, 07:22:35) [Clang 10.0.0 ] :: Anaconda, Inc. on darwin Type "help", "copyright", "credits" or "license"for more information. >>> import tensorflow as tf >>> >>> tf.add(1,2).numpy() 2021-02-01 14:11:37.000601: I tensorflow/core/platform/cpu_feature_guard.cc:145] This TensorFlow binary is optimized with Intel(R) MKL-DNN to use the following CPU instructions in performance critical operations: SSE4.1 SSE4.2 AVX AVX2 FMA To enable them in non-MKL-DNN operations, rebuild TensorFlow with the appropriate compiler flags. 2021-02-01 14:11:37.001166: I tensorflow/core/common_runtime/process_util.cc:115] Creating new thread pool with default inter op setting: 8. Tune using inter_op_parallelism_threads for best performance. 3
특화 명령 을 –copt 부분에 명시해서 빌드한다.
bazel build: Intel CPU 특화 명령 세트
빌드할 때 아래와 같이 cpu option을 추가로주면 해당 cpu에 대해 최적화된 빌드로 진행됩니다. 아래의 copt 들은 머신마다 다르며, tensorflow warning을 보고 적절히 추가해주면 됩니다.
$ ./configure You have bazel 3.7.2 installed. Please specify the location of python. [Default is /Users/qkboo/.pyenv/versions/miniconda3-latest/bin/python3]: /Users/qkboo/.pyenv/versions/tf2_p38/bin/python
Found possible Python library paths: /Users/qkboo/.pyenv/versions/tf2_p38/lib/python3.8/site-packages Please input the desired Python library path to use. Default is [/Users/qkboo/.pyenv/versions/tf2_p38/lib/python3.8/site-packages]
Do you wish to build TensorFlow with ROCm support? [y/N]: n No ROCm support will be enabled for TensorFlow.
Do you wish to build TensorFlow with CUDA support? [y/N]: n No CUDA support will be enabled for TensorFlow.
Do you wish to download a fresh release of clang? (Experimental) [y/N]: n Clang will not be downloaded.
Please specify optimization flags to use during compilation when bazel option "--config=opt" is specified [Default is -Wno-sign-compare]:
Would you like to interactively configure ./WORKSPACE for Android builds? [y/N]: n Not configuring the WORKSPACE for Android builds.
Do you wish to build TensorFlow with iOS support? [y/N]: y iOS support will be enabled for TensorFlow.
Preconfigured Bazel build configs. You can use any of the below by adding "--config=<>" to your build command. See .bazelrc for more details. --config=mkl # Build with MKL support. --config=mkl_aarch64 # Build with oneDNN support for Aarch64. --config=monolithic # Config for mostly static monolithic build. --config=ngraph # Build with Intel nGraph support. --config=numa # Build with NUMA support. --config=dynamic_kernels # (Experimental) Build kernels into separate shared objects. --config=v2 # Build TensorFlow 2.x instead of 1.x. Preconfigured Bazel build configs to DISABLE default on features: --config=noaws # Disable AWS S3 filesystem support. --config=nogcp # Disable GCP support. --config=nohdfs # Disable HDFS support. --config=nonccl # Disable NVIDIA NCCL support. Configuration finished
>>> t = tf.constant('logcg') 2020-01-18 20:04:43.088104: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x7fefdc983db0 initialized for platform Host (this does not guarantee that XLA will be used). Devices: 2020-01-18 20:04:43.088134: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (0): Host, Default Version
(cv3python3) ~/$ python Python 3.4.2 (default, Oct 19 2014, 13:31:11) [GCC 4.9.1] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import cv2 >>> cv2.__version__ '3.1.0' >>>
$ python Python 3.4.2 (default, Oct 19 2014, 13:31:11) [GCC 4.9.1] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import cv2 >>> cv2.__version__ '3.1.0' >>>
시스템에서 파이썬이 두 개 이상 설치되어 있으면 일반적을 Python2.7 버전이 기본 파아썬 이다.
1 2 3 4 5 6 7 8
$ python3 Python 3.4.2 (default, Oct 19 2014, 13:31:11) [GCC 4.9.1] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import cv2 >>> cv2.__version__ '3.1.0-dev' >>>