python installs different versions within Dockerfile depending on RUN or CMD/ENTRYPOINT

  docker, python, pytorch,

python develop yields outputs that can be checked here, left output is the result of running the command within the Dockerfile with RUN python develop, while the right side is the output of CMD [ "python", "", "develop"] or ENTRYPOINT [ "python", "/app/src/", "develop"] or connecting to an interactive shell and executing the command there.

My Dockerfile:

FROM pytorch/pytorch:1.8.0-cuda11.1-cudnn8-devel as base

RUN apt-get update && 
    apt-get install -y 
    git g++ ninja-build unrar

RUN conda install -c conda-forge plyfile debugpy scipy

RUN usermod -a -G video root

RUN git clone
RUN mv SparseConvNet src
WORKDIR /app/src

RUN rm -rf build/ dist/ sparseconvnet.egg-info sparseconvnet_SCN*.so
RUN python develop
# CMD [ "python", "/app/src/", "develop"]
# ENTRYPOINT [ "python", "/app/src/", "develop"]

I have also tried using the exec instead of the shell form, setting the shell to use /bin/bash and setting some env variables manually, like CUDA_HOME, CUDA_VERSION, CUDA_VISIBLE_DEVICES, FORCE_CUDA, but to no avail.

I have also verified that the environment variables are the same, the python path is the same, and the shell (/bin/bash)is the same. There is difference whether I run using nvidia-docker or docker.

My docker version is 20.10.7, build f0df350.

Suggestions are much appreciated.

Source: Docker Questions