Tensorflow root directory in Mac - python

I need to use the transform_graph in Tensorflow. However, according to TensorFlow: Quantization Error "Analysis of target '//tensorflow/tools/graph_transforms:transform_graph' failed; build aborted.", I still need to configure tensorflow by issuing ./configure in the top root Tensorflow directory:
$ cd tensorflow # cd to the top-level directory created
$ ./configure
Where is the top-level directory of Tensorflow?
I did this:
C:\> python
>>>import tensorflow as tf
>>>print(tf.__file__ )
And found out that my tensorflow directory is in /Users/miniconda3/lib/python3.6/site-packages/tensorflow.
However, when I issue the ./configure command inside this directory, it says
-bash: ./configure: No such file or directory
And checked that this directory does not contain any hidden file named configure
I checked the Tensorflow repo in Github found in https://github.com/tensorflow/tensorflow/tree/master/tensorflow/tools, and found the configure file. I compared the tensorflow folder from Github and in my local machine and found out that they don't contain the same files. Am I in the wrong directory in my local machine? What Tensorflow root directory is referred here?

use the following to find the location:
pip3 show tensorflow
or
pip show tensorflow
Output on my MAC OS:
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.7/lib/python3.7/site-
packages
Requires: six, absl-py, keras-preprocessing, tensorboard, astor, protobuf,
numpy, gast, termcolor, grpcio, wheel, keras-applications
Required-by:
Refer https://www.youtube.com/watch?v=BVS3U1OQzO4

Related

Could not load dynamic library 'libcudnn.so.8' in ubuntu

i am using Ubuntu 20.04.3 and trying to install tensorflow. Nvidia driver version is Driver Version: 470.63.01.
First, i have installed cuda 11.0 and checked it installation via following command
cat /usr/local/cuda/version.txt
It output CUDA Version 11.0.207.
Next i installed cudnn
tar -xzvf cudnn-11.0-linux-x64-v8.0.5.39
sudo cp cuda/include/cudnn*.h /usr/local/cuda/include
sudo cp -P cuda/lib64/libcudnn* /usr/local/cuda/lib64
sudo chmod a+r /usr/local/cuda/include/cudnn*.h /usr/local/cuda/lib64/libcudnn*
I also checked cuda files with this command
ls /usr/local |grep cuda
which result in
cuda
cuda-11.0
Cudnn files are tested by
ls /usr/local/cuda-11.0/lib64/libcudnn.so.8*
and output is
/usr/local/cuda-11.0/lib64/libcudnn.so.8
/usr/local/cuda-11.0/lib64/libcudnn.so.8.0.5
Then i installed tensorflow
pip install tensorflow==2.4.0
but when i run
import tensorflow as tf
tf.config.list_physical_devices('GPU')
It did not get GPU and error is Could not load dynamic library 'libcudnn.so.8'; dlerror: libcudnn.so.8: cannot open shared object file: No such file or directory
I just faced the same issue. From your code snippet I see that you are referencing two different CUDA locations:
/usr/local/cuda/
/usr/local/cuda-11.0/
So you might double-check if that causes an issue.
From here I learned that TF reads the system information about available CUDA from LD_LIBRARY_PATH. Multiple CUDA versions are installed on the system I am using. Thus, exporting these paths explicitly fixed the issue for me:
export LD_LIBRARY_PATH=/usr/local/cuda-11.0/lib64:$LD_LIBRARY_PATH
export CUDA_HOME=/usr/local/cuda-11.0
Of course, you would need to adapt the path to your specific situation.

Cannot install Tensorflow on PyCharm

I am trying to install TensorFlow on PyCharm in Project > Python Interpreter to meet the requirement of the TF Developer Certificate exam.
My computer is Windows 10. On the Python Console, I print the python version:
>>> print(sys.version)
3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 22:20:52) [MSC v.1916 32 bit (Intel)]
Then I go to File > Settings > Project > Python Interpreter > Available Packages, find and install the Tensorflow package. I install the default version which is 2.2.0. My pip version is 20.1.1.
But I cannot install it, it displays this error:
Error occurred:
ERROR: Could not find a version that satisfies the requirement tensorflow (from versions: none)
Command output:
ERROR: Could not find a version that satisfies the requirement tensorflow (from versions: none)
ERROR: No matching distribution found for tensorflow
I have searched for this solution but I cannot find anything that helps me solve it. Does anyone know how to fix this? Thanks.
Update:
When I install the TF in my cmd, it installs successfully.
C:\Users\User>pip show tensorflow
Name: tensorflow
Version: 2.2.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\user\anaconda3\lib\site-packages
Requires: six, google-pasta, wrapt, astunparse, gast, wheel, scipy, absl-py, numpy, tensorboard, termcolor, grpcio, h5py, keras-preprocessing, tensorflow-estimator, protobuf, opt-einsum
Required-by:
Update 2:
I follow this set up instruction by TF: Link
Update 3:
So I tried to install via package location but it doesn't work (Python 3.7 CPU-only):
pip install https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow_cpu-2.2.0-cp37-cp37m-win_amd64.whl
Error:
ERROR: tensorflow_cpu-2.2.0-cp37-cp37m-win_amd64.whl is not a supported wheel on this platform.
Update 4:
I create a new project, then use conda environment to install TF. Then it works.
But I still don't understand why using normal venv, it cannot install.
Update 5:
Everything works fine on Ubuntu when following the instruction by TF.
I had this issue when I was trying to use TensorFlow on Windows 10 while having multiple versions of Python installed.
What I did was uninstall all versions except the most updated one. If I needed an older version I would use Conda virtual environment.

