cuDNN error: CUDNN_STATUS_EXECUTION_FAILED while using flair - pytorch

I have been using https://github.com/zalandoresearch/flair#example-usage
tried using flair to experiment flair but then I don't know why I am not able to use the GPU.
and tried the following:
>>> from flair.data import Sentence
>>> from flair.models import SequenceTagger
>>> sentence = Sentence('I love Berlin .')
>>> tagger = SequenceTagger.load('ner')
2019-07-20 17:52:15,062 loading file /home/vz/.flair/models/en-ner-conll03-v0.4.pt
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/vz/miniconda3/envs/gp/lib/python3.6/site-packages/flair/nn.py", line 103, in load
model = cls._init_model_with_state_dict(state)
File "/home/vz/miniconda3/envs/gp/lib/python3.6/site-packages/flair/models/sequence_tagger_model.py", line 205, in _init_model_with_state_dict
locked_dropout=use_locked_dropout,
File "/home/vz/miniconda3/envs/gp/lib/python3.6/site-packages/flair/models/sequence_tagger_model.py", line 166, in __init__
self.to(flair.device)
File "/home/vz/miniconda3/envs/gp/lib/python3.6/site-packages/torch/nn/modules/module.py", line 386, in to
return self._apply(convert)
File "/home/vz/miniconda3/envs/gp/lib/python3.6/site-packages/torch/nn/modules/module.py", line 193, in _apply
module._apply(fn)
File "/home/vz/miniconda3/envs/gp/lib/python3.6/site-packages/torch/nn/modules/module.py", line 193, in _apply
module._apply(fn)
File "/home/vz/miniconda3/envs/gp/lib/python3.6/site-packages/torch/nn/modules/module.py", line 193, in _apply
module._apply(fn)
[Previous line repeated 1 more time]
File "/home/vz/miniconda3/envs/gp/lib/python3.6/site-packages/torch/nn/modules/rnn.py", line 127, in _apply
self.flatten_parameters()
File "/home/vz/miniconda3/envs/gp/lib/python3.6/site-packages/torch/nn/modules/rnn.py", line 123, in flatten_parameters
self.batch_first, bool(self.bidirectional))
RuntimeError: cuDNN error: CUDNN_STATUS_EXECUTION_FAILED
Can anyone please help me as to how to fix this error ?
Thanks in advance.

The error is with my machine and CUDNN requirement i would suggest every one to install pytorch with conda so the way to install should be something like this
conda install pytorch torchvision cudatoolkit=9.0 -c pytorch
to Eradicate any kind of issues with the installation.

Related

RuntimeError: The 'data' object was created by an older version of PyG

