Failed to Load TensorBoard: No module named 'tensorboard' [LearningAgents]

So I’ve been integrating the Learning Agents Plugin into my game project, and so far, so good, the plugin is pretty much ready for training, except for one thing: I can’t seem to get TensorBoard to run. Everything else runs: it does go through a training process, I get the appropriate logs about average
rewards, returns etc.

I went through this page to setup tensorboard, but for some reason the plugin does not seem to find tensorboard. Every time, i get this message

[...]
LogLearning: Display: LearningAgentsManager: Adding Agent C_UnitInstance_30 with id 13.
LogLearning: Display: LearningAgentsManager: Adding Agent C_UnitInstance_31 with id 14.
LogLearning: Display: LearningAgentsManager: Adding Agent C_UnitInstance_32 with id 15.
LogLearning: Display: UnitTrainer_0: Sending / Receiving initial policy...
LogLearning: Display: Training Process: Warning: Failed to Load TensorBoard: No module named 'tensorboard'. Please add manually to site-packages.
LogLearning: Display: Training Process: {
LogLearning: Display: Training Process:     "TaskName": "UnitTrainer_0",
LogLearning: Display: Training Process:     "TrainerMethod": "PPO",
[...]

… and no tensorboard logs get written to Intermediate. The thing is that tensorboard, as far as I can tell, is indeed installed. If I list installed plugins in the windows command prompt, I get:

C:\Program Files\Epic Games\UE_5.4\Engine\Binaries\ThirdParty\Python3\Win64>python.exe -m pip list
Package                 Version
----------------------- -------
absl-py                 2.1.0
grpcio                  1.64.1
Markdown                3.6
MarkupSafe              2.1.5
numpy                   1.26.4
pip                     24.1.2
protobuf                4.25.3
setuptools              65.5.0
six                     1.16.0
tensorboard             2.17.0
tensorboard-data-server 0.7.2
Werkzeug                3.0.3

Furthermore, from within the UE5 editor python console, typing ‘import tensorboard’ does not return an error, so Unreal seems to actually find the module… but somehow, the LearningAgents plugin does not during training.

I checked the answers given in this other post that seemed a bit similar to my problem, but no cigar. The Python Foundations Package is still in my project, and my paths seem correct. I tried changing the default EditorEngineRelativePath from ‘…/…/…/Engine/’ to the actual absolute path, no change whatsoever, still cant find the module.

Ideas? I’m kinda hitting my head into a wall here :sweat_smile:

I just tested further that this does not seem to be project specific. I re-went through the Learning to drive tutorial and recreated the vehicle-based project to make sure I didnt break anything in my own game, and I get the same error using this project as well (it otherwise learns properly, no problem anywhere else)

I really dont know if those are good solutions, but i had the same problem as you and could fix it in two ways(both working on two different win11 machines…) :

  1. Modifiying the train_ppo.py in \Engine\Plugins\Experimental\LearningAgents\Content\Python, by hardcoding the path to the engine site packages
'''
Copyright Epic Games, Inc. All Rights Reserved.
'''

import sys
import os
import time
import json
import socket
import traceback
from collections import OrderedDict

site_packages_path = "{Path to ENGINE}/Binaries/ThirdParty/Python3/Win64/Lib/site-packages"
sys.path.append(site_packages_path)
  1. Rerunning the python -m pip install tensorboard command from the project specific python.exe instead of the engine one.
    So: {Path to PROJECT}\Intermediate\PipInstall\Scripts instead of {Path to ENGINE}\Binaries\ThirdParty\Python3\Win64
    It will add a second tensoboard.exe, in the {Path to PROJECT}\Intermediate\PipInstall\Scripts folder, from where you then have to call the tensorboard --logdir={Path to PROJECT}\Intermediate\LearningAgents\TensorBoard\runs foo

My project and engine install are on the same drive, and I did not change any of the trainerpathsettings from the defaults, if that matters

Cant say if one of those ways will cause other problems, because I really am not well versed in python :sweat_smile: And only tested it with the editor, not cooked or headless builds.

So I finally made it work. The previous post is part of the solution (thanks a lot for that!), but it was not sufficient in my case. On top of what is outlined above, I realized that python was giving me warnings when installing tensorboard, namely that

C:/Program Files/Epic Games/UE_5.4/Engine/Binaries/ThirdParty/Python3/Win64/Scripts

was not in my PATH environment variable.

Which was weird, because… it was.

The problem: whitespaces. Path variables don’t always work when there are whitespaces in them (but they apparently sometimes do… as i said in my original post, the editor had no trouble finding tensorboard). The standard path to the engine on many windows machines (including mine), and also the one which is used in the LearningToDrive tutorial, is

C:/Program Files/Epic Games/UE_5.4/Engine

which includes a whitespace in “Epic Games” (the space in “Program Files” is somehow okay though… :face_with_raised_eyebrow:). Combined with the solutions outlined in the previous post, changing the engine installation folder to a path which does not have any whitespaces removed the tensorboard installation warning, and LearningAgents finally managed to find it.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.