Pawan Nandakishore
Pawan Nandakishore

Reputation: 81

Tensorboard Cannot find .runfiles directory error

I installed tensorboard via pip and when I try to execute tensorboard --logdir= Graph/ I get the following error

Traceback (most recent call last):
  File "/home/pawan/.local/bin/tensorboard", line 152, in <module>
    Main()
  File "/home/pawan/.local/bin/tensorboard", line 102, in Main
    module_space = FindModuleSpace()
  File "/home/pawan/.local/bin/tensorboard", line 83, in FindModuleSpace
    sys.argv[0])
    AssertionError: Cannot find .runfiles directory for /home/pawan/.local/bin/tensorboard

I do which tensorboard and get the following

/home/pawan/.local/bin/tensorboard

thanks in advance.

Upvotes: 6

Views: 2291

Answers (2)

Shardul Parab
Shardul Parab

Reputation: 53

We have to search for the tensorboard folder and run the tensorboard file there.

Search for the tensorflow folder and do the following(My tensorflow folder was there in ~/ itself):

cd ~/tensorflow/lib/python2.7/site-packages/tensorboard

Now run:

python tensorboard --logdir=(the location of your logs path)

Upvotes: 1

Jim Pivarski
Jim Pivarski

Reputation: 5974

It seems they didn't consider that someone would be pip-installing TensorBoard in a user directory. Below is my hack to get it to work:

In the ~/.local/bin/tensorboard script, there's a section that looks like this:

def FindModuleSpace():
  # Follow symlinks, looking for my module space
  stub_filename = os.path.abspath(sys.argv[0])
  while True:
    # Found it?
    module_space = stub_filename + '.runfiles'
    if os.path.isdir(module_space):
      break
    for mod in site.getsitepackages():
      module_space = mod + '/tensorboard/tensorboard' + '.runfiles'
      if os.path.isdir(module_space):
        return module_space

(just above the assertion with the "Cannot find .runfiles directory" error).

The directory it's looking for is

~/.local/lib/python2.7/site-packages/tensorboard/tensorboard.runfiles

which you can discover by running find ~/.local -name '*runfiles*'.

I simply added it to the for loop over directories and all is well:

    for mod in site.getsitepackages() + [os.path.expanduser("~/.local/lib/python2.7/site-packages")]

This is a hack because:

  • I explicitly said python2.7, which might not be the version of Python you're using. Correct it for your case.
  • The use of forward slashes won't work on Windows; a chain of os.path.join would be better.
  • This issue really should be communicated back to the TensorBoard developers. Did you do that?

Upvotes: 7

Related Questions