I'm new to tensorflow and was trying to follow the tutorial here https://cloud.google.com/tpu/docs/quickstart to run the MNIST TPU model.
I got error from
python3 mnist_main.py \
--tpu=$TPU_NAME \
--model_dir=$MODEL_DIR \
--data_dir=$DATA_DIR \
--train_epochs=10 \
--distribution_strategy=tpu \
--download
Error message
Traceback (most recent call last):
File "mnist_main.py", line 31, in <module>
from official.vision.image_classification.resnet import common
File "/usr/share/models/official/vision/image_classification/resnet/common.py", line 26, in <module>
import tensorflow_model_optimization as tfmot
ModuleNotFoundError: No module named 'tensorflow_model_optimization'
Any idea about to solve it ? Thank you.
You need to install it using command line (or terminal).
pip install --user --upgrade tensorflow-model-optimization
In Google Colab, if you are running a notebook using qkeras you need to do the following:
!git clone https://github.com/google/qkeras.git
import sys
sys.path.append('qkeras')
!pip install git+https://github.com/keras-team/keras-tuner.git
!pip install tensorflow_model_optimization
import tensorflow_model_optimization as tfmot
Related
I am changing pandas into cudf to make faster aggregating and reduce the processing speed. I figure out one library which works on GPU with pandas.
"CUDF LINK" https://github.com/rapidsai/cudf
When I entered the below to install in my project it gives an error and I also tried many version of numba.
conda install -c rapidsai -c nvidia -c numba -c conda-forge \
cudf=0.13 python=3.7 cudatoolkit=10.2
Traceback
Traceback (most recent call last):
File "/home/khawar/deepface/tests/Ensemble-Face-Recognition.py", line 5, in <module>
import cudf
File "/home/khawar/anaconda3/envs/deepface/lib/python3.7/site-packages/cudf/__init__.py", line 7, in <module>
from cudf import core, datasets
File "/home/khawar/anaconda3/envs/deepface/lib/python3.7/site-packages/cudf/core/__init__.py", line 3, in <module>
from cudf.core import buffer, column
File "/home/khawar/anaconda3/envs/deepface/lib/python3.7/site-packages/cudf/core/column/__init__.py", line 1, in <module>
from cudf.core.column.categorical import CategoricalColumn # noqa: F401
File "/home/khawar/anaconda3/envs/deepface/lib/python3.7/site-packages/cudf/core/column/categorical.py", line 11, in <module>
import cudf._libxx as libcudfxx
File "/home/khawar/anaconda3/envs/deepface/lib/python3.7/site-packages/cudf/_libxx/__init__.py", line 5, in <module>
from . import (
File "cudf/_libxx/aggregation.pxd", line 9, in init cudf._libxx.reduce
File "cudf/_libxx/aggregation.pyx", line 11, in init cudf._libxx.aggregation
File "/home/khawar/anaconda3/envs/deepface/lib/python3.7/site-packages/cudf/utils/cudautils.py", line 7, in <module>
from numba import cuda, numpy_support
ImportError: cannot import name 'numpy_support' from 'numba' (/home/khawar/anaconda3/envs/deepface/lib/python3.7/site-packages/numba/__init__.py)
When trying to install cuDF 0.13, conda is apparently finding a numba version that is incompatible with that cuDF 0.13.
cuDF 0.13 is out of date. The current stable release is 0.17 and the nightly is 0.18. We'll update the README, as it should provide installation instructions for the current version.
We recommend creating a fresh conda environment. Please try the following conda install command, found here:
conda create -n rapids-0.17 -c rapidsai -c nvidia -c conda-forge \
-c defaults rapids-blazing=0.17 python=3.7 cudatoolkit=10.2
I'm trying to train TF2 for object detection. When I run model_main_tf2.py, I get the following error:
Traceback (most recent call last):
File "C:\Python_venv\trained_models\model_main_tf2.py", line 32, in <module>
from object_detection import model_lib_v2
ImportError: cannot import name 'model_lib_v2' from 'object_detection' (c:\Python_venv\tensorflow\lib\site-packages\object_detection\__init__.py)
How do I install model_lib_v2?
I tried reinstalling TF and reinstalling TensorFlow-object-detection-API but no luck. I went all over the internet looking for answers.
I found:
https://github.com/tensorflow/models/issues/7920
But they don't say how to install model_lib_v2
Unfortunately I cannot use TF1, the goal is to use TF2.
see https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/tf2.md
git clone https://github.com/tensorflow/models.git
## Python Package Installation
cd models/research
### Compile protos.
protoc object_detection/protos/*.proto --python_out=.
### Install TensorFlow Object Detection API.
cp object_detection/packages/tf2/setup.py .
python3 -m pip install --user --use-feature=2020-resolver .
You should be able to just go to line 32 in "C:\Python_venv\trained_models\model_main_tf2.py" and remove "from object_detection", since you are already inside the package.
replace:
"from object_detection import model_lib_v2"
by:
"import model_lib_v2"
OS: Kubuntu 18.04
I have a Python program (program.py) that has this at the beginning:
import shlex
import sys
import notify2
import os
import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk
gi.require_version("AppIndicator3", "0.1")
from gi.repository import AppIndicator3
When I run it, this is what happens:
$ python3 /path/to/program.py
Traceback (most recent call last):
File "/path/to/program.py", line 34, in <module>
gi.require_version('AppIndicator3', '0.1')
File "/home/linuxbrew/.linuxbrew/Cellar/python#3.8/3.8.5/lib/python3.8/site-packages/gi/__init__.py", line 129, in require_version
raise ValueError('Namespace %s not available' % namespace)
ValueError: Namespace AppIndicator3 not available
Relevant info:
$ python3 --version
Python 3.8.5
$ pip3 freeze
dbus-python==1.2.16
docutils==0.16
formiko==1.4.3
libxml2-python==2.9.10
meson==0.55.1
notify2==0.3.1
pycairo==1.19.1
PyGObject==3.36.1
$ brew install gobject-introspection
Warning: gobject-introspection 1.64.1_2 is already installed and up-to-date
To reinstall 1.64.1_2, run `brew reinstall gobject-introspection`
I also have the following installed:
libappindicator3-1 is already the newest version (12.10.1+18.04.20180322.1-0ubuntu1).
gir1.2-appindicator3-0.1 is already the newest version (12.10.1+18.04.20180322.1-0ubuntu1).
python3-gi is already the newest version (3.26.1-2ubuntu1).
What might be keeping AppIndicator3 from being found?
Try taking off line 9 and import it directly.
I'm trying to use the Tensorflow Object Detection API and I've successfully tested the installation,but we I try to generate the PASCAL VOC TFRecord files with the given command
python object_detection/create_pascal_tf_record.py \
--label_map_path=object_detection/data/pascal_label_map.pbtxt \
--data_dir=VOCdevkit --year=VOC2012 --set=train \
--output_path=pascal_train.record
I encountered the following error:
Traceback (most recent call last):
File "object_detection/create_pascal_tf_record.py", line 36, in <module>
from object_detection.utils import dataset_util
ImportError: No module named object_detection.utils
my PYTHONPATH is:
:/usr/local/lib/python2.7/dist-packages/tensorflow/models:/usr/local/lib/python2.7/dist-packages/tensorflow/models/slim
and I'm running the above command in the /models directory,anyone who knows how to fix this problem?
I had the same problem and I solved it by adding :
import os
import sys
sys.path.append(os.path.abspath("./object_detection"))
and
from object_detection.utils import dataset_util
becomes
from utils import dataset_util
It's better for you to add 'object_detection' to the env path, not in the python script.
You can do this in the shell, at the 'object_detection' directory.
export PYTHONPATH=$PYTHONPATH:`pwd`
Or add the path to .bashrc/.zshrc (depend on your shell), so don‘t need to export every time.
echo "export PYTHONPATH=$PYTHONPATH:`pwd` >> ~/.bashrc
I would not be posting this question if I had not researched this problem thoroughly. I run python server.py (it uses sklearn). Which gives me
Traceback (most recent call last):
File "server.py", line 34, in <module>
from lotusApp.lotus import lotus
File "/Users/natumyers/Desktop/.dev/qq/lotusApp/lotus.py", line 2, in <module>
from sklearn import datasets
File "/Library/Python/2.7/site-packages/sklearn/__init__.py", line 57, in <module>
from .base import clone
File "/Library/Python/2.7/site-packages/sklearn/base.py", line 11, in <module>
from .utils.fixes import signature
File "/Library/Python/2.7/site-packages/sklearn/utils/__init__.py", line 10, in <module>
from .murmurhash import murmurhash3_32
File "numpy.pxd", line 155, in init sklearn.utils.murmurhash (sklearn/utils/murmurhash.c:5029)
ValueError: numpy.dtype has the wrong size, try recompiling
I next do everything I can, nothing helps.
I ran:
sudo -H pip uninstall numpy
sudo -H pip uninstall pandas
sudo -H pip install numpy
sudo -H pip install pandas
All which give me errors such as OSError: [Errno 1] Operation not permitted:
I try sudo -H easy_install --upgrade numpy
I get a list of errors like
_configtest.c:13:5: note: 'ctanl' is a builtin with type '_Complex long double (_Complex long double)'
_configtest.c:14:5: warning: incompatible redeclaration of library function 'cpowl' [-Wincompatible-library-redeclaration]
int cpowl (void);
^
Edit: Perhaps part of the issue was that I wasn't running the virtual environment. So I get that going, and when I type python server.py, I get error:
from sklearn import datasets
ImportError: No module named sklearn
sudo -H pip install -U scikit-learn Doesn't install because of another error....
I was using depreciated python. I updated everything to python 3, and used pip3.