thanks for your great contribution to the science:
I have installed the following pytorch and pytorch_gemetric versions as you have mentioned in this link:
conda create -n tox-env python=3.6
conda install pytorch=1.6.0 torchvision torchaudio cudatoolkit=10.2 -c pytorch
pip install torch-scatter==2.0.6 torch-sparse==0.6.9 -f https://pytorch-geometric.com/whl/torch-1.6.0+cu102.html
pip install torch-geometric==2.0.0
The reason is that I am trying to run the code from a GitHub repositorty, when it reaches to this line, it was raising an error (in the latest version of pytorch). Then I had to downgrade the pyG and pytorch versions, however, I am getting the following error:
/home/es/anaconda3/envs/tox-env/bin/python /home/es/PycharmProjects/1-Meta-MGNN/Meta-MGNN/main.py
/home/es/anaconda3/envs/tox-env/lib/python3.6/site-packages/torch/cuda/__init__.py:125: UserWarning:
NVIDIA GeForce RTX 3090 Ti with CUDA capability sm_86 is not compatible with the current PyTorch installation.
The current PyTorch install supports CUDA capabilities sm_37 sm_50 sm_60 sm_61 sm_70 sm_75 compute_37.
If you want to use the NVIDIA GeForce RTX 3090 Ti GPU with PyTorch, please check the instructions at https://pytorch.org/get-started/locally/
warnings.warn(incompatible_device_warn.format(device_name, capability, " ".join(arch_list), device_name))
tox21
Iteration: 0%| | 0/2 [00:00<?, ?it/s]
Traceback (most recent call last):
File "/home/es/PycharmProjects/1-Meta-MGNN/Meta-MGNN/main.py", line 131, in <module>
main("tox21", "model_gin/supervised_contextpred.pth", "gin", True, True, True, 0.1, 5)
File "/home/es/PycharmProjects/1-Meta-MGNN/Meta-MGNN/main.py", line 105, in main
support_grads = model(epoch)
File "/home/es/anaconda3/envs/tox-env/lib/python3.6/site-packages/torch/nn/modules/module.py", line 722, in _call_impl
result = self.forward(*input, **kwargs)
File "/home/es/PycharmProjects/1-Meta-MGNN/Meta-MGNN/meta_model.py", line 183, in forward
for step, batch in enumerate(tqdm(support_loaders[task], desc="Iteration")):
File "/home/es/anaconda3/envs/tox-env/lib/python3.6/site-packages/tqdm/std.py", line 1195, in __iter__
for obj in iterable:
File "/home/es/anaconda3/envs/tox-env/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 363, in __next__
data = self._next_data()
File "/home/es/anaconda3/envs/tox-env/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 989, in _next_data
return self._process_data(data)
File "/home/es/anaconda3/envs/tox-env/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 1014, in _process_data
data.reraise()
File "/home/es/anaconda3/envs/tox-env/lib/python3.6/site-packages/torch/_utils.py", line 395, in reraise
raise self.exc_type(msg)
RuntimeError: Caught RuntimeError in DataLoader worker process 0.
Original Traceback (most recent call last):
File "/home/es/anaconda3/envs/tox-env/lib/python3.6/site-packages/torch/utils/data/_utils/worker.py", line 185, in _worker_loop
data = fetcher.fetch(index)
File "/home/es/anaconda3/envs/tox-env/lib/python3.6/site-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/home/es/anaconda3/envs/tox-env/lib/python3.6/site-packages/torch/utils/data/_utils/fetch.py", line 44, in <listcomp>
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/home/es/anaconda3/envs/tox-env/lib/python3.6/site-packages/torch_geometric/data/dataset.py", line 198, in __getitem__
data = self.get(self.indices()[idx])
File "/home/es/PycharmProjects/1-Meta-MGNN/Meta-MGNN/loader.py", line 142, in get
for key in self.data.keys:
File "/home/es/anaconda3/envs/tox-env/lib/python3.6/site-packages/torch_geometric/data/data.py", line 103, in keys
for store in self.stores:
File "/home/es/anaconda3/envs/tox-env/lib/python3.6/site-packages/torch_geometric/data/data.py", line 393, in stores
return [self._store]
File "/home/es/anaconda3/envs/tox-env/lib/python3.6/site-packages/torch_geometric/data/data.py", line 341, in __getattr__
"The 'data' object was created by an older version of PyG. "
RuntimeError: The 'data' object was created by an older version of PyG. If this error occurred while loading an already existing dataset, remove the 'processed/' directory in the dataset's root folder and try again.
Process finished with exit code 1

How to fix AttributeError: module 'tensorflow' has no attribute 'space_to_depth'

