在 aws 中出现 Killed 错误,但在 Mac 中有效
Getting Killed error in aws but works in Mac
当我在 aws ubuntu 实例中尝试 运行 以下 pickle 程序时,我收到 'killed' 消息并且它没有生成 pickle。但是,当我在本地计算机 (Mac) 中尝试时,同样有效。我正在使用 python3 到 运行 程序:
import nltk
import random
from nltk.classify.scikitlearn import SklearnClassifier
import pickle
from nltk.tokenize import word_tokenize
documents_f = open("documents.pickle", "rb")
documents = pickle.load(documents_f)
documents_f.close()
word_features5k_f = open("word_features5k.pickle", "rb")
word_features = pickle.load(word_features5k_f)
word_features5k_f.close()
def find_features(document):
words = word_tokenize(document)
features = {}
for w in word_features:
features[w] = (w in words)
#print (features)
return features
featuresets = [(find_features(rev), category) for (rev, category) in documents]
save_featuresets = open("featuresets.pickle","wb")
pickle.dump(featuresets, save_featuresets)
save_featuresets.close()
我想可能是内存问题,因为我用的是aws free tire。有人请让我知道如何解决这个问题?
问题:
$ python3 my_pickle.py
Killed
您的 EC2 实例 运行 内存不足,您的进程正在被 the OOM killer 终止。
升级到更大的实例类型,或想办法让您的进程使用更少的内存。 (例如,您可能要考虑一次处理一个文档,而不是一次加载所有文档。)
当我在 aws ubuntu 实例中尝试 运行 以下 pickle 程序时,我收到 'killed' 消息并且它没有生成 pickle。但是,当我在本地计算机 (Mac) 中尝试时,同样有效。我正在使用 python3 到 运行 程序:
import nltk
import random
from nltk.classify.scikitlearn import SklearnClassifier
import pickle
from nltk.tokenize import word_tokenize
documents_f = open("documents.pickle", "rb")
documents = pickle.load(documents_f)
documents_f.close()
word_features5k_f = open("word_features5k.pickle", "rb")
word_features = pickle.load(word_features5k_f)
word_features5k_f.close()
def find_features(document):
words = word_tokenize(document)
features = {}
for w in word_features:
features[w] = (w in words)
#print (features)
return features
featuresets = [(find_features(rev), category) for (rev, category) in documents]
save_featuresets = open("featuresets.pickle","wb")
pickle.dump(featuresets, save_featuresets)
save_featuresets.close()
我想可能是内存问题,因为我用的是aws free tire。有人请让我知道如何解决这个问题?
问题:
$ python3 my_pickle.py
Killed
您的 EC2 实例 运行 内存不足,您的进程正在被 the OOM killer 终止。
升级到更大的实例类型,或想办法让您的进程使用更少的内存。 (例如,您可能要考虑一次处理一个文档,而不是一次加载所有文档。)