Install TensorFlow in Virtualenv without sudo privilege

Install Virtualenv without sudo privilege

  • Download and unzip one of the latest pacages:
1
2
wget https://github.com/pypa/virtualenv/archive/15.1.0.tar.gz
tar -zxvf 15.1.0.tar.gz
  • Run command below to create an environment:
1
2
cd 15.1.0
python virtualenv.py ~/tfenv
  • Activate the virtualenv environment using source command:
1
source ~/tfenv/bin/activate

It will change you prompt to: (tfenv)$

  • Install pip in your the environment:
1
(tfenv)$ easy_install -U pip
  • Install tensorflow using pip:
1
(tfenv)$ pip install --upgrade tensorflow

Uninstallation

  • Exit virtualenv:
1
(tfenv)$ deactivate
  • Remove the directory:
1
rm -rf ~/tfenv

Enter & Quit the environment

  • Entering the virtualenv:
1
source ~/tfenv/bin/activate
  • Quitting the virtualenv:
1
(tfenv)$ deactivate

Validate the installation

  • Invoke python
1
(tfenv)$ python
  • Enter the following program, the system should output “Hello, TensorFlow!”:
1
2
3
4
>>> import tensorflow as tf:
>>> hello = tf.constant("Hello, TensorFlow!")
>>> sess = tf.Session()
>>> print sess.run(hello)

If anything goes wrong, please comment below, I’ll response when I see it. Have fun!