網頁

2019年5月3日 星期五

Mac install tensorflow-1.9.0+Keras

官方版的安裝對Mac有許多限制,如果不想利用虛擬環境跑TensorFlow的話,以下是安裝流程。

Mac安裝tensorFlow必須要注意Python跟Bazel版本,而且新版Mac顯卡都是AMD,所以不支援GPU,所以安裝前必須注意下面的軟體需求。




$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
$ export PATH="/usr/local/bin:/usr/local/sbin:$PATH"
$ brew install python@3

切換Python版本
$ brew unlink python
安裝3.6.5
$ brew install --ignore-dependencies https://raw.githubusercontent.com/Homebrew/homebrew-core/f2a764ef944b1080be64bd88dca9a1d80130c558/Formula/python.rb
$ brew switch python 3.7.3
$ brew switch python 3.6.5_1

$ pip install -U --user pip six numpy wheel setuptools mock
$ pip install -U --user keras_applications==1.0.6 --no-deps
$ pip install -U --user keras_preprocessing==1.0.5 --no-deps

$ sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
$ sudo xcodebuild -license accept

https://github.com/bazelbuild/bazel/releases下載0.19.2
$ chmod +x bazel-0.19.2-installer-darwin-x86_64.sh
$ ./bazel-0.19.2-installer-darwin-x86_64.sh

$ git clone https://github.com/tensorflow/tensorflow.git
$ cd tensorflow

$ git checkout r1.9

$ ./configure

WARNING: The following rc files are no longer being read, please transfer their contents or import their path into one of the standard rc files:
/Users/yangyan-ling/tensorflow/tools/bazel.rc
WARNING: --batch mode is deprecated. Please instead explicitly shut down your Bazel server using the command "bazel shutdown".
You have bazel 0.19.2 installed.
Please specify the location of python. [Default is /usr/local/opt/python@2/bin/python2.7]: /usr/local/bin/python3
(配合利用Homebrew安裝的RDKit其python3呼叫位址)

Found possible Python library paths:
  /usr/local/Cellar/python/3.6.5_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
Please input the desired Python library path to use.  Default is [/usr/local/Cellar/python/3.6.5_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages]

Do you wish to build TensorFlow with Google Cloud Platform support? [Y/n]: n
No Google Cloud Platform support will be enabled for TensorFlow.

Do you wish to build TensorFlow with Hadoop File System support? [Y/n]: n
No Hadoop File System support will be enabled for TensorFlow.

Do you wish to build TensorFlow with Amazon S3 File System support? [Y/n]: n
No Amazon S3 File System support will be enabled for TensorFlow.

Do you wish to build TensorFlow with Apache Kafka Platform support? [Y/n]: n
No Apache Kafka Platform support will be enabled for TensorFlow.

Do you wish to build TensorFlow with XLA JIT support? [y/N]: n
No XLA JIT support will be enabled for TensorFlow.

Do you wish to build TensorFlow with GDR support? [y/N]: n
No GDR support will be enabled for TensorFlow.

Do you wish to build TensorFlow with VERBS support? [y/N]: n
No VERBS support will be enabled for TensorFlow.

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 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.

Do you wish to build TensorFlow with MPI support? [y/N]: n
No MPI support will be enabled for TensorFlow.

Please specify optimization flags to use during compilation when bazel option "--config=opt" is specified [Default is -march=native]:


Would you like to interactively configure ./WORKSPACE for Android builds? [y/N]: n
Not configuring the WORKSPACE for Android builds.

Preconfigured Bazel build configs. You can use any of the below by adding "--config=<>" to your build command. See tools/bazel.rc for more details.
--config=mkl          # Build with MKL support.
--config=monolithic  # Config for mostly static monolithic build.
Configuration finished

$ pip install enum34
$ pip uninstall enum

$ bazel build --config=opt //tensorflow/tools/pip_package:build_pip_package

執行完會在/tmp/tensorflow_pkg產生tensorflow-1.9.0-cp36-cp36m-macosx_10_13_x86_64.whl
$ ./bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg

$ pip install /tmp/tensorflow_pkg/tensorflow-1.9.0-cp36-cp36m-macosx_10_13_x86_64.whl



參考
https://www.tensorflow.org/install/source

$ brew install hdf5
$ brew install graphviz
$ sudo pip3 install pydot
$ sudo pip3 install keras


參考
https://keras.io/#installation

沒有留言:

張貼留言