5
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

OS X用TensorFlow導入

Last updated at Posted at 2016-07-20

自分のMacにTensorFlowの環境構築をした。
(基本的に公式Tutorialそのまま)
継続して、TensorFlowを使い続けるか微妙だったのでvirtualenvで環境構築をした。
環境は以下。

  • OS X El Capitan (10.11.5)
  • python 2.7 (2.7.11)
  • zsh
$ pip install --upgrade virtualenv
$ virtualenv --system-site-packages ~/tensorflow
$ source ~/tensorflow/bin/activate
# Mac OS X, CPU only, Python 2.7:
(tensorflow)$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.2.1-py2-none-any.whl
(tensorflow)$ pip install --upgrade $TF_BINARY_URL

インストールチェック

$ python
...
>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
>>> print(sess.run(hello))
Hello, TensorFlow!
>>> a = tf.constant(10)
>>> b = tf.constant(32)
>>> print(sess.run(a + b))
42
>>>

TensorFlow環境の切り替え

$ source ~/tensorflow/bin/activate # activate the tensorflow environment.
(tensorflow)$ deactivate # deactivate the environment.

次は個人的な設定
activateのコマンドが面倒なのでエイリアスをはる。

$ echo "alias activateTF='source ~/tensorflow/bin/activate'" >> ~/.zshrc
$ source ~/.zshrc

コマンド確認

$ activateTF
(tensorflow)$  # Your prompt should change.

以上。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?