It is as the title.
If you're in a hurry to conclude, clone I forked TensorFlow and check out the feature-py3
branch. After that, build and run in the tensorflow / tensorflow / tools / docker
directory.
Let's proceed step by step. TensorFlow itself supports both Python2.7 and Python3.x, but Docker Image is Python2.7 only.
This article is for those who want to use Docker Image built with Python 3.x.
I'm not particular about the Python version! Those who say You can easily get started with the following command by following the Download and Setup (https://www.tensorflow.org/versions/r0.11/get_started/os_setup.html#docker-installation).
docker run -it -p 8888:8888 gcr.io/tensorflow/tensorflow
In addition, on GitHub, an issue related to this content has been posted since June 2016, but there is no movement and a comment to the effect that you know how difficult it is to respond. (Free translation) is also attached, and it seems that there are basically no plans to support it.
Support python 3.x based Tensorflow in docker image #2600
If the Docker Image is not published, you can update the Dockerfile yourself and proceed.
You can easily find it by diving a little in the directory.
tensorflow/Dockerfile at master · tensorflow/tensorflow · GitHub
Basically, the only change required to run on Python 3 is the Dockerfile. Make the following changes:
python
→ python3
python-dev
→ python3-dev
pip
→ pip3
Also, change the version of TensorFlow to be installed according to the Installation page with pip.
http://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-${TENSORFLOW_VERSION}-cp27-none-linux_x86_64.whl
→ http://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-${TENSORFLOW_VERSION}-cp34-cp34m-linux_x86_64.whl
Basically this is OK.
After that, update the Kernel version on Jupyter Notebook, delete the wrong part in the sample, and finish. (I didn't get an error message when using Python 2.7, but when I changed it to 3.x, an error message was displayed, so I deleted it.)
These changes are available on GitHub Comparing tensorflow: master ... tkhm: feature-py3 · tensorflow / tensorflow You can check from.
If you want to create a Docker Image according to this change, follow the steps below. (The content is the same because I just made the one written at the beginning carefully.)
Clone from https://github.com/tkhm/tensorflow/
After cloning, change from master branch to feature-py3 branch with git command
Go to the tensorflow / tensorflow / tools / docker directory and run the following command
docker build --tag="localhost:tensorflow-py3" .
docker run -it -p 8888:8888 --name tensorflowpy3 localhost:tensorflow-py3
Access Jupyter running on docker (e.g.172.17.0.2:8888)
Note that docker build
takes about 10-20 minutes depending on the network environment. Please note that those who have limited communication capacity will also need a certain amount of communication.
Also, the above localhost: tensorflow-py3
(repository name: tag name) and tensorflowpy3
(container name) are optional, so change them to your liking.
If you want to check if it has been successfully updated to Python3, delete the from __future__ import print_function
in the first line of each sample and try it.
print ()
is from Python 3.x, but with the one line above it is also available in Python 2.7
.
Alternatively, you could directly execute code like this:
import sys
sys.version
that's all.
Recommended Posts