Installing TensorFlow on Ubuntu/Google Cloud Platform

What is TensorFlow? Most probably you know perfect the answer but if you are new(according to google):

TensorFlow is an open-source software library for Machine Intelligence.

It's one of the most popular software libraries out there for AI(artificial intelligence). You can follow the very detailed instruction from: Installing TensorFlow

Google Cloud Platform is a suite of cloud computing services that runs on the same infrastructure that Google uses internally for its end-user ..

This is a description for Google Cloud Platform found on Wikipedia. It's a good combination to use them for AI projects without the need to invest for hardware. GCP offers 300 $ as a trial amount if you want to try their platform: Free TrialThis can be enough for weeks of training neural network.

Python is a very popular programming language. It is very useful in big range of areas and has a design that emphasizes code readability and simplicity. It is widely considered to be relatively easy programming language to learn and master because of its focus on readability.

Pre-Flight Notes

  • These instructions are intended specifically for installing TensorFlow.
  • I’ll be working from a Ubuntu 14.04 LTS server, and I’ll be logged in as non-root user.
  • Connection is done through SSH(with key authorization).

1 install required libraries - zip, python3-pip and python3-dev

sudo apt-get -y install zip
sudo apt-get -y install python3-pip python3-dev

2 install tensor flow - check for the version that you need. Here it is:

  • version - 1.0.1
  • python - 3
  • 64 bit version
sudo pip3 install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.0.1-cp34-cp34m-linux_x86_64.whl

3 install required libraries - python-pip python-dev python-virtualenv

sudo apt-get install python-pip python-dev python-virtualenv

4 set virtual environment

virtualenv --system-site-packages ~/tensorflow

5 Activate tensorflow

source ~/tensorflow/bin/activate

6 Prepare training session

unzip your-rnn-package.zip
cd your-rnn-package
python3 train.py
(if you want the script to continue after exiting current session use - nohup command)
sudo nohup python3 train.py

7 Sample

python3 sample.py

8 Deactivate tensorflow

deactivate

9 Connect with ssh(depending on your settings

  • sh user@host – Connect to host as user
  • ssh -p port user@host – Connect to host on port port as user
  • ssh-copy-id user@host – Add your key to host for user to enable a keyed or passwordless login

10 All commands unformatted

  ssh -p 22 myuser@168.0.0.1
  sudo apt-get -y install zip
  sudo apt-get -y install python3-pip python3-dev
  sudo pip3 install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.0.1-cp34-cp34m-linux_x86_64.whl
  sudo apt-get -y install python-pip python-dev python-virtualenv
  virtualenv --system-site-packages ~/tensorflow
  source ~/tensorflow/bin/activate
  deactivate
  sudo mkdir sample
  sudo chown -R myuser:myuser /home/sample/
  sudo mkdir /home/myuser/working
  sudo unzip /home/sample/my-rnn-package.zip
  cd my-rnn-package/data/sampledata/
  sudo cp /home/sample/input.txt .
  sudo python3 train.py
  sudo nohup python3 train.py
  sudo rm -r /home/myuser/working/my-rnn-package/

  sudo tail -f -n 100 /home/myuser/working/my-rnn-package/nohup.out