running keras in jupyter notebook, windows 10,64 bit system - python-3.x

running keras gives me following error:
Using TensorFlow backend.
ERROR:root:Internal Python error in the inspect module.
Below is the traceback from this internal error.
ERROR:root:Internal Python error in the inspect module.
Below is the traceback from this internal error.
Traceback (most recent call last):
File "c:\users\chetan garg\appdata\local\programs\python\python36\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "c:\users\chetan garg\appdata\local\programs\python\python36\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "c:\users\chetan garg\appdata\local\programs\python\python36\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "c:\users\chetan garg\appdata\local\programs\python\python36\lib\imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "c:\users\chetan garg\appdata\local\programs\python\python36\lib\imp.py", line 343, in load_dynamic
return _load(spec)
ImportError: DLL load failed: The specified module could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\users\chetan garg\appdata\local\programs\python\python36\lib\site-packages\IPython\core\interactiveshell.py", line 2034, in showtraceback
stb = value._render_traceback_()
AttributeError: 'ImportError' object has no attribute '_render_traceback_'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\users\chetan garg\appdata\local\programs\python\python36\lib\site-packages\IPython\core\interactiveshell.py", line 3242, in run_ast_nodes
if (await self.run_code(code, result, async_=asy)):
File "c:\users\chetan garg\appdata\local\programs\python\python36\lib\site-packages\IPython\core\interactiveshell.py", line 3336, in run_code
self.showtraceback(running_compiled_code=True)
File "c:\users\chetan garg\appdata\local\programs\python\python36\lib\site-packages\IPython\core\interactiveshell.py", line 2037, in showtraceback
value, tb, tb_offset=tb_offset)
File "c:\users\chetan garg\appdata\local\programs\python\python36\lib\site-packages\IPython\core\ultratb.py", line 1418, in structured_traceback
self, etype, value, tb, tb_offset, number_of_lines_of_context)
File "c:\users\chetan garg\appdata\local\programs\python\python36\lib\site-packages\IPython\core\ultratb.py", line 1318, in structured_traceback
self, etype, value, tb, tb_offset, number_of_lines_of_context
File "c:\users\chetan garg\appdata\local\programs\python\python36\lib\site-packages\IPython\core\ultratb.py", line 1186, in structured_traceback
formatted_exceptions += self.prepare_chained_exception_message(evalue.__cause__)
TypeError: must be str, not list
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\users\chetan garg\appdata\local\programs\python\python36\lib\site-packages\IPython\core\interactiveshell.py", line 2034, in showtraceback
stb = value._render_traceback_()
AttributeError: 'TypeError' object has no attribute '_render_traceback_'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\users\chetan garg\appdata\local\programs\python\python36\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "c:\users\chetan garg\appdata\local\programs\python\python36\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "c:\users\chetan garg\appdata\local\programs\python\python36\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "c:\users\chetan garg\appdata\local\programs\python\python36\lib\imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "c:\users\chetan garg\appdata\local\programs\python\python36\lib\imp.py", line 343, in load_dynamic
return _load(spec)
ImportError: DLL load failed: The specified module could not be found.
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/errors
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
c:\users\chetan garg\appdata\local\programs\python\python36\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py in <module>
57
---> 58 from tensorflow.python.pywrap_tensorflow_internal import *
59 from tensorflow.python.pywrap_tensorflow_internal import __version__
c:\users\chetan garg\appdata\local\programs\python\python36\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py in <module>
27 return _mod
---> 28 _pywrap_tensorflow_internal = swig_import_helper()
29 del swig_import_helper
c:\users\chetan garg\appdata\local\programs\python\python36\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py in swig_import_helper()
23 try:
---> 24 _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
25 finally:
c:\users\chetan garg\appdata\local\programs\python\python36\lib\imp.py in load_module(name, file, filename, details)
242 else:
--> 243 return load_dynamic(name, filename, file)
244 elif type_ == PKG_DIRECTORY:
c:\users\chetan garg\appdata\local\programs\python\python36\lib\imp.py in load_dynamic(name, path, file)
342 name=name, loader=loader, origin=path)
--> 343 return _load(spec)
344
ImportError: DLL load failed: The specified module could not be found.
During handling of the above exception, another exception occurred
During handling of the above exception, another exception occurred:
AttributeError Traceback (most recent call last)
c:\users\chetan garg\appdata\local\programs\python\python36\lib\site-packages\IPython\core\interactiveshell.py in showtraceback(self, exc_tuple, filename, tb_offset, exception_only, running_compiled_code)
2033 # in the engines. This should return a list of strings.
-> 2034 stb = value._render_traceback_()
2035 except Exception:
AttributeError: 'ImportError' object has no attribute '_render_traceback_'
During handling of the above exception, another exception occurred:
TypeError Traceback (most recent call last)
c:\users\chetan garg\appdata\local\programs\python\python36\lib\site-packages\IPython\core\interactiveshell.py in run_code(self, code_obj, result, async_)
3334 if result is not None:
3335 result.error_in_exec = sys.exc_info()[1]
-> 3336 self.showtraceback(running_compiled_code=True)
3337 else:
3338 outflag = False
c:\users\chetan garg\appdata\local\programs\python\python36\lib\site-packages\IPython\core\interactiveshell.py in showtraceback(self, exc_tuple, filename, tb_offset, exception_only, running_compiled_code)
2035 except Exception:
2036 stb = self.InteractiveTB.structured_traceback(etype,
-> 2037 value, tb, tb_offset=tb_offset)
2038
2039 self._showtraceback(etype, value, stb)
c:\users\chetan garg\appdata\local\programs\python\python36\lib\site-packages\IPython\core\ultratb.py in structured_traceback(self, etype, value, tb, tb_offset, number_of_lines_of_context)
1416 self.tb = tb
1417 return FormattedTB.structured_traceback(
-> 1418 self, etype, value, tb, tb_offset, number_of_lines_of_context)
1419
1420
c:\users\chetan garg\appdata\local\programs\python\python36\lib\site-packages\IPython\core\ultratb.py in structured_traceback(self, etype, value, tb, tb_offset, number_of_lines_of_context)
1316 # Verbose modes need a full traceback
1317 return VerboseTB.structured_traceback(
-> 1318 self, etype, value, tb, tb_offset, number_of_lines_of_context
1319 )
1320 elif mode == 'Minimal':
c:\users\chetan garg\appdata\local\programs\python\python36\lib\site-packages\IPython\core\ultratb.py in structured_traceback(self, etype, evalue, etb, tb_offset, number_of_lines_of_context)
1184 exception = self.get_parts_of_chained_exception(evalue)
1185 if exception:
-> 1186 formatted_exceptions += self.prepare_chained_exception_message(evalue.__cause__)
1187 etype, evalue, etb = exception
1188 else:
TypeError: must be str, not list
n_pts = 100

