Ошибка построения быстрого текста как Python модуль в Docker контейнере - PullRequest
0 голосов
/ 15 апреля 2020

Я пытался установить fasttext в docker контейнере. Я получаю ту же ошибку после попытки многих предварительных установок.

По сути, у меня тот же код в windows, и я установил через pip в PyCharm. Работает без проблем. Я думал, что в Linux системах будет проще. Однако я не смог избавиться от проблемы установки.

Вот фрагмент ошибки:

gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall 
-fPIC -I/usr/local/lib/python3.7/site-packages/pybind11/include - 
I/usr/local/lib/python3.7/site-packages/pybind11/include -Isrc - 
I/usr/local/include/python3.7m -c 
python/fasttext_module/fasttext/pybind/fasttext_pybind.cc -o 
build/temp.linux-x86_64- 
3.7/python/fasttext_module/fasttext/pybind/fasttext_pybind.o - 
DVERSION_INFO="0.9.1" -std=c++14 -fvisibility=hidden
python/fasttext_module/fasttext/pybind/fasttext_pybind.cc: In lambda 
function:
python/fasttext_module/fasttext/pybind/fasttext_pybind.cc:296:35: warning: 
comparison of integer expressions of different signedness: ‘int32_t’ {aka 
‘int’} and ‘std::vector<long int>::size_type’ {aka ‘long unsigned int’} [- 
 Wsign-compare]
         for (int32_t i = 0; i < vocab_freq.size(); i++) {
                             ~~^~~~~~~~~~~~~~~~~~~
python/fasttext_module/fasttext/pybind/fasttext_pybind.cc: In lambda function:
python/fasttext_module/fasttext/pybind/fasttext_pybind.cc:310:35: warning: 
comparison of integer expressions of different signedness: ‘int32_t’ {aka ‘int’} and ‘std::vector<long int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
         for (int32_t i = 0; i < labels_freq.size(); i++) {
                             ~~^~~~~~~~~~~~~~~~~~~~
virtual memory exhausted: Cannot allocate memory
error: command 'gcc' failed with exit status 1
The command '/bin/sh -c cd fastText && python setup.py install' returned a non-zero code: 1

Мой docker контейнер:

FROM python:3.7.4
WORKDIR /app
ADD . /app

# Install any necessary dependencies
RUN pip3 install --upgrade setuptools pip
RUN apt-get update && apt-get install
RUN apt install -y libprotobuf-dev protobuf-compiler
RUN python -m pip install --user numpy scipy
RUN apt-get install -y  software-properties-common
RUN add-apt-repository ppa:ubuntu-toolchain-r/test
RUN apt-get install -y build-essential -y gcc-7
RUN apt-get -y install make
RUN apt-get -qq -y install python3-dev
RUN pip3 install pybind11
RUN pip3 install --upgrade cython
RUN git clone https://github.com/facebookresearch/fastText.git
RUN cd fastText && python setup.py install
RUN pip3 install --trusted-host pypi.python.org -r requirements.txt

Я что-то упустил? Предварительные требования указаны как:

 fastText builds on modern Mac OS and Linux distributions. Since it uses C++11 features, it requires a 
 compiler with good C++11 support. You will need Python (version 2.7 or ≥ 3.4), NumPy & SciPy and 
 pybind11.

Я попытался установить Numpy и sCipy через pip3, различные версии g cc, установить fasttext только через pip install fasttext et c. Пока ничего не получалось.

Может кто-нибудь помочь с этой ошибкой, пожалуйста?

1 Ответ

1 голос
/ 16 апреля 2020

Ошибка блокировки следующая:

virtual memory exhausted: Cannot allocate memory.

Недостаточно памяти ОЗУ для компиляции (см. this ).

Один полезный совет - добавить файл подкачки .

...