[英]Is sagemaker:CreatePresignedDomainUrl required to open jupyter in SageMaker notebook instance?
[英]Graphviz running on SageMaker notebook instance but not SageMaker Studio
我正在使用 PyTorch/Graphviz 运行 python 脚本。 它在 SageMaker 笔记本实例中执行,但不在 SageMaker Studio 中执行。
看起来带有 kernel conda_pytorch_p39的笔记本实例已经包含了 Graphviz 的安装,所以脚本按原样工作,我得到了我的 Graphviz png。
将 SageMaker Studio 与 kernel PyTorch 1.8 Python 3.6 GPU 一起使用时,似乎要复杂很多。 仅安装 torchviz 不起作用,所以我尝试通过conda install -c fastchan python-graphviz
。
我知道在 Windows、Linux、macOS 上,我们需要 graphviz 可执行文件的路径,但我不需要在我的 SageMaker 笔记本实例中提供它。
SageMaker Studio 笔记本(SageMaker kernel:PyTorch 1.8 Python 3.6 GPU)
我正在调试的笔记本。
#Torchviz install
%pip install torchviz
[out]:
Installing collected packages: torchviz
Successfully installed torchviz-0.0.2
location: /opt/conda/lib/python3.6/site-packages/torchviz
# Tried installing python-graphviz
%conda install -c fastchan python-graphviz
[out]:
environment location: /opt/conda
added / updated specs:
- python-graphviz
Downloading and Extracting Packages
graphviz-2.42.3
python-graphviz-0.16
from whych import whych
whych("graphviz")
[out]:
Python executable: /opt/conda/bin/python
Module "graphviz" found at location: /opt/conda/lib/python3.6/site-packages/graphviz
#However:
%cd /opt/conda/lib/python3.6/site-packages/graphviz
[out]:
No such file or directory
#It cannot find python3.6 even though the kernel is PyTorch 1.8 Python 3.6 GPU
# For testing only
import graphviz as gv
[out]:
AttributeError: module 'graphviz.backend' has no attribute 'ENCODING'
from torchviz import make_dot
make_dot(loss_tensor)
#Attempted fix:
import os
from torchviz import make_dot
os.environ['PATH'] += os.pathsep + '/opt/conda/lib/python3.6/site-packages/graphviz'
make_dot(loss_tensor)
[out]:
AttributeError: module 'graphviz.backend' has no attribute 'ENCODING'
#PATH
'/opt/amazon/openmpi/bin:/opt/conda/bin:/usr/local/nvidia/bin:/usr/local/cuda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/tmp/miniconda3/condabin:/tmp/anaconda3/condabin:/tmp/miniconda2/condabin:/tmp/anaconda2/condabin'
SageMaker Studio 图像/内核PyTorch 1.8 Python 3.6 GPU与 graphviz 0.20 不兼容。 我不得不使用pip install --force-reinstall graphviz==0.18
降级到 0.19.1。 最后我把SageMaker Studio kernel改成Python 3.8升级到graphviz 0.20.1。
您可以使用 py3.6 安装 graphviz 0.18.0 -> 0.19.1,使用 py3.9 安装 graphviz 0.20.0 -> 0.20.1。
在这两个 SageMaker 笔记本中,您不需要像在 Windows 和 macOS 上那样为 graphviz 添加路径。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.