[dev env] Install tensorflow in virtualenv - e-guy/e-guyNotes GitHub Wiki

Install tensorflow in virtualenv

1. Create and activate venv

$ virtualenv -p /usr/bin/python3.5 --no-site-packages py3.5venv
$ source py3.5venv/bin/activate

2. Install tensorflow

(py3.5venv) $ pip install tensorflow==1.8.* --no-cache-dir

3. Check tensorflow

(py3.5venv) $ python -c "import tensorflow as tf"

4. Uninstall tensorflow

(py3.5venv-tf-cv2) $ pip uninstall tensorflow-gpu protobuf --yes

Check wheather "tensorflow"-related folders exit under ~/py_venv/py2.7venv/lib/python2.7/site-packages/, if it does, remove them.


An Exmple

-- to set-up a provided tensorflow+deeplabV3 program environment (tf-gpu with opencv) in virtualenv

create venv

$ virtualenv -p /usr/lib/python3.5 --no-site-packages py3.5venv-tf-cv2

install neccessary packages and tensorflow:

(py3.5venv-tf-cv2) $ pip install numpy==1.15.4 --no-cache-dir && pip install scikit-image==0.13.1 --no-cache-dir && pip install scikit-learn==0.20.2 --no-cache-dir && pip install scipy==1.2.0 --no-cache-dir && pip install tensorflow==1.8.0.* --no-cache-dir

then, copy cv2 into virtualenv:(note: check your source cv2 location)

(py3.5venv-tf-cv2) $ cp -r /home/robin/.local/lib/python3.5/site-packages/cv2 ~/py_venv/py3.5venv/lib/python3.5/site-packages/

now, the venv is ready to run the provided program.