I have python 3.7.4 installed and tensorflow version 2.2.0 installed on my Windows 10 x64.
I am trying to execute this:
yolo_model = load_model("model_data/yolo.h5")
And it gives the mentioned error
Here is the stack trace:
Traceback (most recent call last):
File "Object Detection.py", line 78, in <module>
yolo_model = load_model("model_data/yolo.h5")
File "E:\Python37\lib\site-packages\keras\engine\saving.py", line 492, in load_wrapper
return load_function(*args, **kwargs)
File "E:\Python37\lib\site-packages\keras\engine\saving.py", line 584, in load_model
model = _deserialize_model(h5dict, custom_objects, compile)
File "E:\Python37\lib\site-packages\keras\engine\saving.py", line 274, in _deserialize_model
model = model_from_config(model_config, custom_objects=custom_objects)
File "E:\Python37\lib\site-packages\keras\engine\saving.py", line 627, in model_from_config
return deserialize(config, custom_objects=custom_objects)
File "E:\Python37\lib\site-packages\keras\layers\__init__.py", line 168, in deserialize
printable_module_name='layer')
File "E:\Python37\lib\site-packages\keras\utils\generic_utils.py", line 147, in deserialize_keras_object
list(custom_objects.items())))
File "E:\Python37\lib\site-packages\keras\engine\network.py", line 1075, in from_config
process_node(layer, node_data)
File "E:\Python37\lib\site-packages\keras\engine\network.py", line 1025, in process_node
layer(unpack_singleton(input_tensors), **kwargs)
File "E:\Python37\lib\site-packages\keras\backend\tensorflow_backend.py", line 75, in symbolic_fn_wrapper
return func(*args, **kwargs)
File "E:\Python37\lib\site-packages\keras\engine\base_layer.py", line 489, in __call__
output = self.call(inputs, **kwargs)
File "E:\Python37\lib\site-packages\keras\layers\core.py", line 716, in call
return self.function(inputs, **arguments)
File "/Users/kian/Desktop/floydhub/yolo-03-oct/YAD2K/yad2k/models/keras_yolo.py", line 32, in space_to_depth_x2
AttributeError: module 'tensorflow' has no attribute 'space_to_depth'
I think location of module is different, FYI
tensorflow 1.x : tensorflow.space_to_depth
tensorflow 2.x : tensorflow.nn.space_to_depth
Seem to be conflict tensorflow version and keras version. Downgrade tensorflow to 1.14.0 and keras to 2.3.1 fix the problem
Think location of module is different, FYI:
tensorflow 1.x: tensorflow.space_to_depth
tensorflow 2.: tensorflow.nn.space_to_depth
Yes it worked.

astropy.extern.configobj.configobj.ConfigObjError: Parsing failed with several errors

When I import the astropy package, I got the following error message.
>>> import astropy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/lalitawadee/anaconda3/lib/python3.7/site-packages/astropy/__init__.py", line 288, in <module>
log = _init_log()
File "/home/lalitawadee/anaconda3/lib/python3.7/site-packages/astropy/logger.py", line 97, in _init_log
log._set_defaults()
File "/home/lalitawadee/anaconda3/lib/python3.7/site-packages/astropy/logger.py", line 473, in _set_defaults
self.setLevel(conf.log_level)
File "/home/lalitawadee/anaconda3/lib/python3.7/site-packages/astropy/config/configuration.py", line 273, in __get__
return self()
File "/home/lalitawadee/anaconda3/lib/python3.7/site-packages/astropy/config/configuration.py", line 396, in __call__
sec = get_config(self.module)
File "/home/lalitawadee/anaconda3/lib/python3.7/site-packages/astropy/config/configuration.py", line 530, in get_config
cobj = configobj.ConfigObj(cfgfn, interpolation=False)
File "/home/lalitawadee/anaconda3/lib/python3.7/site-packages/astropy/extern/configobj/configobj.py", line 1227, in __init__
self._load(infile, configspec)
File "/home/lalitawadee/anaconda3/lib/python3.7/site-packages/astropy/extern/configobj/configobj.py", line 1316, in _load
raise error
astropy.extern.configobj.configobj.ConfigObjError: Parsing failed with several errors.
First error at line 142.
I've already tried to remove Anaconda and re-install it, but the problem still remains. Could you please help me with this? Thank you in advance.
It sounds like you somehow have a corrupt astropy config file somewhere. It would help if the error message gave the filename, but see http://docs.astropy.org/en/stable/config/ for possible locations.
For starters, I would try something at the command-line like
$ mv ~/.astropy/ ~/.astropy.bak
and try again. I don't think this should have anything specifically to do with Anaconda.

spaCy produces "PicklingError: Could not pickle object as excessively deep recursion required." after the first run (second run onwards)

