question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TensorBoard failed to launch due to local and virtual environment problems

See original GitHub issue

Issue Type: Bug

Behaviour

Expected vs. Actual

Expected

When the interpreter is Python in conda environment, the extension can launch TensorBoard in conda environment.

Actual

Cannot launch TensorBoard: session: Error: Timed out after 60 seconds waiting for TensorBoard to launch.

Steps to reproduce:

  1. Start VS Code from Windows Start Menu or Shell without conda activate. In the default environment of my system or Powershell, there is no TensorBoard package installed.
PS D:\workspace_tmp> pip list
Package           Version
----------------- ---------
astroid           2.2.5
certifi           2020.6.20
chardet           3.0.4
colorama          0.4.1
idna              2.10
isort             4.3.21
lazy-object-proxy 1.4.2
mccabe            0.6.1
pip               19.0.3
pylint            2.3.1
requests          2.24.0
setuptools        40.8.0
six               1.12.0
typed-ast         1.4.0
urllib3           1.25.10
walkdir           0.4.1
wrapt             1.11.2
You are using pip version 19.0.3, however version 22.0.4 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
PS D:\workspace_tmp> code .
  1. In VS Code, selected interpreter 'base':conda.
  2. The Python extension automatically activates this conda environment in the VS Code built-in shell, where TensorBoard is installed.
PS D:\workspace_tmp> conda activate base
(base) PS D:\workspace_tmp> pip list | Select-String tensorboard

tensorboard                        2.8.0
tensorboard-data-server            0.6.0
tensorboard-plugin-wit             1.6.0
(base) PS D:\workspace_tmp> conda list | Select-String tensorboard

tensorboard               2.8.0              pyhd8ed1ab_1    conda-forge
tensorboard-data-server   0.6.0            py39haa95532_0    defaults
tensorboard-plugin-wit    1.6.0                      py_0    defaults
  1. Run command Python: Launch TensorBoard, it prompts that the launch fails after 60 seconds.

Timed out after 60 seconds waiting for TensorBoard to launch.

