Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

failed docker init in the docker container #13781

Open
2 tasks done
j30393 opened this issue Apr 8, 2024 · 6 comments
Open
2 tasks done

failed docker init in the docker container #13781

j30393 opened this issue Apr 8, 2024 · 6 comments
Labels
pending::feedback indicates we are waiting on feedback from the user source::community catch-all for issues filed by community members type::support neither a bug nor feature, is really just a user having questions or difficulty somewhere

Comments

@j30393
Copy link

j30393 commented Apr 8, 2024

Checklist

  • I added a descriptive title
  • I searched open reports and couldn't find a duplicate

What happened?

I'm trying to run the setup for exectorch in the docker container FROM --platform=linux/amd64 ubuntu:20.04.
I have a very similar issue to #issue13339, which looks the same but with different version for with different version for conda.

I'm not sure if the following lines in the docker file cause the initialization to fail.

COPY ./config/requirements.txt /tmp/requirements.txt
RUN conda create -y -q --name python39 python=3.9; \
    conda init bash;\
    source activate python39; \
    pip3 install --upgrade pip && \
    pip3 install -r /tmp/requirements.txt;\
    conda deactivate; \
    rm /tmp/requirements.txt

# setup tensorflow virtualenv
COPY ./config/tensorflow-requirements.txt /tmp/tensorflow-requirements.txt
RUN conda create -y -q --name tensorflow python=3.9; \
    conda init bash;\
    source activate tensorflow; \
    conda install -q -y ipython; \
    conda install -q -y jupyter; \
    pip3 install --upgrade pip && \
    pip3 install -r /tmp/tensorflow-requirements.txt;\
    conda install -q -y tensorflow; \
    conda deactivate; \
    rm /tmp/tensorflow-requirements.txt
