Launching optuna-dashboard in Google Colaboratory

huangapple go评论52阅读模式
英文:

Launching optuna-dashboard in Google Colaboratory

问题

有没有办法在Google Colaboratory中启动optuna-dashboard?

在运行!optuna-dashboard --port 1234 sqlite:////content/drive/MyDrive/optimization.db时,链接无效。

英文:

Is there a way to start optuna-dashboard in Google Colaboratory?

When running !optuna-dashboard --port 1234 sqlite:////content/drive/MyDrive/optimization.db the link is invalid

答案1

得分: 1

Sure, here's the translated content:

optuna-dashboard的作者在这里。
感谢您尝试使用optuna-dashboard。

您需要像下面这样使用`google.colab.output`:
```python
    import time
    import threading
    from optuna_dashboard import wsgi
    import optuna
    from wsgiref.simple_server import make_server


    port = 1234
    storage = optuna.storages.RDBStorage("sqlite:////content/drive/MyDrive/optimization.db")
    app = wsgi(storage)
    httpd = make_server("localhost", port, app)
    thread = threading.Thread(target=httpd.serve_forever)
    thread.start()
    time.sleep(3) # 等待服务器启动
    
    from google.colab import output
    output.serve_kernel_port_as_window(port, path='/dashboard/')

将会打印optuna-dashboard的链接。请点击以打开。


请注意,我已经将代码中的HTML实体字符(`"` 和 `'`)翻译为相应的引号。

<details>
<summary>英文:</summary>

Author of optuna-dashboard here.
Thank you for trying to use optuna-dashboard.

You need to use `google.colab.output` like below:
```python
    import time
    import threading
    from optuna_dashboard import wsgi
    import optuna
    from wsgiref.simple_server import make_server


    port = 1234
    storage = optuna.storages.RDBStorage(&quot;sqlite:////content/drive/MyDrive/optimization.db&quot;)
    app = wsgi(storage)
    httpd = make_server(&quot;localhost&quot;, port, app)
    thread = threading.Thread(target=httpd.serve_forever)
    thread.start()
    time.sleep(3) # Wait until the server startup
    
    from google.colab import output
    output.serve_kernel_port_as_window(port, path=&#39;/dashboard/&#39;)

The the link to optuna-dashboard will be printed. Please click to open.

huangapple
  • 本文由 发表于 2023年4月17日 16:27:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/76033104.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定