LoginSignup
1
0

More than 5 years have passed since last update.

[macOS] TensorFlowをインストールする

Posted at

[macOS] TensorFlowをインストールする

CoreMLではモデルは開発者で用意しないといけない。TensorFlowの利用を考えて、インストールしてみる。

公式サイトの情報によると、macOSでは以下の選択肢がある。

  • virtualenv
  • "native" pip
  • Docker
  • installing from sources
  • Anaconda

お勧めはvirtualenvということなので、素直に従ってみる。

virtualenvをインストールする。

$ sudo easy_install pip
$ pip install --upgrade virtualenv

あれ、二個目のコマンドでエラーになる。パーミッション関連なので、sudoつけてみた。

$ sudo pip install --upgrade virtualenv

成功した。

virtualenv 環境を作成する。標準のPythonは2.7.10なので、以下のコマンドとなる。

$ virtualenv --system-site-packages ~/tensorflow

次はアクティベート。bashなので、以下のコマンドとなる。

$ source ~/tensorflow/bin/activate
(targetDirectory) $

pip 8.1がインストールされていることを確認する。

$ easy_install -U pip

TensorFlowをインストール。

$ pip install --upgrade tensorflow

動作確認する。

$ python
Python 2.7.10 (default, Jul 15 2017, 17:16:57) 
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> # Python
... import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
2017-12-15 22:40:19.713684: I tensorflow/core/platform/cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.2 AVX AVX2 FMA
>>> print(sess.run(hello))
Hello, TensorFlow!
>>> 

成功したみたいだ。

関連情報
Installing TensorFlow on macOS

Cocoa Advent Calendar 2017

Cocoa勉強会 BUKURO.swift (connpass)

Cocoa勉強会 BUKURO.swift (ATND)

Cocoa勉強会 BUKURO.swift (Peatix)

【Cocoa練習帳】
http://www.bitz.co.jp/weblog/

http://ameblo.jp/bitz/(ミラー・サイト)

Qiita

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0