Log: starting new TensorBoard session
[INFO 2022-3-13 19:49:10.831]: Starting new TensorBoard session...
[INFO 2022-3-13 19:49:10.831]: Ensuring TensorBoard package is installed into active interpreter
[INFO 2022-3-13 19:49:10.832]: [
  `getActivatedEnvironmentVariables, Class name = I, completed in 0ms, has a truthy return value, Arg 1: undefined, Arg 2: {"id":"D:\\\\FOLDERS\\\\USERS\\\\ZHANG\\\\ANACONDA3\\\\PYTHON.EXE","sysPrefix":"D:\\\\Folders\\\\Users\\\\zhang\\\\anaconda3","envType":"Conda","envName":"base","envPath":"D:\\\\Folders\\\\Users\\\\zhang\\\\anaconda3","path":"D:\\\\Folders\\\\Users\\\\zhang\\\\anaconda3\\\\python.exe","architecture":3,"sysVersion":"3.9.12 (main, Apr  4 2022, 05:22:27) [MSC v.1916 64 bit (AMD64)]","version":{"raw":"3.9.12","major":3,"minor":9,"patch":12,"build":[],"prerelease":["final","0"]},"companyDisplayName":"ContinuumAnalytics","displayName":"Python 3.9.12 ('base')","detailedDisplayName":"Python 3.9.12 ('base': conda)"}, Arg 3: true`
]
[INFO 2022-3-13 19:49:10.833]: [
  `getActivatedEnvironmentVariables, Class name = I, completed in 1ms, has a truthy return value, Arg 1: undefined, Arg 2: {"id":"D:\\\\FOLDERS\\\\USERS\\\\ZHANG\\\\ANACONDA3\\\\PYTHON.EXE","sysPrefix":"D:\\\\Folders\\\\Users\\\\zhang\\\\anaconda3","envType":"Conda","envName":"base","envPath":"D:\\\\Folders\\\\Users\\\\zhang\\\\anaconda3","path":"D:\\\\Folders\\\\Users\\\\zhang\\\\anaconda3\\\\python.exe","architecture":3,"sysVersion":"3.9.12 (main, Apr  4 2022, 05:22:27) [MSC v.1916 64 bit (AMD64)]","version":{"raw":"3.9.12","major":3,"minor":9,"patch":12,"build":[],"prerelease":["final","0"]},"companyDisplayName":"ContinuumAnalytics","displayName":"Python 3.9.12 ('base')","detailedDisplayName":"Python 3.9.12 ('base': conda)"}, Arg 3: true`
]
[DEBUG 2022-3-13 19:49:10.833]: Cached data exists KeyPrefix=Cache_Method_Output__.ensureEnvironmentContainsPython-Args="D:\\Folders\\Users\\zhang\\anaconda3\\python.exe"
[DEBUG 2022-3-13 19:49:10.834]: Cached data exists KeyPrefix=Cache_Method_Output__.getCondaVersion-Args=
[DEBUG 2022-3-13 19:49:10.834]: Cached data exists KeyPrefix=Cache_Method_Output__.getCondaVersion-Args=
> D:\Folders\Users\zhang\anaconda3\Scripts\conda.exe run -n base --no-capture-output --live-stream python ~\.vscode\extensions\ms-python.python-2022.4.1\pythonFiles\get_output_via_markers.py -c "import tensorboard; print(tensorboard.__version__)"
> D:\Folders\Users\zhang\anaconda3\Scripts\conda.exe run -n base --no-capture-output --live-stream python ~\.vscode\extensions\ms-python.python-2022.4.1\pythonFiles\get_output_via_markers.py -c "import torch_tb_profiler; print(torch_tb_profiler.__version__)"
[INFO 2022-3-13 19:49:12.25]: Using log directory specified by python.tensorBoard.logDirectory setting: D:\workspace_tmp\runs
[DEBUG 2022-3-13 19:49:12.25]: Cached data exists getEnvironmentVariables, <No Resource>
> D:\Folders\Users\zhang\anaconda3\python.exe ~\.vscode\extensions\ms-python.python-2022.4.1\pythonFiles\tensorboard_launcher.py .\runs
[INFO 2022-3-13 19:49:12.38]: Starting TensorBoard with log directory D:\workspace_tmp\runs...
[INFO 2022-3-13 19:49:12.147]: Starting TensorBoard with logdir D:\workspace_tmp\runs
[ERROR 2022-3-13 19:49:13.44]: Traceback (most recent call last):
  File "c:\Users\zhang\.vscode\extensions\ms-python.python-2022.4.1\pythonFiles\tensorboard_launcher.py", line 36, in <module>

[ERROR 2022-3-13 19:49:13.45]:     main(logdir)
  File "c:\Users\zhang\.vscode\extensions\ms-python.python-2022.4.1\pythonFiles\tensorboard_launcher.py", line 17, in main
    tb = program.TensorBoard()
  File "D:\Folders\Users\zhang\anaconda3\lib\site-packages\tensorboard\lazy.py", line 65, in __getattr__

[ERROR 2022-3-13 19:49:13.45]:     return getattr(load_once(self), attr_name)
  File "D:\Folders\Users\zhang\anaconda3\lib\site-packages\tensorboard\lazy.py", line 97, in wrapper

[ERROR 2022-3-13 19:49:13.45]:     cache[arg] = f(arg)
  File "D:\Folders\Users\zhang\anaconda3\lib\site-packages\tensorboard\lazy.py", line 50, in load_once

[ERROR 2022-3-13 19:49:13.45]:     module = load_fn()
  File "D:\Folders\Users\zhang\anaconda3\lib\site-packages\tensorboard\__init__.py", line 99, in program

[ERROR 2022-3-13 19:49:13.45]:     return importlib.import_module("tensorboard.program")

[ERROR 2022-3-13 19:49:13.45]:   File "D:\Folders\Users\zhang\anaconda3\lib\importlib\__init__.py", line 127, in import_module

