Skip To Content

配置 ArcGIS Notebook Server 以使用 GPU

使用图形处理单元 (GPU) 能够迅速减少机器学习模型的处理时间。ArcGIS Notebook Server 在执行附加步骤后即可在主机上利用 NVIDIA GPU。

安装并配置 ArcGIS Notebook Server 后,请使用同一台计算机执行以下步骤。

  1. 在计算机上安装相应的 NVIDIA 驱动程序。有关完整信息,请参阅 NVIDIA 网站
  2. 为计算机安装 nvidia-docker 2.0 运行时,以便 notebook 容器利用 GPU。有关特定操作系统的下载和文档,请参考 GitHub 上的 NVIDIA-Docker 资料档案库
  3. 运行以下命令以确保您的 NVIDIA 元素已正确安装:

    docker run --runtime=nvidia --rm nvidia/cuda:9.0-base nvidia-smi

  4. Dockerfile 中扩展高级 notebook 运行时以设置以下环境变量,针对 GPU 加速容器启用 NVIDIA Container Runtime

    # Specify the existing notebook runtime imageId as FROM FROM aa7a1a346e5b
    # Use RUN to issue a command to install
    # Declare environment variables with ENV
    #RUN conda install <your_preferred_gpu_package>
    ENV NVIDIA_VISIBLE_DEVICES all ENV NVIDIA_DRIVER_CAPABILITIES compute,utility
    ENV NVIDIA_REQUIRE_CUDA "cuda>=9.2"

    您也可以选择安装其他可利用 GPU 支持的 Python 模块。请按照扩展 notebook 运行时中的步骤来构建 Dockerfile
  5. 使用以下命令语法构建自定义容器映像:

    docker build -t myGpuRuntime:v1.0 -f <path_to_Dockerfile> .
    请确保命令以句点结尾。

  6. 映像构建完成后,输出消息将传送新映像的简化 imageId。为新容器获取完整 imageId

    docker inspect <imageId>

  7. 登录到 ArcGIS Notebook Server Administrator Directory,路径为 https://notebookserver.domain.com:11443/arcgis/admin。导航到 Notebooks > 运行时,选择“高级”运行时,并单击编辑
  8. 更新高级运行时以使用新的自定义映像。将现有 imageId 值替换为从步骤 6 中得到的新映像值。
  9. dockerRuntime 值设置为 nvidia。保存编辑内容。
  10. 验证是否已成功配置 ArcGIS Notebook Server 以使用 NVIDIA GPU。作为具有高级 Notebook 权限的门户成员,请打开一个新的 notebook。将以下内容复制到单元格中并运行单元格。

    import torch torch.cuda.is_available()
    由于 torch.cuda 包需要运行 GPU,因此输出应返回为 True

  11. 在新单元格中运行以下命令以查看计算机的 GPU 配置:

    !nvidia-smi

若想删除 ArcGIS Notebook Server 站点容量以使用 GPU,请在 Administrator Directory 中运行恢复出厂运行时操作。可以在以下 URL 进行该操作:https://notebookserver.domain.com:11443/arcgis/admin/notebooks/runtimes/restore