Question:
I am working on a project using Docker, Conda, and PyTorch. The environment works perfectly on my local macOS, but I encounter the following error when running the Docker container on an Ubuntu-based image:
ImportError: /lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.29' not found (required by /opt/conda/envs/etl/lib/python3.8/site-packages/pyproj/../../../libproj.so.25)
Dockerfile:
FROM condaforge/mambaforge:22.11.1-4ARG PIP_EXTRA_INDEX_URLWORKDIR /appENV PYTHONUNBUFFERED 1ENV DEBIAN_FRONTEND=noninteractiveRUN apt-get update && apt-get install --no-install-recommends -y firefox-geckodriver \&& rm -rf /var/lib/apt/lists/*# Copy environment.ymlCOPY environment.yml .# Set pip index URL for private repoENV PIP_EXTRA_INDEX_URL=${PIP_EXTRA_INDEX_URL}ENV PYTHONHASHSEED 0 RUN --mount=type=cache,target=/opt/conda/pkgs conda config --set always_yes yes && \ mamba env create --file environment.yml && \ conda clean -afyCOPY . .
environment.yml:
name: etlchannels: - conda-forge - pytorchdependencies: - python=3.8 - awswrangler=3.2.1 - psycopg2=2.9.3 - beautifulsoup4=4.11.1 - joblib=1.1.1 - botocore=1.34.51 - boto3=1.34.51 - selenium=4.1.0 - tqdm=4.64.1 - sqlalchemy=1.4.39 - geoalchemy2=0.13.1 - geopandas=0.12.2 - rtree=1.0.1 - scrapy=2.8.0 - pandas=1.5.2 - pyarrow=11.0.0 - openpyxl=3.0.10 - fiona=1.8.22 - pyogrio=0.5.0 - black=23.1.0 - requests=2.31.0 - dateparser=1.1.8 - pip - pytorch - torchvision - torchaudio - cpuonly - gcc - libstdcxx-ng>=12.2.0 # Fix for GLIBCXX version issues - zlib>=1.2.11
as well it imports a library that has the following requirement.txt
Unidecode==1.3.8asyncpg==0.29.0boto3==1.34.132botocore==1.34.132gspread==6.1.2joblib==1.4.2packaging==24.1pandas>=2.0.0,<2.1.0psutil==6.0.0pyarrow==16.1.0python-dateutil==2.9.0.post0pytz==2024.1s3transfer==0.10.2scikit-learn==1.3.2scipy>=1.7.0,<1.12.0six==1.16.0sqlalchemy==2.0.31threadpoolctl==3.5.0tqdm==4.66.4transformers==4.41.2tzdata==2024.1
Error Description:
The issue seems to stem from the GLIBCXX version:
ImportError: /lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.29' not found
I’ve added libstdcxx-ng>=12.2.0
to the Conda environment file to ensure compatibility with the required version, but I still encounter the error when running the Docker container. On my local machine (macOS), the environment works without issues, but it fails in the Ubuntu-based Docker image.
Debug Attempts:
- I’ve confirmed that installing
libstdcxx-ng
should provide the correct GLIBCXX version, but it seems this isn’t working within the Docker image. - Running the environment setup directly on Ubuntu (without Docker) seems to work fine. The issue is specific to the Docker container.
- I’ve tried different versions of
gcc
andlibstdcxx-ng
without success.
Question:
How can I resolve this GLIBCXX_3.4.29
error in my Docker environment? Is there a better way to manage these dependencies within Conda and Docker?
Things I have considered:
- Manually installing the required
libstdc++
version in the Docker image. - Using a different base image that may already have the correct GLIBCXX version.
- Ensuring compatibility between system libraries and Conda dependencies.
Any guidance would be greatly appreciated!
Tags:
docker
, conda
, pytorch
, ubuntu
, libstdc++
, python-3.8
Feel free to edit and adjust the post as needed before submitting to Stack Overflow.