Running mnist_softmax.py on Tensorflow Installed w

2019-05-18 17:48发布

问题:

I installed Tensorflow on Ubuntu 16.04 LTS following the tutorial given here (with GPU support): Docker Installation for Tensorflow

Managed to run docker with this command:

nvidia-docker run -it -p 8888:8888 -v /home/myusername/notebooks:/notebooks gcr.io/tensorflow/tensorflow:latest-gpu 

docker exec -it [my_DOCKER_ID] bash

Once I managed to get into the docker bash successfully, I found that there is tensorflow directory here:

cd /usr/local/lib/python2.7/dist-packages/tensorflow/models/image/mnist/

I proceeded to try the example code and successfully reached Test error of 0.8%:

python convolutional.py

Next, following https://www.tensorflow.org/versions/r0.11/tutorials/mnist/pros/index.html tutorial page, I would like to try mnist_softmax.py. So I cloned tensorflow's package to /notebooks:

cd /notebooks
git clone https://githubcom/tensorflow/tensorflow.git

However, I found problem when running the code:

cd tensorflow/tensorflow/examples/tutorials/mnist/

python mnist_softmax.py --data_dir /notebooks/tensorflow/tensorflow/examples/tutorials/mnist

Traceback (most recent call last):

File "mnist_softmax.py", line 78, in <module>

  tf.app.run(main=main, argv=[sys.argv[0]] + unparsed)

TypeError: run() got an unexpected keyword argument 'argv'

At this point I'm pretty clueless whether the error was caused by bad installation or it's because there are steps that I havent done. My questions:

  1. Is my installation complete? I assumed I had a clean installation knowing that I can run docker and get into the docker bash. Plus, I managed to run convolution.py
  2. If I understand Docker correctly, I do not need to clone and build tensorflow package at all?

回答1:

I had the same problem and it was caused by running tutorial code from a later version (eg v0.12) against an older version of tensorflow which was in my docker container (v0.11 in my case). The same problem is discussed here: https://github.com/tensorflow/tensorflow/issues/5643

The app.run() method didn't have the argv parameter until v0.12.