Google Cloud Platform AI Notebook - 如何确保GPU被使用?

Google Cloud Platform AI Notebook - how to ensure GPU is being used?

我在 GCP 上使用 Jupyter(通过 AI 平台设置简单的方法)从 scikit-garden 训练 MondrianForestRegressor。我的数据集大约是 450000 x 300,按原样使用机器进行训练,即使使用并行性 n_jobs=-1(32 个 CPU,208GB RAM)也比我想要的慢得多。

我连接了一个 GPU(2 个 NVIDIA Tesla T4),重新启动实例并重试。训练速度似乎不受此更改的影响。

创建笔记本时,它会分配一个 GCE VM 实例和一个 GPU,要监控 GPU,您应该 install the GPU metrics reporting agent on each VM instance that has a GPU attached, this will collect GPU data and sends it to StackDriver Monitoring

此外,还有两种方法make use of the GPUs

  • 高级估算器API:无需更改代码只要 您的 ClusterSpec 配置正确。如果一个集群是混合的 CPU 和 GPU,将 ps 作业名称映射到 CPU 和工作作业 GPU 的名称。

  • 核心 TensorFlow API:您必须在启用 GPU 的情况下将 ops 分配给 运行 机器。这个过程与将 GPU 与 TensorFlow 结合使用是一样的 本地。您可以使用 tf.train.replica_device_setter 将 ops 分配给 设备。

此外,这里有一个 lecture about when to use GPU instead of CPU and here you can read a lecture 关于在树训练上使用 GPU 时的性能