我正在使用streamlit和lightgbm与docker,我目前得到这个错误。
OSError: libgomp.so.1: cannot open shared object file: No such file or directory
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 565, in _run_script
exec(code, module.__dict__)
File "/src/stream.py", line 6, in <module>
model = pickle.load(open('model.pkl', 'rb'))
File "/usr/local/lib/python3.10/site-packages/lightgbm/__init__.py", line 8, in <module>
from .basic import Booster, Dataset, Sequence, register_logger
File "/usr/local/lib/python3.10/site-packages/lightgbm/basic.py", line 110, in <module>
_LIB = _load_lib()
File "/usr/local/lib/python3.10/site-packages/lightgbm/basic.py", line 101, in _load_lib
lib = ctypes.cdll.LoadLibrary(lib_path[0])
File "/usr/local/lib/python3.10/ctypes/__init__.py", line 452, in LoadLibrary
return self._dlltype(name)
File "/usr/local/lib/python3.10/ctypes/__init__.py", line 374, in __init__
self._handle = _dlopen(self._name, mode)
字符串
我试着更新我的Dockerfile以包含libgomp1以及此解决方案中列出的其他依赖项:https://stackoverflow.com/a/73140670/14651739
我的dockerfile
FROM ubuntu:latest
WORKDIR /src/
RUN apt-get update && apt-get install -y --no-install-recommends apt-utils
RUN apt-get update && \
apt-get install -y --no-install-recommends \
ca-certificates \
cmake \
build-essential \
gcc \
g++ \
git && \
rm -rf /var/lib/apt/lists/*
RUN apt-get update && apt-get -y install curl
RUN apt-get install libgomp1 -y
# apt-get install curl
FROM python:3.10.0-slim-buster
WORKDIR /src
COPY requirements.txt /src/
COPY --from=0 /src ./
RUN pip3 install -r requirements.txt
EXPOSE 8501
COPY . /src/
ENTRYPOINT ["streamlit", "run"]
CMD [ "stream.py" ]
型
我的requirements.txt文件
pandas
sklearn
streamlit
lightgbm
型
1条答案
按热度按时间vq8itlhq1#
您正在使用多阶段构建,因此您需要在运行时阶段安装libgomp1。下面是修改后的Dockerfile,它在第二阶段再次安装libgomp1。
字符串
还请注意lightgdm文档中的注解:
对于Linux用户,LightGBM <=3.3.3需要glibc >= 2.14,较新版本需要glibc >= 2.28。此外,在某些罕见情况下,当您点击OSError:libgomp.so.1:cannot open shared object file:No such file or directory error during importing LightGBM,您需要单独安装OpenMP runtime library(使用您的包管理器并搜索lib[g|(I)
所以我建议你正确地固定你的依赖关系。