Try uninstall and install TensorFlow. If you use conda:
conda uninstall tensorflow
conda uninstall keras
conda install tensorflow
conda install keras
Next time, it is better to provide the code you run, not just error. In that case, people can better help you.

Related

Multi-GPU inference with Luke NER not working

I'm trying to run Luke for inference on multiple gpus using DataParallel but I'm encountering an error that I can't seem to resolve. Can you help ?
Here is my code
from transformers import LukeTokenizer, LukeForEntitySpanClassification
import torch
luke_model = LukeForEntitySpanClassification.from_pretrained("studio-ousia/luke-large-finetuned-conll-2003")
#Getting inputs (type : transformers.tokenization_utils_base.BatchEncoding)
inputs = []
for i in tqdm(range(10)):
input_filepath = df["input_filepath"].iloc[i]
handle = open(input_filepath,'rb')
input_tensor = pickle.load(handle)
inputs.append(input_tensor)
device_ids = [0,1,2,3]
model= torch.nn.DataParallel(luke_model)
model.to("cuda")
replicas = nn.parallel.replicate(model,device_ids)
inputs_dp = nn.parallel.scatter(inputs[:4], device_ids)
outputs = nn.parallel.parallel_apply(replicas, inputs_dp)`
The error I get is :
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<command-1863732679336681> in <module>
21
22 inputs_dp = nn.parallel.scatter(inputs[:4], device_ids)
---> 23 outputs = nn.parallel.parallel_apply(replicas, inputs_dp)
/databricks/python/lib/python3.8/site-packages/torch/nn/parallel/parallel_apply.py in parallel_apply(modules, inputs, kwargs_tup, devices)
84 output = results[i]
85 if isinstance(output, ExceptionWrapper):
---> 86 output.reraise()
87 outputs.append(output)
88 return outputs
/databricks/python/lib/python3.8/site-packages/torch/_utils.py in reraise(self)
432 # instantiate since we don't know how to
433 raise RuntimeError(msg) from None
--> 434 raise exception
435
436
AttributeError: Caught AttributeError in replica 0 on device 0.
Original Traceback (most recent call last):
File "/databricks/python/lib/python3.8/site-packages/torch/nn/parallel/parallel_apply.py", line 61, in _worker
output = module(*input, **kwargs)
File "/databricks/python/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "/databricks/python/lib/python3.8/site-packages/torch/nn/parallel/data_parallel.py", line 168, in forward
outputs = self.parallel_apply(replicas, inputs, kwargs)
File "/databricks/python/lib/python3.8/site-packages/torch/nn/parallel/data_parallel.py", line 178, in parallel_apply
return parallel_apply(replicas, inputs, kwargs, self.device_ids[:len(replicas)])
File "/databricks/python/lib/python3.8/site-packages/torch/nn/parallel/parallel_apply.py", line 86, in parallel_apply
output.reraise()
File "/databricks/python/lib/python3.8/site-packages/torch/_utils.py", line 434, in reraise
raise exception
AttributeError: Caught AttributeError in replica 0 on device 0.
Original Traceback (most recent call last):
File "/databricks/python/lib/python3.8/site-packages/transformers/tokenization_utils_base.py", line 250, in __getattr__
return self.data[item]
KeyError: 'size'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/databricks/python/lib/python3.8/site-packages/torch/nn/parallel/parallel_apply.py", line 61, in _worker
output = module(*input, **kwargs)
File "/databricks/python/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "/databricks/python/lib/python3.8/site-packages/transformers/models/luke/modeling_luke.py", line 1583, in forward
outputs = self.luke(
File "/databricks/python/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "/databricks/python/lib/python3.8/site-packages/transformers/models/luke/modeling_luke.py", line 977, in forward
input_shape = input_ids.size()
File "/databricks/python/lib/python3.8/site-packages/transformers/tokenization_utils_base.py", line 252, in __getattr__
raise AttributeError
AttributeError
I tried adding
class MyDataParallel(nn.DataParallel):
def __getattr__(self, name):
return getattr(self.module, name)
But I get : RecursionError: maximum recursion depth exceeded while calling a Python object
Thanks in advance!

I am getting TypeError: '(slice(None, None, None), None)' is an invalid key when I use pandas in my new computer

I am running a code in a new computer (the code works perfectly in my old computer) and I get the following errors:
Traceback (most recent call last):
File ~\anaconda3\lib\site-packages\pandas\core\indexes\base.py:3621 in get_loc
return self._engine.get_loc(casted_key)
File pandas\_libs\index.pyx:136 in pandas._libs.index.IndexEngine.get_loc
File pandas\_libs\index.pyx:142 in pandas._libs.index.IndexEngine.get_loc
TypeError: '(slice(None, None, None), None)' is an invalid key
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File ~...\temp.py:364 in <module>
ax.plot(pd.to_datetime(hodls.index, unit="s"), hodls)
File ~\anaconda3\lib\site-packages\matplotlib\axes\_axes.py:1632 in plot
lines = [*self._get_lines(*args, data=data, **kwargs)]
File ~\anaconda3\lib\site-packages\matplotlib\axes\_base.py:312 in __call__
yield from self._plot_args(this, kwargs)
File ~\anaconda3\lib\site-packages\matplotlib\axes\_base.py:488 in _plot_args
y = _check_1d(xy[1])
File ~\anaconda3\lib\site-packages\matplotlib\cbook\__init__.py:1327 in _check_1d
ndim = x[:, None].ndim
File ~\anaconda3\lib\site-packages\pandas\core\frame.py:3505 in __getitem__
indexer = self.columns.get_loc(key)
File ~\anaconda3\lib\site-packages\pandas\core\indexes\base.py:3628 in get_loc
self._check_indexing_error(key)
File ~\anaconda3\lib\site-packages\pandas\core\indexes\base.py:5637 in _check_indexing_error
raise InvalidIndexError(key)
InvalidIndexError: (slice(None, None, None), None)
Can anybody help me?

Pyttsx3 Voice KeyError: 'sapi5'

Getting unknown voice id error. I tried with ( Pyttsx3 2.6 and python 3.6 ), ( pyttsx3==2.9 & python 3.10)
Traceback (most recent call last):
File "E:\anaconda3\envs\dummy\lib\site-packages\pyttsx3\__init__.py", line 44, in init
eng = _activeEngines[driverName]
File "E:\anaconda3\envs\dummy\lib\weakref.py", line 137, in __getitem__
o = self.data[key]()
KeyError: None
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/Dnyanesh/PycharmProjects/dummy/main.py", line 5, in <module>
engine = pyttsx3.init()
File "E:\anaconda3\envs\dummy\lib\site-packages\pyttsx3\__init__.py", line 46, in init
eng = Engine(driverName, debug)
File "E:\anaconda3\envs\dummy\lib\site-packages\pyttsx3\engine.py", line 52, in __init__
self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug)
File "E:\anaconda3\envs\dummy\lib\site-packages\pyttsx3\driver.py", line 77, in __init__
self._driver = self._module.buildDriver(weakref.proxy(self))
File "E:\anaconda3\envs\dummy\lib\site-packages\pyttsx3\drivers\sapi5.py", line 22, in buildDriver
return SAPI5Driver(proxy)
File "E:\anaconda3\envs\dummy\lib\site-packages\pyttsx3\drivers\sapi5.py", line 41, in __init__
self.setProperty('voice', self.getProperty('voice'))
File "E:\anaconda3\envs\dummy\lib\site-packages\pyttsx3\drivers\sapi5.py", line 82, in setProperty
token = self._tokenFromId(value)
File "E:\anaconda3\envs\dummy\lib\site-packages\pyttsx3\drivers\sapi5.py", line 66, in _tokenFromId
raise ValueError('unknown voice id %s', id_)
ValueError: ('unknown voice id %s', 'HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Speech_OneCore\\Voices\\Tokens\\MSTTS_V110_enUS_DavidM')

Serialization error with Spark Pandas_UDF

I have a python function that I converted to Pandas_UDF function and it worked fine up until last week but getting the below error from the last few days. We tried a simple python function with Pandas UDF and it is not throwing this error. I am not sure what exactly in my code is causing this. Has there been any change to spark environment. I am using Azure Databricks if it helps.
Search only turned up the this link but it is old.
Appreciate any pointers on how to fix this issue.
Thanks,
Yudi
SparkException: Job aborted due to stage failure: Task 0 in stage 23.0 failed 4 times, most recent failure: Lost task 0.3 in stage 23.0 (TID 252, 172.17.69.7, executor 0): org.apache.spark.api.python.PythonException: Traceback (most recent call last):
File "/databricks/spark/python/pyspark/serializers.py", line 180, in _read_with_length
return self.loads(obj)
File "/databricks/spark/python/pyspark/serializers.py", line 669, in loads
return pickle.loads(obj, encoding=encoding)
File "/databricks/spark/python/pyspark/cloudpickle.py", line 875, in subimport
import(name)
ImportError: No module named '_pandasujson'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/databricks/spark/python/pyspark/worker.py", line 394, in main
func, profiler, deserializer, serializer = read_udfs(pickleSer, infile, eval_type)
File "/databricks/spark/python/pyspark/worker.py", line 234, in read_udfs
arg_offsets, udf = read_single_udf(pickleSer, infile, eval_type, runner_conf)
File "/databricks/spark/python/pyspark/worker.py", line 160, in read_single_udf
f, return_type = read_command(pickleSer, infile)
File "/databricks/spark/python/pyspark/worker.py", line 69, in read_command
command = serializer._read_with_length(file)
File "/databricks/spark/python/pyspark/serializers.py", line 183, in _read_with_length
raise SerializationError("Caused by " + traceback.format_exc())
pyspark.serializers.SerializationError: Caused by Traceback (most recent call last):
File "/databricks/spark/python/pyspark/serializers.py", line 180, in _read_with_length
return self.loads(obj)
File "/databricks/spark/python/pyspark/serializers.py", line 669, in loads
return pickle.loads(obj, encoding=encoding)
File "/databricks/spark/python/pyspark/cloudpickle.py", line 875, in subimport
import(name)
ImportError: No module named '_pandasujson'

I installed tensorflow and tensorflow_gpu on my Windows 10 64-bit OS with PyCharm and Python 3.7.2. But i get these errors while using tensorflow

Traceback (most recent call last): File "C:\Users\sai
kushal\PycharmProjects\live\venv\lib\site-packages\tensorflow\python\pywrap_tensorflow.py",
line 58, in
from tensorflow.python.pywrap_tensorflow_internal import * File "C:\Users\sai
kushal\PycharmProjects\live\venv\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py",
line 28, in
_pywrap_tensorflow_internal = swig_import_helper() File "C:\Users\sai
kushal\PycharmProjects\live\venv\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py",
line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description) File "C:\Users\sai
kushal\AppData\Local\Programs\Python\Python37\lib\imp.py", line 242,
in load_module
return load_dynamic(name, filename, file) File "C:\Users\sai kushal\AppData\Local\Programs\Python\Python37\lib\imp.py", line 342,
in load_dynamic
return _load(spec) ImportError: DLL load failed: The specified module could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "C:/Users/sai
kushal/PycharmProjects/live/testing_2.py", line 1, in
import tensorflow as tf File "C:\Users\sai kushal\PycharmProjects\live\venv\lib\site-packages\tensorflow__init__.py",
line 24, in
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import File "C:\Users\sai
kushal\PycharmProjects\live\venv\lib\site-packages\tensorflow\python__init__.py",
line 49, in
from tensorflow.python import pywrap_tensorflow File "C:\Users\sai
kushal\PycharmProjects\live\venv\lib\site-packages\tensorflow\python\pywrap_tensorflow.py",
line 74, in
raise ImportError(msg) ImportError: Traceback (most recent call last): File "C:\Users\sai
kushal\PycharmProjects\live\venv\lib\site-packages\tensorflow\python\pywrap_tensorflow.py",
line 58, in
from tensorflow.python.pywrap_tensorflow_internal import * File "C:\Users\sai
kushal\PycharmProjects\live\venv\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py",
line 28, in
_pywrap_tensorflow_internal = swig_import_helper() File "C:\Users\sai
kushal\PycharmProjects\live\venv\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py",
line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description) File "C:\Users\sai
kushal\AppData\Local\Programs\Python\Python37\lib\imp.py", line 242,
in load_module
return load_dynamic(name, filename, file) File "C:\Users\sai kushal\AppData\Local\Programs\Python\Python37\lib\imp.py", line 342,
in load_dynamic
return _load(spec) ImportError: DLL load failed: The specified module could not be found.
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/errors for some common reasons
and solutions. Include the entire stack trace above this error message
when asking for help.
Python 3.7 doesn't support tensorflow yet, use python 3.6 Instead, that should fix this error, if it doesn't, comment below.

Resources