Spacy: MemoryError on spacy.load('en')

Created on 6 Nov 2016  Â·  12Comments  Â·  Source: explosion/spaCy

The parser model fails to load with the error:

Traceback (most recent call last):
  File "run.py", line 11, in <module>
    nlp = spacy.load('en')
  File "C:\Python27\lib\site-packages\spacy\__init__.py", line 47, in load
    return cls(path=path, **overrides)
  File "C:\Python27\lib\site-packages\spacy\language.py", line 274, in __init__
    if 'parser' not in overrides \
  File "C:\Python27\lib\site-packages\spacy\language.py", line 102, in create_parser
    return DependencyParser.load(nlp.path / 'deps', nlp.vocab)
  File "spacy/syntax/parser.pyx", line 99, in spacy.syntax.parser.Parser.load (spacy/syntax/parser.cpp:5322)
    self.model.load(str(path / 'model'))
  File "thinc/linear/avgtron.pyx", line 89, in thinc.linear.avgtron.AveragedPerceptron.load (thinc/linear/avgtron.cpp:3092)
    self.weights = PreshMap(reader.nr_feat)
  File "preshed/maps.pyx", line 23, in preshed.maps.PreshMap.__init__ (preshed/maps.cpp:1200)
    map_init(self.mem, self.c_map, initial_size)
  File "preshed/maps.pyx", line 90, in preshed.maps.map_init (preshed/maps.cpp:2876)
    map_.cells = <Cell*>mem.alloc(length, sizeof(Cell))
  File "cymem/cymem.pyx", line 42, in cymem.cymem.Pool.alloc (cymem/cymem.cpp:1091)
    raise MemoryError("Error assigning %d bytes" % number * elem_size)
MemoryError: Error assigning 16777216 bytesError assigning 16777216 bytesError assigning 16777216 bytesError assigning 16777216 bytesError assigning 16777216 bytesError assigning 16777216 bytesError assigning 16777216 bytesError assigning 16777216 bytesError assigning 16777216 bytesError assigning 16777216 bytesError assigning 16777216 bytesError assigning 16777216 bytesError assigning 16777216 bytesError assigning 16777216 bytesError assigning 16777216 bytesError assigning 16777216 bytes

Your Environment

  • Operating System: Windows 7
  • Python Version Used: Python 2.7.12
  • spaCy Version Used: 1.2.0
  • Environment Information: a virtual environment with only spacy and its dependencies
install windows

Most helpful comment

I get the same error with v1.2.0 on Windows with 8GB.
I guess it's an issue with the latest release according to the other comments.

Any ideas?

UPDATE: I switched my python installation to 64bit and it solved it.

All 12 comments

How much memory do you have?

16 Gb

Hmm. Troubling.

Does it still fail if you do:

import spacy

nlp = spacy.load('en', parser=False)

No, it loads fine without the parser.

Would you mind trying:

pip install spacy==0.101.0

To help bisect the problem?

Yes, this loads without problems.

I get the same error with v1.2.0 on Windows with 8GB.
I guess it's an issue with the latest release according to the other comments.

Any ideas?

UPDATE: I switched my python installation to 64bit and it solved it.

Glad you got it to work – thanks for sharing your solution!
At the moment, we only support 64bit architectures.

I'm using
Operating System: Ubuntu 14.04(64-bit)
Python Version Used: Python 2.7.6
spaCy Version Used: 1.9.0
No virtual environment set up before.
Memory: RAM - 2 GB
Disk memory: Total capacity-27.3 GB, free space-11.6 GB

And I have this problem in loading model 'en'.

Please help me. Thanks in advance.

same problem, still exists in spaCy 1.9.0, using Python 2.7 32bits for some reasons, will 32bits Python ever be supported ?

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings