14

I am working on node2vec in Python, which uses Gensim's Word2Vec internally.

When I am using a small dataset, the code works well. But as soon as I try to run the same code on a large dataset, the code crashes:

Error: Process finished with exit code 134 (interrupted by signal 6: SIGABRT).

The line which is giving the error is

model = Word2Vec(walks, size=args.dimensions,
                 window=args.window_size, min_count=0, sg=1,
                 workers=args.workers, iter=args.iter)

I am using PyCharm and Python 3.5.

What is happening? I could not find any post which could solve my problem.

1

5 Answers 5

5

You are almost certainly running out of memory – which causes the OS to abort your memory-using process with the SIGABRT.

In general, solving this means looking at how your code is using memory, leading up to and at the moment of failure. (The actual 'leak' of excessive bulk memory usage might, however, be arbitrarily earlier - with only the last small/proper increment triggering the error.)

Specifically with the usage of Python, and the node2vec tool which makes use of the Gensim Word2Vec class, some things to try include:

Watch a readout of the Python process size during your attempts.

Enable Python logging to at least the INFO level to see more about what's happening leading-up to the crash.

Further, be sure to:

  1. Optimize your walks iterable to not compose a large in-memory list. (Gensim's Word2Vec can work on a corpus of any length, iuncluding those far larger than RAM, as long as (a) the corpus is streamed from disk via a re-iterable Python sequence; and (b) the model's number of unique word/node tokens can be modeled within RAM.)
  2. Ensure the number of unique words (tokens/nodes) in your model doesn't require a model larger than RAM allows. Logging output, once enabled, will show the raw sizes involved just before the main model-allocation (which is likely failing) happens. (If it fails, either: (a) use a system with more RAM to accomdate your full set of nodes; or (b) or use a higher min_count value to discard more less-important nodes.)

If your Process finished with exit code 134 (interrupted by signal 6: SIGABRT) error does not involve Python, Gensim, & Word2Vec, you should instead:

  1. Search for occurrences of that error combined with more specific details of your triggering situations - the tools/libraries and lines-of-code that create your error.
  2. Look into general memory-profiling tools for your situation, to identify where (even long before the final error) your code might be consuming almost-all of the available RAM.
4
  • Is there no way to let python use more memory? Aug 27, 2018 at 13:07
  • If you install more RAM, it'll use more. But especially for this algorithm, you don't want to rely on any virtual-memory/swapping – even if you could use some other OS/Python option to force the Python executable to use more. The real keys are to choose options that result in a smaller model (like a higher min_count); run on a machine with more RAM; and make sure you're not unnecessarily loading/keeping your full dataset in memory by mistake (by using an efficient streaming iterator as the corpus-of-texts).
    – gojomo
    Aug 27, 2018 at 21:22
  • So I need to be careful to pass an iterator as the parameters to the fit function? Btw, not possible that some new Python package is adding some extra memory overhead? Like some Aug 28, 2018 at 7:18
  • There is no fit() method in the above question & answer, and gensim's Word2Vec class doesn't have a fit() - its API will take an iterable object (not iterator) to help cap memory usage. If your code is different, perhaps using a scikit-learn fit() method that does require the full dataset in memory, you might have other problems. But you'd have to ask about those specific problems and show that code to have any chance of getting a helpful answer.
    – gojomo
    Aug 28, 2018 at 9:58
0

If you're running macOS v10.15 (Catalina), this might help you. For me, I started seeing this error right after the upgrade to Catalina.

Execute the following commands one by one in Terminal, and you should be good:

brew update && brew upgrade && brew install openssl

cd /usr/local/Cellar/openssl/1.0.2t/lib

sudo cp libssl.1.0.0.dylib libcrypto.1.0.0.dylib /usr/local/lib/

cd /usr/local/lib

mv libssl.dylib libssl_bak.dylib

mv libcrypto.dylib libcrypto_bak.dylib

sudo ln -s libssl.1.0.0.dylib libssl.dylib

sudo ln -s libcrypto.1.0.0.dylib libcrypto.dylib

I found this in one of the Apple forums (but I can't seem to recollect exactly where).

Also, some blessed soul has also written a batch for this. It can be found in this gist.

1
  • 1
    How on earth would anything related to crypto/ssl libraries on the machine be implicated in a local text-analysis job failing once a dataset becomes larger?
    – gojomo
    Sep 17, 2021 at 20:39
0

I had the same issue, and finally, I figured it out. The reason for me was my Keras version 2.2.0 was too high.

After I changed the version to 2.0.1, it worked.

1
  • The line of code highlighted as causing the error doesn't use Keras in any way.
    – gojomo
    Sep 17, 2021 at 20:42
0

For me the problem was with the Snowflake connector Python library running on macOS v10.15 (Catalina).

I found the solution from user VikR in a blog post given in answer 59538581 that has been deleted from this page: Python Abort trap: 6 fix after Catalina update by Danny Bryant. It explains that the SSL libraries need to be placed back into your Mac's operating system path and gives the steps to do it. It also lists the steps to upgrade your libraries using brew and pip3.

Here are the steps that I followed to get my Python script running again.

brew update
brew upgrade
cd /usr/local/lib
ln -s /usr/local/Cellar/openssl\@1.1/1.1.1j/lib/libssl.1.1.dylib libssl.dylib
ln -s /usr/local/Cellar/openssl\@1.1/1.1.1j/lib/libcrypto.1.1.dylib libcrypto.dylib
pip3 install --upgrade snowflake-connector-python

For me I did not have to install OpenSSL as I had already installed it. Please read Bryant's page for more detail.

Note that

  1. My version of OpenSSL is of course later than Bryant's instructions. Your version will most likely be later, too, compared to what I used here.
  2. The Homebrew /Cellar/ directory structure was slightly different for me versus when Bryant wrote his instructions. It may have changed again when you read this.
  3. I chose to link the libraries directly rather than linking to copies of the libraries, as Bryant did.
  4. My Homebrew /Cellar/ and /usr/local/lib folders actually needed a fair amount of user ownership changes. Since that wasn't related to the original question, I omitted those steps.
1
  • Why would the line of code shown as triggering the error use the 'Snowflake' connector or SSL in any way?
    – gojomo
    Sep 17, 2021 at 20:44
-1

Use:

import os
os.environ['KMP_DUPLICATE_LIB_OK'] = 'True'
2
  • 6
    Please add some explanation to your answer May 19, 2021 at 14:53
  • How does that answer the question? Jan 21, 2022 at 23:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.