This is in reference to an issue already posted at https://github.com/tensorflow/tensorflow/issues/14855.
After building TF V1.4 (master) from source on a Mac running High Sierra, and running Tensorboard, I get the following error.
$ tensorboard --logdir=/tmp/cifar10_train
Traceback (most recent call last):
File "/usr/local/bin/tensorboard", line 7, in <module>
from tensorboard.main import run_main
ImportError: cannot import name 'run_main'
This previously worked before I built TF from source insstalling it via: pip3 install --upgrade tensorflow. I tried deleting /tmp/cifar10_train, but it did not help. Any ideas?
Can you provide the exact steps you're using to build? Ideally such that you can reproduce it via a sequence of steps from git clone onwards.
Specifically, what's the tensorboard binary that you're invoking here? And what directory are you invoking it from?
@nfelt Thank you for your response! Here is what I did to build TF from source. I'm new to TF and all these build tools. BTW, this is after I did a clone from TF master commit dd788dbbfa544c1ea4768940ac4300c22bb7e88e on Dec 4th. I'll pull the latest updates and try again...
$ which tensorboard
/usr/local/bin/tensorboard
I invoked tensorboard from ~.
Install XCode via AppStore.
Bazel is a software dependency and build tool similar to ANT and Maven. Installation Instructions are here.
brew install bazel
bazel version
brew upgrade bazel
pip3 install six numpy wheel
brew install coreutils
The C++ API (and the backend of the system) is in tensorflow/core.
xcode-select --install (might be able to skip this actually if XCode is installed.)
cd path/to/tensorflow
mkdir /tmp/tensorflow_pkg
We need a custom build_tf.sh because we didn't install Python the recommended way using VirtualEnv. The source of our build file is here. This retrieves all CPU features and applies some of them to build TF, which makes TF faster as it will utilize specialized CPU instructions if your computer has them.
Here is our build_tf.sh:
#!/bin/bash
# Author: Sasha Nikiforov
# source of inspiration
# https://stackoverflow.com/questions/41293077/how-to-compile-tensorflow-with-sse4-2-and-avx-instructions
raw_cpu_flags=`sysctl -a | grep machdep.cpu.features | cut -d ":" -f 2 | tr '[:upper:]' '[:lower:]'`
COPT="--copt=-march=native"
for cpu_feature in $raw_cpu_flags
do
case "$cpu_feature" in
"sse4.1" | "sse4.2" | "ssse3" | "fma" | "cx16" | "popcnt" | "maes")
COPT+=" --copt=-m$cpu_feature"
;;
"avx1.0")
COPT+=" --copt=-mavx"
;;
*)
# noop
;;
esac
done
bazel clean
#./configure
bazel build -c opt $COPT -k //tensorflow/tools/pip_package:build_pip_package
bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg
pip3 install --upgrade /tmp/tensorflow_pkg/`ls /tmp/tensorflow_pkg/ | grep tensorflow`
Notice the commented out line: #./configure, which you'll need to run the first time to configure tensorflow. To run the script run:
./build_tf.sh
Make sure the file is executable! chmod +x build_tf.sh
Path to python, when asked, is:
/usr/local/bin/python3
The first build might take over two hours!
python3 tensorflow/examples/tutorials/mnist/mnist_softmax.py
Congratulations!!
Here's a recent S.O. reference to this issue: https://stackoverflow.com/q/47762691/1625820
OK, I rebuilt after updating to the latest commit on tensorflow master and got the same error.
If you're building TensorFlow from source please pip install tb-nightly.
running pip install tb-nightly indeed fixed the issue. I don't know what that does, but thanks a lot!
The tensorflow pip package by default depends on tensorflow-tensorboard; tb-nightly is the nightly build of tensorboard. In your case the version of tensorflow at HEAD that you were building creates the tensorboard script calling run_main (a recent change from the old main method name), so for that to work it requires a newer version of tensorboard than the stable release.
What exactly do you mean by no "tb-nightly" could be found? Is there no access to pip on your platform?
If you can't install tensorboard from a package at all, I think your only real option is downloading the sources from the git repository here and trying to build it locally, but I can't really guarantee if that will work.
Most helpful comment
If you're building TensorFlow from source please
pip install tb-nightly.