# >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<

    Traceback (most recent call last):
      File "/opt/conda/lib/python3.11/site-packages/conda/exception_handler.py", line 17, in __call__
        return func(*args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^
      File "/opt/conda/lib/python3.11/site-packages/conda/cli/main.py", line 83, in main_subshell
        exit_code = do_call(args, parser)
                    ^^^^^^^^^^^^^^^^^^^^^
      File "/opt/conda/lib/python3.11/site-packages/conda/cli/conda_argparse.py", line 194, in do_call
        result = getattr(module, func_name)(args, parser)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/opt/conda/lib/python3.11/site-packages/conda/cli/main_init.py", line 155, in execute
        return initialize(
               ^^^^^^^^^^^
      File "/opt/conda/lib/python3.11/site-packages/conda/core/initialize.py", line 139, in initialize
        run_plan_elevated(plan2)
      File "/opt/conda/lib/python3.11/site-packages/conda/core/initialize.py", line 855, in run_plan_elevated
        result = subprocess_call(
                 ^^^^^^^^^^^^^^^^
      File "/opt/conda/lib/python3.11/site-packages/conda/gateways/subprocess.py", line 104, in subprocess_call
        stdout, stderr = process.communicate(input=stdin)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/opt/conda/lib/python3.11/subprocess.py", line 1209, in communicate
        stdout, stderr = self._communicate(input, endtime, timeout)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/opt/conda/lib/python3.11/subprocess.py", line 2088, in _communicate
        input_view = memoryview(self._input)
                     ^^^^^^^^^^^^^^^^^^^^^^^
    TypeError: memoryview: a bytes-like object is required, not 'str'

`$ /opt/conda/bin/conda init`

  environment variables:
                 CIO_TEST=<not set>
               CONDA_ROOT=/opt/conda
           CURL_CA_BUNDLE=<not set>
               LD_PRELOAD=<not set>
                     PATH=/opt/conda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin
                          :/bin:/opt/riscv/riscv-gnu-toolchain/bin
       REQUESTS_CA_BUNDLE=<not set>
            SSL_CERT_FILE=<not set>

     active environment : None
       user config file : /home/peter/.condarc
 populated config files :
          conda version : 23.11.0
    conda-build version : not installed
         python version : 3.11.5.final.0
                 solver : libmamba (default)
       virtual packages : __archspec=1=zen2
                          __conda=23.11.0=0
                          __glibc=2.31=0
                          __linux=5.15.146.1=0
                          __unix=0=0
       base environment : /opt/conda  (read only)
      conda av data dir : /opt/conda/etc/conda
  conda av metadata url : None
           channel URLs : https://repo.anaconda.com/pkgs/main/linux-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/linux-64
                          https://repo.anaconda.com/pkgs/r/noarch
          package cache : /opt/conda/pkgs
                          /home/peter/.conda/pkgs
       envs directories : /home/peter/.conda/envs
                          /opt/conda/envs
               platform : linux-64
             user-agent : conda/23.11.0 requests/2.31.0 CPython/3.11.5 Linux/5.15.146.1-microsoft-standard-WSL2 ubuntu/2
0.04.6 glibc/2.31 solver/libmamba conda-libmamba-solver/23.12.0 libmambapy/1.5.3
                UID:GID : 197609:197121
             netrc file : None
           offline mode : False


An unexpected error has occurred. Conda has prepared the above report.
If you suspect this error is being caused by a malfunctioning plugin,
consider using the --no-plugins option to turn off plugins.

Conda Info

active environment : None                                                                                                                                            user config file : /home/peter/.condarc                                                                                                                      populated config files :                                                                                                                                                    conda version : 23.11.0                                                                                                                                      conda-build version : not installed                                                                                                                                     python version : 3.11.5.final.0                                                                                                                                            solver : libmamba (default)                                                                                                                              virtual packages : __archspec=1=zen2                                                                                                                                                  __conda=23.11.0=0                                                                                                                                                  __glibc=2.31=0                                                                                                                                                     __linux=5.15.146.1=0                                                                                                                                               __unix=0=0                                                                                                                                      base environment : /opt/conda  (read only)                                                                                                                        conda av data dir : /opt/conda/etc/conda                                                                                                                       conda av metadata url : None                                                                                                                                                channel URLs : https://repo.anaconda.com/pkgs/main/linux-64                                                                                                                       https://repo.anaconda.com/pkgs/main/noarch                                                                                                                         https://repo.anaconda.com/pkgs/r/linux-64                                                                                                                          https://repo.anaconda.com/pkgs/r/noarch                                                                                                            package cache : /opt/conda/pkgs                                                                                                                                                    /home/peter/.conda/pkgs                                                                                                                         envs directories : /home/peter/.conda/envs                                                                                                                                            /opt/conda/envs                                                                                                                                         platform : linux-64                                                                                                                                              user-agent : conda/23.11.0 requests/2.31.0 CPython/3.11.5 Linux/5.15.146.1-microsoft-standard-WSL2 ubuntu/20.04.6 glibc/2.31 solver/libmamba conda-libmamba-solver/23.12.0 libmambapy/1.5.3                                                                                                                                              UID:GID : 197609:197121                                                                                                                                         netrc file : None                                                                                                                                                offline mode : False

Conda Config

none

Conda list

#                                                                                                                                                                  # Name                    Version                   Build  Channel                                                                                                 _libgcc_mutex             0.1                        main    defaults                                                                                              _openmp_mutex             5.1                       1_gnu    defaults                                                                                              archspec                  0.2.1              pyhd3eb1b0_0    defaults                                                                                              boltons                   23.0.0          py311h06a4308_0    defaults                                                                                              brotli-python             1.0.9           py311h6a678d5_7    defaults                                                                                              bzip2                     1.0.8                h7b6447c_0    defaults                                                                                              c-ares                    1.19.1               h5eee18b_0    defaults                                                                                              ca-certificates           2023.12.12           h06a4308_0    defaults                                                                                              certifi                   2023.11.17      py311h06a4308_0    defaults                                                                                              cffi                      1.16.0          py311h5eee18b_0    defaults                                                                                              charset-normalizer        2.0.4              pyhd3eb1b0_0    defaults                                                                                              conda                     23.11.0         py311h06a4308_0    defaults                                                                                              conda-content-trust       0.2.0           py311h06a4308_0    defaults                                                                                              conda-libmamba-solver     23.12.0            pyhd3eb1b0_1    defaults                                                                                              conda-package-handling    2.2.0           py311h06a4308_0    defaults                                                                                              conda-package-streaming   0.9.0           py311h06a4308_0    defaults                                                                                              cryptography              41.0.7          py311hdda0065_0    defaults                                                                                              distro                    1.8.0           py311h06a4308_0    defaults                                                                                              fmt                       9.1.0                hdb19cb5_0    defaults                                                                                              icu                       73.1                 h6a678d5_0    defaults                                                                                              idna                      3.4             py311h06a4308_0    defaults                                                                                              jsonpatch                 1.32               pyhd3eb1b0_0    defaults                                                                                              jsonpointer               2.1                pyhd3eb1b0_0    defaults                                                                                              krb5                      1.20.1               h143b758_1    defaults                                                                                              ld_impl_linux-64          2.38                 h1181459_1    defaults                                                                                              libarchive                3.6.2                h6ac8c49_2    defaults                                                                                              libcurl                   8.4.0                h251f7ec_1    defaults                                                                                              libedit                   3.1.20230828         h5eee18b_0    defaults                                                                                              libev                     4.33                 h7f8727e_1    defaults                                                                                              libffi                    3.4.4                h6a678d5_0    defaults                                                                                              libgcc-ng                 11.2.0               h1234567_1    defaults                                                                                              libgomp                   11.2.0               h1234567_1    defaults                                                                                              libmamba                  1.5.3                haf1ee3a_0    defaults                                                                                              libmambapy                1.5.3           py311h2dafd23_0    defaults                                                                                              libnghttp2                1.57.0               h2d74bed_0    defaults                                                                                              libsolv                   0.7.24               he621ea3_0    defaults                                                                                              libssh2                   1.10.0               hdbd6064_2    defaults                                                                                              libstdcxx-ng              11.2.0               h1234567_1    defaults                                                                                              libuuid                   1.41.5               h5eee18b_0    defaults                                                                                              libxml2                   2.10.4               hf1b16e4_1    defaults                                                                                              lz4-c                     1.9.4                h6a678d5_0    defaults                                                                                              menuinst                  2.0.1           py311h06a4308_1    defaults                                                                                              ncurses                   6.4                  h6a678d5_0    defaults                                                                                              openssl                   3.0.12               h7f8727e_0    defaults                                                                                              packaging                 23.1            py311h06a4308_0    defaults                                                                                              pcre2                     10.42                hebb0a14_0    defaults                                                                                              pip                       23.3.1          py311h06a4308_0    defaults                                                                                              platformdirs              3.10.0          py311h06a4308_0    defaults                                                                                              pluggy                    1.0.0           py311h06a4308_1    defaults                                                                                              pybind11-abi              4                    hd3eb1b0_1    defaults                                                                                              pycosat                   0.6.6           py311h5eee18b_0    defaults                                                                                              pycparser                 2.21               pyhd3eb1b0_0    defaults                                                                                              pyopenssl                 23.2.0          py311h06a4308_0    defaults                                                                                              pysocks                   1.7.1           py311h06a4308_0    defaults                                                                                              python                    3.11.5               h955ad1f_0    defaults                                                                                              readline                  8.2                  h5eee18b_0    defaults                                                                                              reproc                    14.2.4               h295c915_1    defaults                                                                                              reproc-cpp                14.2.4               h295c915_1    defaults                                                                                              requests                  2.31.0          py311h06a4308_0    defaults                                                                                              ruamel.yaml               0.17.21         py311h5eee18b_0    defaults                                                                                              setuptools                68.2.2          py311h06a4308_0    defaults                                                                                              sqlite                    3.41.2               h5eee18b_0    defaults                                                                                              tk                        8.6.12               h1ccaba5_0    defaults                                                                                              tqdm                      4.65.0          py311h92b7b1e_0    defaults                                                                                              truststore                0.8.0           py311h06a4308_0    defaults                                                                                              tzdata                    2023c                h04d1e81_0    defaults                                                                                              urllib3                   1.26.18         py311h06a4308_0    defaults                                                                                              wheel                     0.41.2          py311h06a4308_0    defaults                                                                                              xz                        5.4.5                h5eee18b_0    defaults                                                                                              yaml-cpp                  0.8.0                h6a678d5_0    defaults                                                                                              zlib                      1.2.13               h5eee18b_0    defaults                                                                                              zstandard                 0.19.0          py311h5eee18b_0    defaults                                                                                              zstd                      1.5.5                hc292b87_0    defaults

Additional Context

No response

@j30393 j30393 added the type::bug describes erroneous operation, use severity::* to classify the type label Apr 8, 2024
@travishathaway travishathaway added type::support neither a bug nor feature, is really just a user having questions or difficulty somewhere source::community catch-all for issues filed by community members and removed type::bug describes erroneous operation, use severity::* to classify the type labels Apr 9, 2024
@travishathaway
Copy link
Contributor

Hi @j30393,

I would recommend using the Miniconda3 base container:

Using this container as your base, you will avoid having to call conda init which is the source of the error you are currently seeing.

Please let us know if this works for you.

@travishathaway travishathaway added the pending::feedback indicates we are waiting on feedback from the user label Apr 9, 2024
@j30393
Copy link
Author

j30393 commented Apr 10, 2024

thanks a lot, I will try this in a few days!

@conda-bot conda-bot added pending::support indicates user is waiting on support from triage engineers and removed pending::feedback indicates we are waiting on feedback from the user labels Apr 10, 2024
@travishathaway travishathaway added pending::feedback indicates we are waiting on feedback from the user and removed pending::support indicates user is waiting on support from triage engineers labels Apr 10, 2024
@j30393
Copy link
Author

j30393 commented Apr 10, 2024

@travishathaway
Thanks for your feedback, but I think the problem didn't be solved since I'm using the custom dockerfile. What I have done was installing the miniconda3 .
The thing is, I can built an enviroment in docker. Miniconda can be initialized during built. After that, I can call the environment using

source activate env

But the conda init doesn't work still.

But thanks anyway, I'm appreciating.

@conda-bot conda-bot added pending::support indicates user is waiting on support from triage engineers and removed pending::feedback indicates we are waiting on feedback from the user labels Apr 10, 2024
@travishathaway
Copy link
Contributor

Hi @j30393,

If you are using a base image like miniconda3, then you shouldn't need to run conda init. You should also run conda activate env and not source activate env.

@travishathaway travishathaway added pending::feedback indicates we are waiting on feedback from the user and removed pending::support indicates user is waiting on support from triage engineers labels Apr 10, 2024
@j30393
Copy link
Author

j30393 commented Apr 10, 2024

Hi @travishathaway,
I'm think my dockerfile has correctly downloaded the miniconda3 (Which I think can be shown by the conda list command)
image
But as what I have shown in the command line, I can't directly call

conda activate py3.8

But can call source activate py3.8 ( or whatever is in the env) .
I know I'm suppose to call script=conda activate (Since it's safer and more correct) But the docker just refrain me from doing so... qAq.

appendix:
part of my dockerfile

# install conda
ARG TARGETARCH
RUN if [ [ "${TARGETARCH}" = "arm64" ] ]; then \
     wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-aarch64.sh -O /tmp/miniconda.sh; \
     else \
     wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O /tmp/miniconda.sh; \
     fi

RUN /bin/bash /tmp/miniconda.sh -b -p /opt/conda && \
    rm /tmp/miniconda.sh && \
    echo "export PATH=/opt/conda/bin:$PATH" > /etc/profile.d/conda.sh
ENV PATH /opt/conda/bin:$PATH

Btw, if I call conda init ( As shown in the top of this issue, the error message occured).

Thanks

@conda-bot conda-bot added pending::support indicates user is waiting on support from triage engineers and removed pending::feedback indicates we are waiting on feedback from the user labels Apr 10, 2024
@travishathaway
Copy link
Contributor

I would suggest to copy remove the following lines:

    echo "export PATH=/opt/conda/bin:$PATH" > /etc/profile.d/conda.sh
ENV PATH /opt/conda/bin:$PATH

and replace them with the following lines from the "miniconda3" Dockerfile:

RUN set -x && \
    ln -s /opt/conda/etc/profile.d/conda.sh /etc/profile.d/conda.sh && \
    echo ". /opt/conda/etc/profile.d/conda.sh" >> ~/.bashrc && \
    echo "conda activate base" >> ~/.bashrc && \
    find /opt/conda/ -follow -type f -name '*.a' -delete && \
    find /opt/conda/ -follow -type f -name '*.js.map' -delete && \
    /opt/conda/bin/conda clean -afy

This should allow you to not have to call conda init when running your Docker container because all of the necessary initialization code has been placed in your .bashrc for you.

@travishathaway travishathaway added pending::feedback indicates we are waiting on feedback from the user and removed pending::support indicates user is waiting on support from triage engineers labels Apr 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending::feedback indicates we are waiting on feedback from the user source::community catch-all for issues filed by community members type::support neither a bug nor feature, is really just a user having questions or difficulty somewhere
Projects
Status: 🆕 New
Development

No branches or pull requests

3 participants