How do I launch Tensorboard? - python

I am following the introductory guide on Tensorflow at https://www.tensorflow.org/guide/low_level_intro, and managed to create an 'events.out' file by using
writer = tf.summary.FileWriter('.')
writer.add_graph(tf.get_default_graph())
writer.flush()
in my python file and running it. The next step is to launch Tensorboard in a 'terminal' with the 'shell command' tensorboard --logdir. How to do this? What terminal am I supposed to use? I tried windows powershell but it does not seem to work. It gives the error
tensorboard : The term 'tensorboard' is not recognized as the name of
a cmdlet, function, script file, or operable prog ram. Check the
spelling of the name, or if a path was included, verify that the path
is correct and try again. At line:1 char:1
+ tensorboard --logdir
+ ~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (tensorboard:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

Using PowerShell is fine. It sounds like your PATH is not configured to find the Tensorboard binary like others are saying. Can you show me what you get for pip show tensorflow? It should have something like below:
(1) ➜ ~ pip show tensorflow
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Name: tensorflow
Version: 1.12.0
Summary: TensorFlow is an open source machine learning framework for everyone.
Home-page: https://www.tensorflow.org/
Author: Google Inc.
Author-email: opensource#google.com
License: Apache 2.0
Location: c:\users\stephanwlee\venv\tf\lib\site-packages
Requires: enum34, keras-preprocessing, wheel, astor, backports.weakref, mock, tensorboard, termcolor, protobuf, gast, absl-py, grpcio, six, keras-applications, numpy
Required-by:
In above output, location is the important piece that tells you where binaries are roughly gets placed. If you are using virtualenv like the TensorFlow installation guide (everything should be set up seamlessly and I would recommend you to use it), the binaries should be in c:\users\stephanwlee\venv\tf\Scripts. Please check and see if the path is in $env:path.
If any of these didn't help, please do add result of pip show tensorflow and $env:path from PowerShell in the response, thanks!

pip show tensorflow
Name: tensorflow
Version: 2.7.0
Summary: TensorFlow is an open source machine learning framework for everyone.
Home-page: https://www.tensorflow.org/
Author: Google Inc.
Author-email: packages#tensorflow.org
License: Apache 2.0
Location: c:\users\luis\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages
Requires: absl-py, astunparse, flatbuffers, gast, google-pasta, grpcio, h5py, keras, keras-preprocessing, libclang, numpy, opt-einsum, protobuf, six, tensorboard, tensorflow-estimator, tensorflow-io-gcs-filesystem, termcolor, typing-extensions, wheel, wrapt
Required-by:
   LUIS#XEONE5-2620-v2  ~ 
❯
   LUIS#XEONE5-2620-v2  ~ 
❯ $env:path
C:\Program Files\Microsoft MPI\Bin\;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Git\cmd;C:\mingw64\bin;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\150\Tools\Binn\;C:\Program Files\Microsoft SQL Server\150\Tools\Binn\;C:\Program Files\Microsoft SQL Server\150\DTS\Binn\;C:\Program Files\Azure Data Studio\bin;C:\Strawberry\c\bin;C:\Strawberry\perl\site\bin;C:\Strawberry\perl\bin;C:\Program Files\MiKTeX\miktex\bin\x64\;C:\Program Files (x86)\Cracklock\Bin;C:\Users\LUIS\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Azure Data Studio\bin;;C:\Users\LUIS\AppData\Local\Programs\oh-my-posh\bin;C:\Users\LUIS\AppData\Local\Programs\oh-my-posh\themes;D:\Program Files\Microsoft VS Code\bin

Related

Colab running Pennylane with DeviceError

I tried to run Pennylane on Colab, so I install it first. But the "Installed devices" are null, what's going on? I have restart and rebuilt for several times. Here is my code.
!pip install pennylane pennylane-qiskit
import pennylane as qml
qml.about()
Here is the result (with nothing in "Installed devices"):
Successfully built qiskit python-constraint contextvars yfinance docplex dlx
Installing collected packages: semantic-version, appdirs, pennylane, sympy, fastjsonschema, retworkx, python-constraint, ply, immutables, contextvars, qiskit-terra, pybind11, qiskit-aer, websockets, cryptography, ntlm-auth, requests-ntlm, qiskit-ibmq-provider, qiskit-ignis, inflection, quandl, lxml, yfinance, docplex, dlx, qiskit-aqua, qiskit, pennylane-qiskit
Found existing installation: sympy 1.1.1
Uninstalling sympy-1.1.1:
Successfully uninstalled sympy-1.1.1
Found existing installation: lxml 4.2.6
Uninstalling lxml-4.2.6:
Successfully uninstalled lxml-4.2.6
Successfully installed appdirs-1.4.4 contextvars-2.4 cryptography-3.2.1 dlx-1.0.4 docplex-2.15.194 fastjsonschema-2.14.5 immutables-0.14 inflection-0.5.1 lxml-4.6.1 ntlm-auth-1.5.0 pennylane-0.12.0 pennylane-qiskit-0.12.0 ply-3.11 pybind11-2.6.0 python-constraint-1.4.0 qiskit-0.23.0 qiskit-aer-0.7.0 qiskit-aqua-0.8.0 qiskit-ibmq-provider-0.11.0 qiskit-ignis-0.5.0 qiskit-terra-0.16.0 quandl-3.5.3 requests-ntlm-1.1.0 retworkx-0.5.0 semantic-version-2.6.0 sympy-1.6.2 websockets-8.1 yfinance-0.1.55
Name: PennyLane
Version: 0.12.0
Summary: PennyLane is a Python quantum machine learning library by Xanadu Inc.
Home-page: https://github.com/XanaduAI/pennylane
Author: None
Author-email: None
License: Apache License 2.0
Location: /usr/local/lib/python3.6/dist-packages
Requires: semantic-version, scipy, autograd, networkx, numpy, appdirs, toml
Required-by: PennyLane-qiskit
Platform info: Linux-4.19.112+-x86_64-with-Ubuntu-18.04-bionic
Python version: 3.6.9
Numpy version: 1.18.5
Scipy version: 1.4.1
Installed devices:
When I tried to use device, I got
raise DeviceError("Device does not exist. Make sure the required plugin is installed.")
Try upgrading the pennylane-sf library as mentioned here:
!pip install pennylane-sf --upgrade
Restart the runtime and that's it!
https://discuss.pennylane.ai/t/tutorial-for-gaussian-boson-sampling-sample-code/728
Had been answered here:
https://discuss.pennylane.ai/t/error-when-calling-device/259/35
See the url for detail.

ModuleNotFoundError: No module named 'tensorflow', even when tensorflow is installed

I am trying to install tensorflow for one of my machine learning projects. However, even though I have installed it, I still get this error
ModuleNotFoundError: No module named 'tensorflow'
To help illustrate this better, I have created a test.py file, with the following content:
import tensorflow as tf
print('Hello world!')
However, still the same error, on line 1.
Relevant questions:
I've tried doing many other answers, but none of them seems to help. Any answers would be appreciated.
Here's some debugging outputs that might help:
pip3 show tensorflow
Name: tensorflow
Version: 1.11.0
Summary: TensorFlow is an open source machine learning framework for everyone.
Home-page: https://www.tensorflow.org/
Author: Google Inc.
Author-email: opensource#google.com
License: Apache 2.0
Location: c:\program files\anaconda3\lib\site-packages
Requires: absl-py, termcolor, keras-applications, astor, six, tensorboard, keras-preprocessing, wheel, gast, setuptools, grpcio, protobuf, numpy
Required-by:
pip3 --version
pip 18.1 from c:\program files\anaconda3\lib\site-packages\pip (python 3.6)
python --version
Python 3.6.0 :: Anaconda 4.3.0 (64-bit)
py test.py
Traceback (most recent call last):
File "test.py", line 1, in <module>
import tensorflow as tf
ModuleNotFoundError: No module named 'tensorflow'
I fixed it! Special thanks to the folks at the Tensorflow Talk slack who helped me, especially #akofman.
It was a combination of 2 problems:
Problem 1
It seems that one of the reasons it was failing was due to one of tensorflow's dependencies being outdated/misinstalled/something. The dependency is h5py. I found out about this by attempting to run import tensorflow in the python interpreter (type python), which gave me a long stack trace, unlike the test file (see problem 2). I fixed this by reinstalling the dependency.
Problem 2
It turns out that I have 3, that's right, 3!, versions of python on my computer
python -V ---> 3.6.0
python -V (in an anaconda enviorment) ---> 3.6.7
py -V ---> 3.7.0
I was running my test file with py, which is apparently 3.7.0 (I thought it was synonymous with python), I guess tensorflow doesn't support that version?

How to find which TensorFlow is installed in my windows system? Whether it is CPU or GPU TensorFlow

I tried out the following command on the Anaconda command prompt,
pip show tensorflow
which gave me the result,
Name: tensorflow
Version: 1.10.0
Summary: TensorFlow is an open source machine learning framework for everyone.
Home-page: https://www.tensorflow.org/
Author: Google Inc.
Author-email: opensource#google.com
License: Apache 2.0
Location: d:\softwares\pycond\envs\tensorflow2\lib\site-packages
Requires: termcolor, absl-py, grpcio, tensorboard, wheel, protobuf, gast, six, numpy, setuptools, astor
I want to know if the installed TensorFlow is CPU supported or GPU supported. How can I get this information?
The TensorFlow pip package includes GPU support for CUDA®-enabled cards
pip show tensorflow
For Older versions of TensorFlow:
For releases 1.15 and older, CPU and GPU packages are separate:
pip install tensorflow==1.15 # CPU
pip install tensorflow-gpu==1.15 # GPU
So, package names are different in for releases 1.15 and older.

Setting Path of TensorFlow

MacOS High Sierra 10.13.2 Early 2016 Rose Gold MacBook
I have done a LOT to get TensorFlow installed (REALLY should have just used pip3 from the start...) and now need to set the path of it so I can import it. Currently, I know it is installed; pip3 show tensorflow gets Name: tensorflow
Version: 1.8.0
Summary: TensorFlow helps the tensors flow
Home-page: https://www.tensorflow.org/
Author: Google Inc.
Author-email: opensource#google.com
License: Apache 2.0
Location: /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
Requires: numpy, absl-py, gast, termcolor, astor, protobuf, grpcio, wheel, six, tensorboard
This is great, but importing tensorflow still doesn't work. I figured out that I need to set the path from some googling and found this command: PYTHONPATH=/your/tensorflow/path:$PYTHONPATH. However, what am I supposed to do with it? Should I replace 'PYTHONPATH' with something? How do I tell it that that points to tensorflow? Should it be like this:
PYTHONPATH=/Users/rose/tensorflow/path:$tensorflow

"No module named ipython" error despite already installed

I am trying to launch ipython using the command: python -m ipython
When launched I get the following error : C:\Program Files\Python36\python.exe: No module named ipython
This is strange because when I run python -m pip show ipython, I get the following message :
Name: ipython
Version: 6.2.1
Summary: IPython: Productive Interactive Computing
Home-page: https://ipython.org
Author: The IPython Development Team
Author-email: ipython-dev#python.org
License: BSD
Location: c:\program files\python36\lib\site-packages
Requires: simplegeneric, setuptools, decorator, pickleshare, traitlets,
pygments, colorama, prompt-toolkit, jedi
I already ensured that all dependencies were correctly installed.
Could you please help me ?
It is actually spelled IPython (upper case I and P to start).
python -m IPython
will do.
Edit: confusion can arise because the pypi service allows the package name and module name to differ.
I solved this problem by using below command:
pip install IPython==5.0 --user
IPython version needs to pair with python version, and I have a python2.7

Categories

Resources