Tensorflow CPU Version Installation Error - tensorflow

I am running Ubuntu by using Virtualbox on Windows10.
I installed Tensorflow CPU version in terminal using pip3 install --upgrade tensorflow as per instruction given in official site of Tensorflow. And when I tried to validate installation as import tenorflow as tf it showed following error:
Traceback (most recent call last):
File "<stdin>", line1, in <module>
ImportError: No module named tensorflow
What should I do, to fix this error?

Related

Failed to import cupy

After installing cupy via "pip install cupy-cuda110", I tried this in python3:
import cupy as cp
However, it failed:
"
$ python3
Python 3.8.10 (default, Nov 26 2021, 20:14:08)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
import cupy as cp
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/cupy/init.py", line 18, in
from cupy import _core # NOQA
File "/usr/local/lib/python3.8/dist-packages/cupy/_core/init.py", line 1, in
from cupy._core import core # NOQA
ImportError: libnvrtc.so.11.0: cannot open shared object file: No such file or directory
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.8/dist-packages/cupy/init.py", line 20, in
raise ImportError(f'''
ImportError:
Failed to import CuPy.
If you installed CuPy via wheels (cupy-cudaXXX or cupy-rocm-X-X), make sure that the package matches with the version of CUDA or ROCm installed.
On Linux, you may need to set LD_LIBRARY_PATH environment variable depending on how you installed CUDA/ROCm.
On Windows, try setting CUDA_PATH environment variable.
Check the Installation Guide for details:
https://docs.cupy.dev/en/latest/install.html
Original error:
ImportError: libnvrtc.so.11.0: cannot open shared object file: No such file or directory
"
May you know how to resolve this problem? Many thanks!
Before installing cupy, you should check the version of Cuda that is installed on your device :
!nvcc --version
For me, the Cuda version installed on my device is 11.0 (See the picture below) :
After that go to the official Cupy website https://docs.cupy.dev/en/stable/install.html
The following image is from the page I referred to above:
Then type the install command that matches your Cuda version, for me, the install command will be :
pip install cupy-cuda110
When installing these packages with CUDA 11.2, 11.3, or 11.4, you may experience a “Failed to import CuPy” error. To resolve this error, please uninstall cupy-cuda115 and install cupy-cuda11x:
pip uninstall cupy-cuda115
pip install cupy-cuda11x
https://rapids.ai/pip.html

ModuleNotFoundError: No module named 'absl'

I followed instructions (https://tensorflow-object-detection-api-tutorial.readthedocs.io/en/latest/training.html) to install the Tensorflow Object Detection API. I use Anaconda on ubuntu18.4 and all of the steps in the instructions seemed to complete OK.
When I train to train my model with the following command:
python model_main_tf2.py --model_dir=models/my_ssd_resnet50_v1_fpn --pipeline_config_path=models/my_ssd_resnet50_v1_fpn/pipeline.config
I get the following error:
Traceback (most recent call last):
File "model_main_tf2.py", line 31, in <module>
from absl import flags
ModuleNotFoundError: No module named 'absl'
I get the error mentioned in the headline. I would be very thankful if someone could help me with a code example to solve the problem.
You need the absl package; to install it, use either one of the following:
pip install absl-py
or if you are in a Conda environment:
conda install -c anaconda absl-py

How to install matplotlib 3.2.x on Ubuntu 16.04?

Tried several methods to install matplotlib on Ubuntu 16.04, but failed miserably. First I ran
sudo apt-get install python3-matplotlib, it always installed matplotlib 1.5.1 and I wanted the latest version 3.2.1. So I purged it and ran pip3 install matplotlib and what I got was always the following error
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-hse72gvy/matplotlib/setup.py", line 139
raise IOError(f"Failed to download jquery-ui. Please download "
^
SyntaxError: invalid syntax
which seems to suggest that I must install jQuery-UI. I haven't found any working solutions on the internet. Any more has a tip or solution?

Numpy API version mismatch

I'm trying to install tensorflow from source on a Gentoo system (I think I need to do this to get it to use CUDA 9.1).
I'm able to build tensorflow, and then install it as a user with:
pip3 install --no-cache-dir --user /tmp/tensorflow_pkg/tensorflow-1.6.0rc1-cp35-cp35m-linux_x86_64.whl
When I try to import tensorflow I get:
>RuntimeError Traceback (most recent call last)
>RuntimeError: module compiled against API version 0xc but this version of numpy is 0xb
>
>ImportError Traceback (most recent call last)
>ImportError: numpy.core.multiarray failed to import
>
>ImportError Traceback (most recent call last)
>ImportError: numpy.core.umath failed to import
>
>ImportError Traceback (most recent call last)
>ImportError: numpy.core.umath failed to import
So my guess is that tensorflow was built against a different version of numpy than my system default (1.13.3).
The question is how to fix it? There's a lot about this process that's unfamiliar to me, so I would be grateful for any pointers in doing any of the following:
Telling the tensorflow build to use the system-wide numpy. Tensorflow uses bazel for the build process
Figure out what version of numpy tensorflow wants and change my system numpy to that.
Something else??? I can't do much with pip on a system-wide level because pip and Gentoo don't get along. I tried installing via Anaconda but then tensorflow couldn't see my gpus. Installing in a virtualenv with pip (which used to work) didn't work, I think because I've got cuda 9.1 installed. Perhaps I should downgrade to 9.0???
Any help appreciated!
Someone I always figure out how to do something the second after I post on SO! I installed into a virtualenv and did pip3 install --upgrade numpy in the virtualenv. All appears to be well...

numpy.test error in virtualenv with ERROR: test_multiarray.TestNewBufferProtocol.test_relaxed_strides

In my ubuntu system,i install numpy in virtualenv with python 2.7. After i install it, using the numpy.test:
python -c "import numpy; numpy.test()"
there are some errors like this:
ERROR: test_multiarray.TestNewBufferProtocol.test_relaxed_strides
Traceback (most recent call last):
File "/home/zjd/wangliangguo/theano-env/local/lib/python2.7/site- packages/nose/case.py", line 197, in runTest
self.test(*self.arg)
File "/home/zjd/wangliangguo/theano-env/local/lib/python2.7/site-packages/numpy/core/tests/test_multiarray.py", line 5366, in test_relaxed_strides fd.write(c.data)
TypeError: 'buffer' does not have the buffer interface
I had the same error with Python 2.7.3. Upgrading to Python 2.7.11 fixed it for me.
I'm on Ubuntu 12.04 LTS, and the default apt-get repositories didn't have Python 2.7.11, so I followed these instructions: https://superuser.com/a/942296