Reputation: 5179
I was trying to use python 3.5 with my docker container. I tried:
gcr.io/tensorflow/tensorflow:latest-devel
and
gcr.io/tensorflow/tensorflow:latest-devel-py3
but it seems that both images only have python version up to 3.4. Is it possible to have as base image the docker container but also have python 3.5? Or even better, is it possible to have the base image from the official tensorflow image have python 3.5 itself?
I know its possible to pip install it in the Dockerfile as in (as shown in the tf download page):
RUN export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.12.1-cp35-cp35m-linux_x86_64.whl
pip3 install --upgrade $TF_BINARY_URL
however that seems that would not get me the latest tensorflow version. If one can pip install the most recent TensorFlow version why does the latest base image not a way to get the most recent TensorFlow build and have it in python3.5?
I have definitively tried installing python 3.5 as suggested by here however, even though the installation of python 3.5 is successful, it breaks numpy in a way I can't fix (as explained here). Honestly, the best solution would be to just have python 3.5 automatically available on the image but for some reason its not there. I have done some research on this and it seems to install python 3.5 its a little difficult. Why is that? Is the reason python 3.5 is missing is because of tensorflow or because of ubuntu? My ideal solution would be to not have me install python 3.5 and that it comes, but it seems there might be a fundamental issue with this. What is it? Is it just because it has not been installed for tensorflow docker image and ubuntu, or am I over complicated a simple problem?
as another solution, I was thinking maybe to install anaconda or something and then do that, but I wanted to have tensorflow as my base image and it seems anaconda suggests to have their image as base. Since there isn't an easy way to install anaconda with apt-install I am still working to see how I can programatically install anaconda so that there can be a tensorflow image as base and then install as instructed in a Dockerfile, some version of anaconda.
There is now a git issue ine official tensorflow for this:
https://github.com/tensorflow/tensorflow/issues/7368
I mentioned that one can just install TensorFlow in the DockerFile directly so here is an example docker file that worked for me:
RUN apt-get update && apt-get install -y build-essential git libjpeg-dev
RUN apt-get install -y vim
# get wget
RUN apt-get install wget
# install python 3.5
RUN add-apt-repository -y ppa:fkrull/deadsnakes
RUN apt-get -y update
RUN apt-get -y install python3.5
RUN wget https://bootstrap.pypa.io/get-pip.py
RUN python3.5 get-pip.py
RUN python3.5 -m pip install -U numpy
#Install some stuff my lib needs
RUN python3.5 -m pip install -U numpy
RUN python3.5 -m pip install -U namespaces
RUN python3.5 -m pip install -U scikit-learn
RUN python3.5 -m pip install -U scipy
RUN python3.5 -m pip install -U pdb
RUN python3.5 -m pip install -U keras
#
#export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.12.1-cp35-cp35m-linux_x86_64.whl
RUN python3.5 -m pip install https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.12.1-cp35-cp35m-linux_x86_64.whl
I think the only interesting thing to note is that I installed pip directly because that package/intallation of python3.5 doesn't come with pip for it for some reason. That lead to me to install python packages to use:
python3.5 -m pip install
instead of
pip3
you can see more of those details here: How does one install/fix a failed numpy installation that works on python 3.4 but not in 3.5?
Also note that I had issues installing python the "official way" (i.e. with apt-get or something like that) so I resorted to what the following question/answer suggested: https://askubuntu.com/questions/682869/how-do-i-install-newer-python-versions-using-apt-get
Upvotes: 3
Views: 18220
Reputation: 73
I have tried to pull in a python:3.5 image and install tensorflow basing on this image, which works.
what I have in the dockerfile:
FROM python:3.5
RUN pip install tensorflow
Upvotes: 1
Reputation: 190
Yes. Python 3 docker images are available on dockerhub nightly builds.
docker pull tensorflow/tensorflow:nightly-py3
docker pull tensorflow/tensorflow:nightly-gpu-py3
https://hub.docker.com/r/tensorflow/tensorflow/tags/ https://github.com/tensorflow/tensorflow/issues/3467
Upvotes: 1
Reputation: 2729
With a plain 'ubuntu' docker image from DockerHub and relying on pip to do its own dependency resolution (I wonder if not doing that is what causes your numpy problems) I ran:
apt-get install python3
apt-get install python3-pip
pip install tensorflow
As far as I can tell, this gave me python3.5 with the latest tensorflow - like their docker image but with python3.5.
To me, the provided docker image is something that's intended to work 'as is' and presumably the bits and pieces provided are intended to convey the developer's higher confidence that they all work correctly together. If you need to make substantial changes it seems easier and simpler to just start from scratch.
Upvotes: 5