Check and run correct Tensorflow Version (v2.0)

i was using the previous version of tensorflow, but i wanna use tensorflow 2.0.0 alpha and i've installed it with pip using
pip install tensorflow==2.0.0-alpha0
than i run the simple code to check what version
import tensorflow as tf
print(tf.__version__)
but this is the result:
1.13.0-rc1
so i check with pip
pip3 show tensorflow
and i got:
Name: tensorflow
Version: 2.0.0a0
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\massimo\appdata\local\programs\python\python37\lib\site-packages
Requires: gast, six, protobuf, google-pasta, absl-py, astor, tb-nightly,
termcolor, grpcio, keras-applications, keras-preprocessing, tf-estimator-
nightly, wheel, numpy
Required-by:
is there something wrong? i'm expecting with tf.version something like 2.0.0
what i'm missing?
Thank you all
Max
UPDATE
while the command
python -m site
sys.path = [
'C:\\Users\\Massimo\\AppVisualCode',
'C:\\Users\\Massimo\\AppData\\Local\\Programs\\Python\\Python37\\python37.
zip',
'C:\\Users\\Massimo\\AppData\\Local\\Programs\\Python\\Python37\\DLLs',
'C:\\Users\\Massimo\\AppData\\Local\\Programs\\Python\\Python37\\lib',
'C:\\Users\\Massimo\\AppData\\Local\\Programs\\Python\\Python37',
'C:\\Users\\Massimo\\AppData\\Roaming\\Python\\Python37\\site-packages',
'C:\\Users\\Massimo\\AppData\\Local\\Programs\\Python\\Python37\\lib\\site-
packages',
]
USER_BASE: 'C:\\Users\\Massimo\\AppData\\Roaming\\Python' (exists)
USER_SITE:
'C:\\Users\\Massimo\\AppData\\Roaming\\Python\\Python37\\site-packages'
(exists)
ENABLE_USER_SITE: True
if you have two interpreters both with python version 3+ upgrade your pip to version 0.8 or above for both the interpreters and then you can also do this
pip3.5 install package1
pip3.6 install package2
pip3.7 install package3
I was about to write the same answer as what Vlad wrote in the comment but because it didn't work for you & since you are already using multiple python interpreters,
another possible suggestion could be to use them in a different virtual environment (interpreters with different or same python versions) for all your new projects (it's also highly recommended by most of the Data Scientists).
After that install the packages with exact version that you want to use and you'll be good to go. You'll never have to worry about for which interpreter/environment you installed which package.

Have two different TensorFlow's, how to uninstall both completely?

I have TensorFlow 0.12 that I built from source for GPU support a few months. There was some problems with it that I solved right now but in the downtime I'd installed TensorFlow 1.0.1 using pip install tensorflow-gpu. I want to know how exactly to uninstall both and start over by installing TF 1.0. What else do I need to do other than deleting /home/username/anaconda2/lib/python2.7/site-packages/tensorflow/? This is the output when I use the following commands:
$ pip show tensorflow
Name: tensorflow
Version: 0.12.0rc1
Summary: TensorFlow helps the tensors flow
Home-page: http://tensorflow.org/
Author: Google Inc.
Author-email: opensource#google.com
License: Apache 2.0
Location: /home/username/anaconda2/lib/python2.7/site-packages
Requires: mock, numpy, protobuf, wheel, six
$ pip show tensorflow-gpu
Name: tensorflow-gpu
Version: 1.0.1
Summary: TensorFlow helps the tensors flow
Home-page: http://tensorflow.org/
Author: Google Inc.
Author-email: opensource#google.com
License: Apache 2.0
Location: /home/username/anaconda2/lib/python2.7/site-packages
Requires: mock, numpy, protobuf, wheel, six
On navigating to the tensorflow-gpu folder in site-packages I found some few files, mostly text
$ cd anaconda2/lib/python2.7/site-packages/tensorflow_gpu-1.0.1.dist-info/
$ ls
DESCRIPTION.rst entry_points.txt METADATA metadata.json RECORD top_level.txt WHEEL
pip uninstall tensorflow-gpu and pip uninstall tensorflow should do it. Otherwise, you can also completely remove and reinstall anaconda to start from scratch.

Where is the root directory of tensorflow installed when using it via Docker on windows?

I need to find out exactly where TensorFlow is installed when using it with the docker as I want to use the Inception-V3 image classifier to classify my own images. However, the tutorial on the website assumes I installed it using pip and thus I am stuck using the default image. Thanks!
You can find the details about tensorflow by typing pip show tensorflow from windows command line or powershell.
For me it showed the following details:
Name: tensorflow
Version: 0.12.1
Summary: TensorFlow helps the tensors flow
Home-page: http://tensorflow.org/
Author: Google Inc.
Author-email: opensource#google.com License: Apache 2.0
Location: c:\program files\anaconda3\lib\site-packages
Requires: protobuf, numpy, six, wheel

Categories