I currently work on spaCy on Spyder3 editor.
But after the first run of below simple code. It gives me the error
"PicklingError: Could not pickle object as excessively deep recursion required."
Could you help me resolve the issue? Am I missing any additional code or settings?
Thanks,
Saul
I could run the code with no issue on jupyter notebook, but it fails on Spyder3.
import spacy
nlp = spacy.load('en_core_web_sm')
It should run without any error.
I have already installed 'en_core_web_sm'
I am not sure what the problem is.
please find whole error message below.
Reloaded modules: __mp_main__, spacy, thinc, thinc.about, thinc.neural, thinc.neural._classes, thinc.neural._classes.model, srsly, srsly._json_api, srsly.ujson, srsly.ujson.ujson, srsly.util, srsly._msgpack_api, srsly.msgpack, srsly.msgpack._version, srsly.msgpack.exceptions, srsly.msgpack._packer, srsly.msgpack._unpacker, srsly.msgpack._ext_type, srsly.msgpack._msgpack_numpy, srsly._pickle_api, srsly.cloudpickle, srsly.cloudpickle.cloudpickle, thinc.neural.util, thinc.neural.train, tqdm, tqdm._tqdm, tqdm._utils, tqdm._monitor, tqdm._tqdm_gui, tqdm._tqdm_pandas, tqdm._main, tqdm._version, thinc.neural.optimizers, thinc.neural.ops, thinc.neural.mem, thinc.check, thinc.compat, thinc.extra, thinc.extra.wrapt, thinc.extra.wrapt.wrappers, thinc.extra.wrapt._wrappers, thinc.extra.wrapt.decorators, thinc.extra.wrapt.importer, thinc.exceptions, wasabi, wasabi.printer, wasabi.tables, wasabi.util, wasabi.traceback, spacy.cli, spacy.cli.download, plac, plac_core, plac_ext, spacy.cli.link, spacy.compat, spacy.util, pkg_resources, pkg_resources.extern, pkg_resources._vendor, pkg_resources.extern.six, pkg_resources.py31compat, pkg_resources.extern.appdirs, pkg_resources._vendor.packaging.__about__, pkg_resources.extern.packaging, pkg_resources.extern.packaging.version, pkg_resources.extern.packaging._structures, pkg_resources.extern.packaging.specifiers, pkg_resources.extern.packaging._compat, pkg_resources.extern.packaging.requirements, pkg_resources.extern.pyparsing, pkg_resources.extern.packaging.markers, jsonschema, jsonschema.exceptions, attr, attr.converters, attr._make, attr._config, attr._compat, attr.exceptions, attr.filters, attr.validators, attr._funcs, jsonschema._utils, jsonschema.compat, jsonschema._format, jsonschema._types, pyrsistent, pyrsistent._pmap, pyrsistent._compat, pyrsistent._pvector, pyrsistent._transformations, pvectorc, pyrsistent._pset, pyrsistent._pbag, pyrsistent._plist, pyrsistent._pdeque, pyrsistent._checked_types, pyrsistent._field_common, pyrsistent._precord, pyrsistent._pclass, pyrsistent._immutable, pyrsistent._helpers, pyrsistent._toolz, jsonschema.validators, jsonschema._legacy_validators, jsonschema._validators, spacy.symbols, spacy.errors, spacy.about, spacy.cli.info, spacy.cli.package, spacy.cli.profile, thinc.extra.datasets, thinc.extra._vendorized, thinc.extra._vendorized.keras_data_utils, thinc.extra._vendorized.keras_generic_utils, spacy.cli.train, spacy._ml, thinc.v2v, thinc.neural._classes.affine, thinc.describe, thinc.neural._classes.relu, thinc.neural._classes.maxout, thinc.neural._classes.softmax, thinc.neural._classes.selu, thinc.i2v, thinc.neural._classes.hash_embed, thinc.neural._lsuv, thinc.neural._classes.embed, thinc.neural._classes.static_vectors, thinc.extra.load_nlp, thinc.t2t, thinc.neural._classes.convolution, thinc.neural._classes.attention, thinc.neural._classes.rnn, thinc.api, thinc.neural._classes.function_layer, thinc.neural._classes.feed_forward, thinc.t2v, thinc.neural.pooling, thinc.misc, thinc.neural._classes.batchnorm, thinc.neural._classes.layernorm, thinc.neural._classes.resnet, thinc.neural._classes.feature_extracter, thinc.linear, thinc.linear.linear, spacy.attrs, spacy.gold, spacy.cli.pretrain, spacy.tokens, spacy.tokens.doc, spacy.tokens.token, spacy.tokens.span, spacy.cli.debug_data, spacy.cli.evaluate, spacy.displacy, spacy.displacy.render, spacy.displacy.templates, spacy.cli.convert, spacy.cli.converters, spacy.cli.converters.conllu2json, spacy.cli.converters.iob2json, spacy.cli.converters.conll_ner2json, spacy.cli.converters.jsonl2json, spacy.cli.init_model, preshed, preshed.about, preshed.counter, spacy.vectors, spacy.cli.validate, spacy.glossary
Traceback (most recent call last):
File "<ipython-input-5-e0e768bc0aee>", line 1, in <module>
runfile('/home/saul/pythontraining/NLP/itemWork_3.py', wdir='/home/saul/pythontraining/NLP')
File "/home/saul/anaconda3/lib/python3.7/site-packages/spyder_kernels/customize/spydercustomize.py", line 786, in runfile
execfile(filename, namespace)
File "/home/saul/anaconda3/lib/python3.7/site-packages/spyder_kernels/customize/spydercustomize.py", line 110, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "/home/saul/pythontraining/NLP/itemWork_3.py", line 11, in <module>
nlp = spacy.load('en_core_web_sm')
File "/home/saul/.local/lib/python3.7/site-packages/spacy/__init__.py", line 27, in load
return util.load_model(name, **overrides)
File "/home/saul/.local/lib/python3.7/site-packages/spacy/util.py", line 131, in load_model
return load_model_from_package(name, **overrides)
File "/home/saul/.local/lib/python3.7/site-packages/spacy/util.py", line 152, in load_model_from_package
return cls.load(**overrides)
File "/home/saul/anaconda3/lib/python3.7/site-packages/en_core_web_sm/__init__.py", line 12, in load
return load_model_from_init_py(__file__, **overrides)
File "/home/saul/.local/lib/python3.7/site-packages/spacy/util.py", line 190, in load_model_from_init_py
return load_model_from_path(data_path, meta, **overrides)
File "/home/saul/.local/lib/python3.7/site-packages/spacy/util.py", line 173, in load_model_from_path
return nlp.from_disk(model_path)
File "/home/saul/.local/lib/python3.7/site-packages/spacy/language.py", line 791, in from_disk
util.from_disk(path, deserializers, exclude)
File "/home/saul/.local/lib/python3.7/site-packages/spacy/util.py", line 630, in from_disk
reader(path / key)
File "/home/saul/.local/lib/python3.7/site-packages/spacy/language.py", line 787, in <lambda>
deserializers[name] = lambda p, proc=proc: proc.from_disk(p, exclude=["vocab"])
File "pipes.pyx", line 617, in spacy.pipeline.pipes.Tagger.from_disk
File "/home/saul/.local/lib/python3.7/site-packages/spacy/util.py", line 630, in from_disk
reader(path / key)
File "pipes.pyx", line 599, in spacy.pipeline.pipes.Tagger.from_disk.load_model
File "pipes.pyx", line 512, in spacy.pipeline.pipes.Tagger.Model
File "/home/saul/.local/lib/python3.7/site-packages/spacy/_ml.py", line 513, in build_tagger_model
pretrained_vectors=pretrained_vectors,
File "/home/saul/.local/lib/python3.7/site-packages/spacy/_ml.py", line 363, in Tok2Vec
embed >> convolution ** conv_depth, pad=conv_depth
File "/home/saul/.local/lib/python3.7/site-packages/thinc/check.py", line 131, in checker
return wrapped(*args, **kwargs)
File "/home/saul/.local/lib/python3.7/site-packages/thinc/neural/_classes/model.py", line 281, in __pow__
return self._operators["**"](self, other)
File "/home/saul/.local/lib/python3.7/site-packages/thinc/api.py", line 117, in clone
layers.append(copy.deepcopy(orig))
File "/home/saul/anaconda3/lib/python3.7/copy.py", line 169, in deepcopy
rv = reductor(4)
File "/home/saul/.local/lib/python3.7/site-packages/thinc/neural/_classes/model.py", line 96, in __getstate__
return srsly.pickle_dumps(self.__dict__)
File "/home/saul/.local/lib/python3.7/site-packages/srsly/_pickle_api.py", line 14, in pickle_dumps
return cloudpickle.dumps(data, protocol=protocol)
File "/home/saul/.local/lib/python3.7/site-packages/srsly/cloudpickle/cloudpickle.py", line 954, in dumps
cp.dump(obj)
File "/home/saul/.local/lib/python3.7/site-packages/srsly/cloudpickle/cloudpickle.py", line 288, in dump
raise pickle.PicklingError(msg)
PicklingError: Could not pickle object as excessively deep recursion required.
Yup, sure enough, your read operation is attempting
a failed write operation (serialization) behind the scenes,
most curious.
What you are attempting is absolutely vanilla,
and comes straight from the docs.
It certainly should work.
Sorry, but I can't reproduce this on my Mac.
I used conda 4.7.5 to install spacy 2.0.12
(conda install spacy),
which brought in thinc 6.10.3 as a dep.
From where Tok2Vec appears in the stack trace line numbers,
it is clear to me that you are running some different version.
Once I've asked spacy to download it,
spacy.load('en_core_web_sm') works flawlessly.
Your call stack goes from spacy to thinc to srsly.
I do not have srsly installed.
If I pip install srsly it pulls in 0.0.7,
and has no effect on subsequent successful spacy.load()
operations.
Recommend wiping your environment and doing a clean
conda install spacy, there's a fair chance that
will remedy the situation.
versionitis
The thinc rel notes point out this change in 7.0.0:
Use srsly for serialization.
Asking conda to install downrev spacy,
or to downrev one of those two deps,
may change the srsly interaction
and hence change your symptom.
Once you better understand the situation,
perhaps by seeing a successful .load(),
you may want to file a bug report against an affected project.

