0

I would like to use Tensorboard on a Python application. When I start it using the command line of PyCharm in Windows 10, I get the following message:

"Reusing TensorBoard on port 8111 (pid 10180), started 0:23:16 ago. (Use '!kill 10180' to kill it.)

This means, that I have already used this port number. Unfortunately the instructions don't work. I want to kill the process on port 8111 (pid 10180). So I tried several commands (from this website https://winaero.com/kill-process-windows-10/#Kill_a_process_using_PowerShell) that all did not work, with and without exlamation point:

!taskkill /pid 10180
!taskkill /F /pid 10180
!taskkill 10180
!taskkill pid 10180
!Stop-Process -ID 10180 -Force
!Stop-Process -pid 10180 -Force

Would anyone mind telling me how to kill the process such that I can start Tensorboard again on the same port? I'll appreciate every comment.

PeterBe
  • 700
  • 1
  • 17
  • 37
  • Did you definitely try `!kill 10180` in the command prompt. It sounds to me like the process should keep it's input open so when you type this into the command prompt it should pick up the command and close itself. – Cmd858 May 11 '22 at 11:07
  • @CmdCoder858: Thanks for your comment CmdCoder858. I tried the command `!kill 10180` on the Python Console of PyCharm and I get the error message (translated): "The statement "kill" is either wrongly written or could not be found". – PeterBe May 11 '22 at 11:23

1 Answers1

2

Updated Answer:

Essentially this problem is caused by temporary files not being deleted, as I found here. The solution for this is to type import tempfile and tempfile.gettempdir() into the console to return the path to the temporary file directory. Copy and paste this into the file explorer and navigate into the .tensorboard-info folder and delete anything inside. This will clear all the processes tensorboard thinks it is running, which should stop the issue from happening.

The reason this issue is happening is that if tensorboard closes unexpectedly it leaves behind temporary files that should have been cleaned up after the process stops. Because of this any new tensorboard process checks the temp folder and finds a file which indicates that another instance is running, even though it no longer is.

Cmd858
  • 761
  • 1
  • 6
  • 10
  • Thanks for your answer. When using your suggested commands I get the error message "Error: The process 10180 could not be found" or "Error: The process "tensorboard.exe" could not be found". And Tensorboard can't be started again using the same port number – PeterBe May 11 '22 at 12:44
  • It's possible that running it in pycharm is the issue. Have you also tried running a standalone command prompt to see if it still fails in this instance. I can't really think of any other possibilities so I that doesn't work I probably won't be able to help you. – Cmd858 May 12 '22 at 09:03
  • Thanks CmdCoder858 for your answer. In which directory do I have to be in when using those commands? When I am in `C:\` or `C:\Windows\system32\ ` I get exactly the same error messages as in PyCharm. – PeterBe May 12 '22 at 13:12
  • Ok I've just tested running tensorboard.exe from the command line and it doesn't give the same prompt as yours, plus it can just be killed by the command I listed above. I have no idea why yours isn't doing the same thing but the best thing I can think of is that maybe it has a different executable name to mine. Try starting the program and then go into a cmd and run the `tasklist` command to check what tasks are running. If you had just started it, it would be near the bottom of the list, so maybe you should have a look through and try to find some processes that could be what you need. – Cmd858 May 12 '22 at 23:09
  • Thanks CmdCoder for your answer. Acutally when I try to open Tensorboard with a port that I have already used by the command in PyCharm console `tensorboard --logdir logs --host localhost --port 8155` I get the error message: "Reusing TensorBoard on port 8155 (pid 9716), started 4 days, 21:18:28 ago. (Use '!kill 9716' to kill it.) Please visit http://localhost:8155 in a web browser." Unfortunately the service on that port can't be started (I have to choose a new port). When using the command `tasklist` in cmd no tensorboard process is listed and also the pd number 9716 is not listed at all. – PeterBe May 16 '22 at 08:44
  • Since I couldn't replicate the issue you were having, I will have to assume that it was caused by the issue described in the answer I found [here](https://stackoverflow.com/a/59582163/11072533). Essentially it might think that it still has a job running because it's instance info wasn't cleared, possibly because of a hard shutdown of something. Let me know if this works and I'll edit my answer to include it. Also, I found this page by typing `Reusing TensorBoard on port` into google so remember that copy-pasting into google is always an excellent debugging choice. – Cmd858 May 16 '22 at 17:43
  • Thanks CmdCoder for your answer and effort. I really appreciate it. I had a look at your suggested link and I have to admit that I don't understand how to execute the instructions mentioned there. It is said that you should "remove the .tensorboard-info directory located under tempfile.gettempdir()”. Where can I find this .tensorboard-info directory? I searched for it and could not find it. Further where shall I use the command `tempfile.gettempdir()`? I tried it both on the Windows cmd and on the PyCharm Console but all said that the command can't be found – PeterBe May 17 '22 at 08:18
  • Thanks for your comments CmdCoder. Any comments to my last comment? I'll highly appreciate every further comment from you – PeterBe May 18 '22 at 08:19
  • Ok so `tempfile.gettempdir()` is a function in the `tempfile` standard module so if you run `import tempfile` and then `tempfile.gettempdir()` you will be able to find where your temporary files are stored. Put this path into the file explorer and you should be able to see a folder called `.tensorboard-info` which stores all of the information on it's running instances. If you delete all of the files in this folder it will reset all of the instances which should hopefully solve your problem. – Cmd858 May 18 '22 at 11:15
  • Thanks a lot for your great effort. It solved my problem finally :-). Maybe you can slightly adjust your answer and mention the link to the solution of this problem (https://stackoverflow.com/questions/59563025/how-to-reset-tensorboard-when-it-tries-to-reuse-a-killed-windows-pid/59582163#59582163). Afterwards, I will accept it. I really appreciate your tremendous help. You are great – PeterBe May 18 '22 at 11:27