Passo 1:
# apt-get install python-pip python-dev -y
Reading package lists Done
Building dependency tree
Reading state information Done
python-dev is already the newest version (2.7.131).
python-dev set to manually installed.
python-pip is already the newest version (9.0.11).
python-pip set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Passo 2:
# export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.12.1-cp27-none-linux_x86_64.whl
Passo 3:
# pip install upgrade $TF_BINARY_URL
Collecting tensorflow==0.12.1 from https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.12.1-cp27-none-linux_x86_64.whl
Downloading https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.12.1-cp27-none-linux_x86_64.whl (43.1MB)
100% |████████████████████████████████| 43.1MB 31kB/s
Collecting mock>=2.0.0 (from tensorflow==0.12.1)
Downloading mock-2.0.0-py2.py3-none-any.whl (56kB)
100% |████████████████████████████████| 61kB 1.7MB/s
Requirement already up-to-date: numpy>=1.11.0 in /usr/lib/python2.7/dist-packages (from tensorflow==0.12.1)
Collecting protobuf>=3.1.0 (from tensorflow==0.12.1)
Downloading protobuf-3.1.0.post1-py2.py3-none-any.whl (347kB)
100% |████████████████████████████████| 348kB 2.6MB/s
Requirement already up-to-date: wheel in /usr/lib/python2.7/dist-packages (from tensorflow==0.12.1)
Requirement already up-to-date: six>=1.10.0 in /usr/lib/python2.7/dist-packages (from tensorflow==0.12.1)
Collecting funcsigs>=1; python_version < 3.3 (from mock>=2.0.0->tensorflow==0.12.1)
Downloading funcsigs-1.0.2-py2.py3-none-any.whl
Collecting pbr>=0.11 (from mock>=2.0.0->tensorflow==0.12.1)
Downloading pbr-1.10.0-py2.py3-none-any.whl (96kB)
100% |████████████████████████████████| 102kB 3.4MB/s
Collecting setuptools (from protobuf>=3.1.0->tensorflow==0.12.1)
Downloading setuptools-32.3.1-py2.py3-none-any.whl (479kB)
100% |████████████████████████████████| 481kB 1.9MB/s
Installing collected packages: funcsigs, pbr, mock, setuptools, protobuf, tensorflow
Found existing installation: setuptools 32.0.0
Not uninstalling setuptools at /usr/lib/python2.7/dist-packages, outside environment /usr
Successfully installed funcsigs-1.0.2 mock-2.0.0 pbr-1.10.0 protobuf-3.1.0.post1 setuptools-32.3.1 tensorflow-0.12.1
Execute
TensorFlow a partir da linha de comando.
Passo 4:
Abra um terminal e digite o seguinte comando:
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
>>>
Execute um modelo de demonstração do TensorFlow.
Todos os pacotes TensorFlow, incluindo os modelos de demonstração, estão instalados na biblioteca Python. A localização exata da biblioteca Python depende do seu sistema, mas geralmente é um dos seguintes:
- /usr/local/lib/python2.7/dist-packages/tensorflow
- /usr/local/lib/python2.7/site-packages/tensorflow
Você pode descobrir o diretório com o seguinte comando (certifique-se de usar o Python no qual você instalou o TensorFlow, por exemplo, use o "python3" ao invés do "python", se você instalou o Python 3):
python -c 'import os; import inspect; import tensorflow; print(os.path.dirname(inspect.getfile(tensorflow)))'
O modelo de demonstração simples para classificar os dígitos manuscritos do conjunto de dados MNIST está nos modelos de subdiretórios
models/image/mnist/convolutional.py. Você pode executá-lo a partir da linha de comando da seguinte forma (certifique-se de usar o Python com o qual você instalou o TensorFlow):
python -m tensorflow.models.image.mnist.convolutional
Extracting data/train-images-idx3-ubyte.gz
Extracting data/train-labels-idx1-ubyte.gz
Extracting data/t10k-images-idx3-ubyte.gz
Extracting data/t10k-labels-idx1-ubyte.gz
...etc...
Você pode, alternativamente, passar o caminho para o arquivo do programa modelo para o interpretador python (certifique-se de usar a distribuição python que você instalou.
python /usr/local/lib/python2.7/dist-packages/tensorflow/models/image/mnist/convolutional.py
Referências
Meu novo blog:
Installing TensorFlow on Kali (Rolling Base) CPU Mode
Espero ter ajudado!
Mauro Risonho de Paula Assumpção
linkedin:
https://www.linkedin.com/in/firebitsbr/
twitter: @firebitsbr