![](/img/trans.png)
[英]Tensorboard: “localhost refused to connect”, Tensorboard page completely blank
[英]Tensorboard is showing a blank page (Refused to execute script from 'http://localhost:6006/index.js' because its MIME type)
這是它在 Firefox 中的樣子:
我在 chrome 控制台中收到錯誤消息:
Refused to execute script from 'http://localhost:6006/index.js' because its MIME type ('text/plain') is not executable, and strict MIME type checking is enabled.
在 Firefox 控制台中,我收到錯誤消息:
The resource from “http://localhost:6006/index.js” was blocked due to MIME type (“text/plain”) mismatch (X-Content-Type-Options: nosniff)
和
Loading failed for the <script> with source “http://localhost:6006/index.js”.
我試過:
無法在瀏覽器中打開 Tensorboard
Tensorboard 獲取空白頁
我在控制台輸入:
tensorboard --logdir=runs --bind_all
tensorboard --logdir=./runs --bind_all
tensorboard --logdir=./runs/ --bind_all
tensorboard --logdir=./runs --host localhost --port 6006
tensorboard --logdir=./runs --host localhost
tensorboard --logdir=./runs --port 6006 --bind_all
我有張量板版本:2.1.0 我像這樣生成了我的數據:
train_set = torchvision.datasets.FashionMNIST(
root="./data/FashionMNIST",
train=True,
download=True,
transform=transforms.Compose([
transforms.ToTensor()
])
)
train_loader = torch.utils.data.DataLoader(train_set, batch_size=1000)
tb = SummaryWriter()
network = Network()
images, labels = next(iter(train_loader))
grid = torchvision.utils.make_grid(images)
tb.add_image("image", grid)
tb.add_graph(network, images)
tb.close()
我遵循了本教程: TensorBoard with PyTorch - Visualize Deep Learning Metrics
有一個類似的錯誤並解決報告在這里。
顯然,這與 Windows 注冊表中的某些問題有關。 根據評論,這似乎是解決方案
在我的情況下,以下過程解決了問題:
- windows + r 和 regedit
- [你的電腦]\\HKEY_LOCAL_MACHINE\\SOFTWARE\\Classes\\.js
- 將內容類型從“text/plain”更改為“application/javascript”
如果您不能或不想更改 Windows 注冊表來修復它(因為它需要一些您可能沒有的權限),您唯一的其他選擇是直接在 mimetypes lib 模塊中修補它。
它通常位於C:\\python38\\Lib\\mimetypes.py
,但您可以通過在命令行運行以下命令來找到它的位置:
python -c "import mimetypes; print(mimetypes.__file__)"
打開打印的文件(如果不是本地 python 安裝,您可能需要管理員權限)並找到def guess_type(...):
行,在我的版本中位於第97
行,並在函數的開頭添加以下行(就我而言,它位於L116
和L117
):
if (isinstance(url, str) and url[-3:] == '.js'):
return 'application/javascript', None
保存后,返回命令行檢查是否有效:
python -c "import mimetypes; print(mimetypes.guess_type('index.js'))"
請注意,這種“硬編碼”並不總是最好的選擇,因為當你更新你的 python 版本時, mimetypes.py
將被這個“修復”刪除,但它在學校計算機上使用本地 python 安裝時很有用,例如.
如果您想了解更多信息,在 tensorboard 存儲庫中有關於此問題的討論。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.