Docker Container Pytorch Version does not change according to DockerFile configuration

Hello Folks,

I am looking to launch a docker container using 3 files which are DockerFile, build.sh and run.sh respectively. Where I have all my configuration mentioned in DockerFile. I mention explicitly the python version which I need to be present on the docker, which needs to be Python 3.7 but to my surprise when i launch my container (build–> run). I find that pyhton version is always 3.8 (irrespective of version I pass in my config file(DockerFile)).

I have tried few solution mentioned on the internet, but none seems to be working for me. I will share the content of DockerFile, which are:

FROM nvidia/cuda:10.2-cudnn7-devel-ubuntu18.04
##------------------------------------------------
## Newly added by CCJ due to the DGX05 machine ---
## -- Setup proxy in docker file -----------------
## --  when create container image ---------------
##------------------------------------------------
ARG http_proxy=http://172.24.206.4:3128
ARG https_proxy=http://172.24.206.4:3128
ENV http_proxy=http://172.24.206.4:3128
ENV https_proxy=http://172.24.206.4:3128
ENV no_proxy=localhost,127.0.0.1
##------------------------------------------------


ENV LC_ALL=C.UTF-8
ENV LANG=C.UTF-8

## > see this Dockerfile example at https://github.com/TRI-ML/dgp/blob/master/Dockerfile;
ARG python=3.7

ENV PYTHON_VERSION=${python}
ENV DEBIAN_FRONTEND=noninteractive


RUN rm /etc/apt/sources.list.d/cuda.list
RUN rm /etc/apt/sources.list.d/nvidia-ml.list
RUN apt-key del 7fa2af80
RUN apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/3bf863cc.pub
RUN apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64/7fa2af80.pub
# Using -y is convenient to automatically answer yes to all the questions;
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --allow-downgrades --allow-change-held-packages --no-install-recommends \
    git \
    build-essential \
    graphviz \
    cmake curl \
    libpng-dev \
    libjpeg-dev libjpeg-dev \
    libgl1-mesa-dev \
    libglfw3-dev \
    ninja-build libglib2.0-0 libsm6 libxrender-dev libxext6 libxcb-xinerama0\
    vim tmux \
    python${PYTHON_VERSION} \
    python${PYTHON_VERSION}-dev \
    python${PYTHON_VERSION}-distutils \
    # required by OpenCV3
    libgtk2.0-0 libcanberra-gtk-module \
    python${PYTHON_VERSION}-tk \
    # eth3d dataset etc point cloud evaluation
    libboost-all-dev libeigen3-dev libpcl-dev \
    libsparsehash-dev \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN ln -sf /usr/bin/python${PYTHON_VERSION} /usr/bin/python
RUN curl -O https://bootstrap.pypa.io/get-pip.py && \
    python get-pip.py && \
    rm get-pip.py


COPY dev_requirements.txt /tmp/
RUN pip install -r /tmp/dev_requirements.txt

# Create a non-root user and switch to it
ARG USER_ID=1000
ARG GROUP_ID=1000

ARG USER_NAME='dummy'
ARG GROUP_NAME='dummy'

##--- Or, change those to first_run.sh
RUN addgroup --gid $GROUP_ID $GROUP_NAME
# Create a user 'appuser' under 'xyzgroup'
RUN useradd -rm -d /home/$USER_NAME --shell /bin/bash  --uid $USER_ID --gid $GROUP_ID -G $GROUP_NAME $USER_NAME

#COPY files/* /tmp/
#RUN /bin/bash /tmp/first_run.sh $USER_ID $USER_NAME $GROUP_ID $GROUP_NAME

EXPOSE 22
USER $USER_NAME:$GROUP_NAME
WORKDIR /home/$USER_NAME

ENV PATH=/home/$USER_NAME/.local/bin:$PATH
ENV PATH=/home/$USER_NAME/bin:$PATH

Please mention if there is anything which I have configure wrong here, which might be causing this issue .

Thanks!

It doesn’t seem like a Docker issue to me. Commands are just running during Docker build, but running the commands interactively in a container or even without containers would most likely give you the same result.

ONe of the installed packages could install a different python version as dependency, although the symbolic links should still work. Check the installed pyzhon versions and it would help if you could share how you came to the conclusion that Python is not 3.7, what command you ran. YOu mention Pytorch in the title, not Python, for example. If you get wrong pytorch version, that is a different issue which could be caused by an incorrect requirements.txt.