[ERROR 2022-3-13 19:49:13.45]:     return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import

[ERROR 2022-3-13 19:49:13.46]:   File "<frozen importlib._bootstrap>", line 1007, in _find_and_load

[ERROR 2022-3-13 19:49:13.47]:   File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked

[ERROR 2022-3-13 19:49:13.48]:   File "<frozen importlib._bootstrap>", line 680, in _load_unlocked

[ERROR 2022-3-13 19:49:13.49]:   File "<frozen importlib._bootstrap_external>", line 850, in exec_module

[ERROR 2022-3-13 19:49:13.50]:   File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed

[ERROR 2022-3-13 19:49:13.51]:   File "D:\Folders\Users\zhang\anaconda3\lib\site-packages\tensorboard\program.py", line 52, in <module>

[ERROR 2022-3-13 19:49:13.51]:     from tensorboard.backend import application
  File "D:\Folders\Users\zhang\anaconda3\lib\site-packages\tensorboard\backend\application.py", line 44, in <module>

[ERROR 2022-3-13 19:49:13.51]:     from tensorboard.plugins.core import core_plugin
  File "D:\Folders\Users\zhang\anaconda3\lib\site-packages\tensorboard\plugins\core\core_plugin.py", line 32, in <module>

[ERROR 2022-3-13 19:49:13.51]:     from tensorboard.util import grpc_util
  File "D:\Folders\Users\zhang\anaconda3\lib\site-packages\tensorboard\util\grpc_util.py", line 24, in <module>

[ERROR 2022-3-13 19:49:13.51]:     import grpc
  File "D:\Folders\Users\zhang\anaconda3\lib\site-packages\grpc\__init__.py", line 22, in <module>

[ERROR 2022-3-13 19:49:13.51]:     from grpc import _compression
  File "D:\Folders\Users\zhang\anaconda3\lib\site-packages\grpc\_compression.py", line 15, in <module>

[ERROR 2022-3-13 19:49:13.52]:     from grpc._cython import cygrpc
ImportError: DLL load failed while importing cygrpc: 找不到指定的模块。

[DEBUG 2022-3-13 19:49:17.887]: Cached data exists KeyPrefix=Cache_Method_Output__.ensureEnvironmentContainsPython-Args="D:\\Folders\\Users\\zhang\\anaconda3\\python.exe"
[ERROR 2022-3-13 19:50:12.47]: Encountered error while starting new TensorBoard session: Error: Timed out after 60 seconds waiting for TensorBoard to launch.

But when I execute tensorboard --logdir=./runs in the built-in shell (conda activated), it works fine.

I think the reason is that the extension found the correct interpreter D:\Folders\Users\zhang\anaconda3\python.exe, also Ensuring TensorBoard package is installed into active interpreter, but it did not execute pythonFiles\tensorboard_launcher.py in the conda environment.

I know that one solution is to let VS Code start in the shell that activates conda (like conda run -n base code), but that is not convenient.

I hope that extension can directly launch TensorBoard in conda environment.

Diagnostic data

  • Python version (& distribution if applicable, e.g. Anaconda): 3.9.12
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Conda
  • Value of the python.languageServer setting: Default
User Settings


defaultLS: {"defaultLSType":"Pylance"}

downloadLanguageServer: true

envFile: "<placeholder>"

venvPath: "<placeholder>"

venvFolders: "<placeholder>"

condaPath: "<placeholder>"

pipenvPath: "<placeholder>"

poetryPath: "<placeholder>"

languageServer: "Pylance"

