Setting Path of TensorFlow - python

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

Related

ModuleNotFoundError: No module named 'tensorflow.keras', but terminal tells me that i have

Running machine learning python from (https://github.com/cyrixninja/Waste-Classifier-V2). This gives me an error below. However, I can confirm my tensorflow by pip3 show tensorflow and just in case, I re-installed tensorflow here. But No Module error is alerting too many times.
python3 plastic_classifier.py
Using TensorFlow backend.
Traceback (most recent call last):
File "./plastic_classifier.py", line 6, in <module>
from tensorflow.keras.optimizers import RMSprop
ModuleNotFoundError: No module named 'tensorflow.keras'
pip3 show tensorflow
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: /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages
Requires: absl-py, astor, gast, grpcio, keras-applications, keras-preprocessing, numpy, protobuf, six, tensorboard, termcolor, wheel
Required-by:
pip install tensorflow-macos
Successfully installed MarkupSafe-2.1.1 absl-py-1.2.0 astunparse-1.6.3 flatbuffers-1.12 gast-0.4.0 google-auth-2.11.0 google-auth-oauthlib-0.4.6 google-pasta-0.2.0 grpcio-1.47.0 h5py-3.7.0 keras-2.9.0 keras-preprocessing-1.1.2 libclang-14.0.6 markdown-3.4.1 opt-einsum-3.3.0 protobuf-3.19.4 pyasn1-0.4.8 pyasn1-modules-0.2.8 rsa-4.9 tensorboard-2.9.1 tensorboard-data-server-0.6.1 tensorboard-plugin-wit-1.8.1 tensorflow-estimator-2.9.0 tensorflow-macos-2.9.2 termcolor-1.1.0 werkzeug-2.2.2 wrapt-1.14.1
pip install tensorflow-metal
Successfully installed tensorflow-metal-0.5.1
I would leave some information that I tried https://github.com/jeffheaton/t81_558_deep_learning/blob/master/install/tensorflow-install-mac-metal-jul-2021.ipynb
System information
OS Platform and Distribution (e.g., Linux Ubuntu 16.04): macOS
Monterey 12.3.1 TensorFlow version: 1.12.0 Python version: 3.10.6
Installed using virtualenv? pip? conda?

ImportError: cannot import name 'saveable_objects_from_trackable' from 'tensorflow.python.training.saving.saveable_object_util'

I can't import tensrflow:
import tensorflow as tf
is responded by:
ImportError: cannot import name 'saveable_objects_from_trackable' from 'tensorflow.python.training.saving.saveable_object_util' (C:\Users\Lior\AppData\Roaming\Python\Python39\site-packages\tensorflow\python\training\saving\saveable_object_util.py)
I had a working tf so how did I accidently came here? I tried to fix the problem of
Tensorflow 2.0 list_physical_devices doesn't detect my GPU
one of the things I did was
rm -rf anaconda_folder
Becose I thought that how you need to remove your tf before install it again with GPU detection.
Sagnificant remark about my tf version:
Name: tensorflow
Version: 2.8.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\lior\appdata\roaming\python\python39\site-packages
Requires: absl-py, astunparse, flatbuffers, gast, google-pasta, grpcio, h5py, keras, keras-preprocessing, libclang, numpy, opt-einsum, protobuf, setuptools, six, tensorboard, tensorflow-io-gcs-filesystem, termcolor, tf-estimator-nightly, typing-extensions, wrapt
Required-by:

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.

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.

How to fix empty tensorflow installation?

I get illegal instruction (core dumped) after running import tensorflow with version of tensorflow 1.7.
After that I installed tf 1.5.0-gpu (pip3 install --upgrade tensorflow-gpu==1.5.0)
Then tried to import tensorflow, I get no error
However tf.set_random_seed(random_state) - returns AttributeError: module 'tensorflow' has no attribute 'set_random_seed'
Then in the jupyter notebook with shit-tab get library help:
Type: module
String form: <module 'tensorflow' (namespace)>
Docstring: <no docstring>
Seems to isnt righ. However :
~ $ pip show tensorflow-gpu
Name: tensorflow-gpu
Version: 1.5.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: /home/analyst/anaconda3/lib/python3.6/site-packages
Requires: absl-py, wheel, six, tensorflow-tensorboard, numpy, protobuf
Required-by:
$ pip show tensorflow #Returns nothing
What might be wrong?
UPD: I have such files, which can be found via search. Im afraid of 1.1.0 tf. Is it okay?
>qqusr#qqusr-PC ~ $ locate -i tensorflow.py
/home/qqusr/anaconda3/pkgs/tensorflow-1.1.0-np112py36_0/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py
/home/qqusr/tensorflow/tensorflow/tools/dist_test/scripts/k8s_tensorflow.py
upd: I have 2 active namaspaces: how to fix that:
> tf.__path__
_NamespacePath(['/home/aa/tensorflow', '/home/aa/anaconda3/lib/python3.6/site-packages/tensorflow'])
1) One method that worked for #JaeDukSeo was using the precomplied version
https://www.lfd.uci.edu/~gohlke/pythonlibs/#tensorflow
In addition you give this a try and for precomplied GPU version: https://github.com/mind/wheels.
2) However, installing precomputed version leads me to another error, problems with intel libraries. Trying to solve such problem I found the solution
conda install -c anaconda tensorflow-gpu
You can specify here version you want to install as well

Categories

Resources