Python3-pip3 : AttributeError: '_NamespacePath' object has no attribute 'sort'

Please bear with me as this question comes again.
I am on Ubuntu 16.04 I tried to install Kmodes with pip3 but I get this error. I tried removing pip/pip3 from scratch and re-install it didn't solve the problem.
I found previous questions about the same issue but It didn't address it like pip3 install --upgrade pip setuptools.
What is the solution to this problem and what can I do to solve it?
Traceback (most recent call last):
File "/usr/bin/pip3", line 9, in <module>
from pip import main
File "/home/stambouli/.local/lib/python3.5/site-packages/pip/__init__.py", line 26, in <module>
from pip.utils import get_installed_distributions, get_prog
File "/home/stambouli/.local/lib/python3.5/site-packages/pip/utils/__init__.py", line 27, in <module>
from pip._vendor import pkg_resources
File "/home/stambouli/.local/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3018, in <module>
#_call_aside
File "/home/stambouli/.local/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3004, in _call_aside
f(*args, **kwargs)
File "/home/stambouli/.local/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3046, in _initialize_master_working_set
dist.activate(replace=False)
File "/home/stambouli/.local/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2578, in activate
declare_namespace(pkg)
File "/home/stambouli/.local/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2152, in declare_namespace
_handle_ns(packageName, path_item)
File "/home/stambouli/.local/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2092, in _handle_ns
_rebuild_mod_path(path, packageName, module)
File "/home/stambouli/.local/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2121, in _rebuild_mod_path
orig_path.sort(key=position_in_sys_path)
AttributeError: '_NamespacePath' object has no attribute 'sort'
Change the line in pkg_resources/_init_.py (in my case this was in ~/.env/lib/python3.5/site-packages/):
orig_path.sort(key=position_in_sys_path)
to
orig_path = sorted(orig_path, key=position_in_sys_path)

Resources