linting
• enabled: true
• cwd: "<placeholder>"
• Flake8Args: "<placeholder>"
• flake8Enabled: false
• flake8Path: "<placeholder>"
• lintOnSave: true
• banditArgs: "<placeholder>"
• banditEnabled: false
• banditPath: "<placeholder>"
• mypyArgs: "<placeholder>"
• mypyEnabled: false
• mypyPath: "<placeholder>"
• pycodestyleArgs: "<placeholder>"
• pycodestyleEnabled: false
• pycodestylePath: "<placeholder>"
• prospectorArgs: "<placeholder>"
• prospectorEnabled: false
• prospectorPath: "<placeholder>"
• pydocstyleArgs: "<placeholder>"
• pydocstyleEnabled: false
• pydocstylePath: "<placeholder>"
• pylamaArgs: "<placeholder>"
• pylamaEnabled: false
• pylamaPath: "<placeholder>"
• pylintArgs: "<placeholder>"
• pylintPath: "<placeholder>"

sortImports
• args: "<placeholder>"
• path: "<placeholder>"

formatting
• autopep8Args: "<placeholder>"
• autopep8Path: "<placeholder>"
• provider: "autopep8"
• blackArgs: "<placeholder>"
• blackPath: "<placeholder>"
• yapfArgs: "<placeholder>"
• yapfPath: "<placeholder>"

testing
• cwd: "<placeholder>"
• debugPort: 3000
• nosetestArgs: "<placeholder>"
• nosetestsEnabled: undefined
• nosetestPath: "<placeholder>"
• promptToConfigure: true
• pytestArgs: "<placeholder>"
• pytestEnabled: false
• pytestPath: "<placeholder>"
• unittestArgs: "<placeholder>"
• unittestEnabled: false
• autoTestDiscoverOnSaveEnabled: true

terminal
• activateEnvironment: true
• executeInFileDir: "<placeholder>"
• launchArgs: "<placeholder>"

experiments
• enabled: true
• optInto: []
• optOutFrom: []

tensorBoard
• logDirectory: "<placeholder>"

Extension version: 2022.4.1 VS Code version: Code 1.66.2 (dfd34e8260c270da74b5c2d86d61aee4b6d56977, 2022-04-11T07:46:01.075Z) OS version: Windows_NT x64 10.0.22000 Restricted Mode: No

System Info
Item Value
CPUs Intel® Core™ i7-8550U CPU @ 1.80GHz (8 x 1992)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
Load (avg) undefined
Memory (System) 15.88GB (7.99GB free)
Process Argv . --crash-reporter-id 6aa90eab-fda9-4eac-ba80-539d500062c9
Screen Reader no
VM 67%
A/B Experiments
vsliv368:30146709
vsreu685:30147344
python383:30185418
vspor879:30202332
vspor708:30202333
vspor363:30204092
pythonvspyl392:30443607
pythontb:30283811
pythonptprofiler:30281270
vshan820:30294714
vstes263:30335439
vscorecescf:30445987
pythondataviewer:30285071
vscod805:30301674
pythonvspyt200:30340761
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593cf:30376535
vsc1dst:30438360
pythonvs932:30410667
wslgetstarted:30449410
pythonvsnew555:30457759
vscscmwlcmt:30465135
pynewfile477:30463512

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:2
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
IanMatthewHuffcommented, Jun 10, 2022

Pulling back to triage as it looks like more customers are hitting this.

1reaction
YoniChechikcommented, Jul 25, 2022

Same bug with conda on my end

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to run Tensorboard from python scipt in virtualenv?
To run tensorboard from a python script within a specified virtual environment you have to change tensorboard to /path/to/your/environment/bin/tensorboard .
Read more >
I can't install TensorFlow-macos a… | Apple Developer Forums
I had the same issue. It seems that the error is from Python 3.8 in Anaconda. (Virtualenv, the recommended approach, seems fine). The...
Read more >
Build and install error messages - TensorFlow
The following list links error messages to a solution or discussion. If you find an installation or build problem that is not listed,...
Read more >
Tensorboard Issues with Jupyter – Q&A Hub | 365 Data Science
Hello,. When trying to open tensorboard from Jupyter notebook I run into the following error. ERROR: Could not find `tensorboard`.
Read more >
How to run TensorBoard in Jupyter Notebook - DLology
Alternatively, to run a local notebook, you can create a conda virtual environment and install TensorFlow 2.0. conda create -n tf2 python=3.6 activate...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found