(keeping notes here for ease of future references)
See this Stackoverflow forum - Trouble with TensorFlow in Jupyter Notebook
This post is a copy of the answer I submitted (for ease of my own references). i.e. create an
environment.yml file to make this conda / tensorflow installation process more repeatable.
Acknowledgement: The accepted answer (by Zhongyu Kuang) did help me out tons.
Step 1 - create a Conda environment.yml File
environment.yml looks like this:
name: hello-tensorflow dependencies: - python=3.6 - jupyter - ipython - pip: - https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.1.0-cp36-cp36m-linux_x86_64.whl
- Simply replace the name to whatever you want. (mine is
- Simply replace the python version to whatever you want. (mine is
- Simply replace the tensorflow pip install URL to whatever you want (mine is the Tensorflow URL where Python 3.6 with GPU support)
Step 2 - create the Conda environment
environment.yml being in the current path you are on, this command creates the environment
hello-tensorflow (or whatever you have renamed it to):
conda env create -f environment.yml
Step 3: source activate
Activate the newly created environment:
source activate hello-tensorflow
Step 4 - which python / jupyter / ipython
(hello-tensorflow) $ which python /home/johnny/anaconda3/envs/hello-tensorflow/bin/python
(hello-tensorflow) $ which jupyter /home/johnny/anaconda3/envs/hello-tensorflow/bin/jupyter
(hello-tensorflow) $ which ipython /home/johnny/anaconda3/envs/hello-tensorflow/bin/ipython
You should now be able to import tensorflow from python, jupyter (console / qtconsole / notebook, etc.) and ipython.
Here is what I get:
In : import tensorflow as tf In : hello = tf.constant('Hello, TensorFlow!') In : sess = tf.Session() 2017-05-31 17:16:41.853631: I tensorflow/core/common_runtime/gpu/gpu_device.cc:977] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 750 Ti, pci bus id: 0000:01:00.0) In : print(sess.run(hello)) b'Hello, TensorFlow!'