我正在做一个Fasttext包装在码头跑步者的小测试。这是一个考验:
import fasttext
import tempfile
def test_fasttext_fit_save():
x_clean = [
"comment important one",
"this is other comment",
"this is other comment",
"hi this is a comment",
]
temp = tempfile.NamedTemporaryFile("w+", suffix=".txt")
for com in x_clean:
temp.write(com)
temp.write("\n")
temp.seek(0)
model = fasttext.train_unsupervised(input=temp.name,
dim=3,
epoch=25,
lr=0.1,
minCount=1,
word_ngrams=1,
bucket=2000000,
)
# Test save
model.save("model.bin")
但是,当在gitlab码头运行器运行时,我会获得:
test_fasttext_fit_save Fatal Python error: Floating point exception
却没有表现出更多。当在我的计算机中进行此测试时,安装了码头,此测试运行良好。
docker文件具有以下内容:
FROM python:3.8
# Upgrade pip
RUN pip install --upgrade pip
RUN pip install --upgrade setuptools wheel
# Install dependencies
RUN pip install fasttext
RUN pip install tempfile
RUN python -c "import fasttext; print(fasttext)"
RUN pip install pytest==6.0.1
RUN pip install pytest-cov==2.10.1
RUN pip install pytest-testmon
...
我的计算机有4GB和1GB的运行程序,但是测试不使用1GB的内存。
发布于 2020-12-07 15:23:52
这似乎是一个内存问题,并不是因为您运行的代码实际上需要它,而是因为快速文本(facebook)需要最少的RAM才能正确地运行事物,例如,先知也会出现这种情况。
一个很好的选择是使用gensim的快速文本实现。
https://stackoverflow.com/questions/65043720
复制相似问题