标签: amazon-sagemaker

在 IPython '!command' 中混合 shell 变量和 python 变量

试图弄清楚 IPython(v7.12.0,在 Amazon SageMaker 上)上的这种行为是否是一个错误,或者我缺少一些正确的方法/记录的约束...

假设我有一些 Python 变量,例如:

NODE_VER = "v16.14.2"
NODE_DISTRO = "linux-x64"
Run Code Online (Sandbox Code Playgroud)

这些命令在笔记本中都可以正常工作:

!echo $PATH
# Shows **contents of system path**
!echo /usr/local/lib/nodejs/node-{NODE_VER}-{NODE_DISTRO}/bin:
# Shows /usr/local/lib/nodejs/node-v16.14.2-linux-x64/bin
Run Code Online (Sandbox Code Playgroud)

...但这并不:

!echo /usr/local/lib/nodejs/node-{NODE_VER}-{NODE_DISTRO}/bin:$PATH
# Shows:
# /usr/local/lib/nodejs/node-{NODE_VER}-{NODE_DISTRO}/bin:**contents of system path**
Run Code Online (Sandbox Code Playgroud)

我已经尝试了几种组合,例如使用$NODE_VER语法代替(它生成node--/代替node-{NODE_VER}-{NODE_DISTRO}/,但似乎使用shell变量(PATH)和Python变量(NODE_VER/NODE_DISTRO)的任何组合都会失败。

谁能帮助我理解为什么以及如何解决它?

正如您可能已经猜到的那样,我的最终目标是实际将此文件夹添加到 PATH 而不是仅仅回显它 - 类似于:

!export PATH=/usr/local/lib/nodejs/node-{NODE_VER}-{NODE_DISTRO}/bin:$PATH
Run Code Online (Sandbox Code Playgroud)

ipython jupyter-notebook jupyter-lab amazon-sagemaker

2
推荐指数
1
解决办法
1041
查看次数

如何加载Sagemaker中没有的python模块?

我想安装spacy,它不是Sagemaker平台的一部分.我应该如何安装呢?

amazon-web-services amazon-sagemaker

1
推荐指数
2
解决办法
1226
查看次数

在 SageMaker 中自动执行 .ipynb 文件

我想自动化 Jupyter 的工作。

我在 AWS Lambda 中创建了一个函数,当 S3 存储桶收到一个 .csv 文件时,它会打开确定的 Jupyter 实例并且工作正常。

现在我想执行完成所有工作的 .ipynb 文件。

我曾尝试使用 Jupyter 配置生命周期。

但它总是失败。是否可以在同一个 lambda 函数中做到这一点?

jupyter nbconvert --execute --to notebook
                  --inplace /home/ec2-user/SageMaker/Scikit.ipynb
                  --ExecutePreprocessor.kernel_name=python3
                  --ExecutePreprocessor.timeout=1500
Run Code Online (Sandbox Code Playgroud)

当您运行文件 .ipynb 没有运行时,它会在终端中执行它。

我希望您以在线模式运行它。

在文件 .ipynb 中,我调用 Sagemaker 来引入角色,AWS CloudWatch 显示的错误之一如下:

ModuleNotFoundError: No module named 'sagemaker' <-- Appears in CloudWatch
Run Code Online (Sandbox Code Playgroud)

python jupyter-notebook amazon-sagemaker

1
推荐指数
1
解决办法
4342
查看次数

SageMaker PyTorchModel 传递自定义变量

通过类使用 SageMaker 部署模型时PyTorchModel,是否可以传递自定义环境变量或 kwargs?

我希望能够通过自定义参数切换服务代码的功能,而不是需要编写多个serve.py来处理不同的训练模型导出方法。

model = PyTorchModel(name='my_model',
                     model_data=estimator.model_data,
                     role=role,
                     framework_version='1.0.0',
                     entry_point='serve.py',
                     source_dir='src',
                     sagemaker_session=sess,
                     predictor_cls=ImagePredictor,
                     <custom_argument?>
                    )
Run Code Online (Sandbox Code Playgroud)

keyword-argument pytorch amazon-sagemaker

1
推荐指数
1
解决办法
624
查看次数

部署作为服务创建的sagemaker端点

我已经在AWS Sagemaker上训练了信用欺诈数据集并创建了模型的端点。假设我想将其作为服务提供给我的朋友。他有一些信用数据,想知道交易是否欺诈。他希望使用我的端点。我该如何分享?

  1. 我应该共享我的终端ARN吗?我认为这不是正确的方法。没有普通帐户,他将无法使用它。
  2. 还是有另一种方法

endpoint amazon-web-services amazon-sagemaker

1
推荐指数
1
解决办法
36
查看次数

AWS Sagemaker 上 Facebook Prophet 的导入问题

我正在尝试在 AWS Sagemaker Jupyter 笔记本上使用 Facebook Prophet。我尝试通过两种方式安装 fbprophet:

!{sys.executable} -m pip install fbprophet

!conda install -c conda-forge fbprophet --yes
Run Code Online (Sandbox Code Playgroud)

(最后一个来自我在其他论坛上看到的几个答案)

但是,它们似乎都不起作用。特别是,最新的似乎适用于安装,但随后导入 fbprophet 导致错误,这似乎与 matplotlib 相关:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-8-d9f3d4c04a60> in <module>()
      1 # Imports
----> 2 from fbprophet import Prophet

~/anaconda3/envs/python3/lib/python3.6/site-packages/fbprophet/__init__.py in <module>()
      6 # of patent rights can be found in the PATENTS file in the same directory.
      7 
----> 8 from fbprophet.forecaster import Prophet
      9 
     10 __version__ = '0.6'

~/anaconda3/envs/python3/lib/python3.6/site-packages/fbprophet/forecaster.py in <module>()
     17 …
Run Code Online (Sandbox Code Playgroud)

python matplotlib amazon-sagemaker facebook-prophet

1
推荐指数
1
解决办法
1621
查看次数

如何使用 TensorFlow 估算器和 Python Sagemaker SDK 指定最大运行时间?

使用 Python Sagemaker SDK,可以使用 TensorFlow 启动一项训练作业,代码如下:

import sagemaker
from sagemaker.tensorflow import TensorFlow

sess = sagemaker.Session()
tf_estimator = TensorFlow(...)
tf_estimator.fit(...)
Run Code Online (Sandbox Code Playgroud)

是否可以在此脚本中的某处指定训练的最大运行时间?

python tensorflow amazon-sagemaker

1
推荐指数
1
解决办法
1235
查看次数

使用 SageMaker Pytorch 图像进行训练

我正在尝试将微调 BERT 模型的训练过程容器化,并在 SageMaker 上运行。我计划使用预构建的 SageMaker Pytorch GPU 容器 ( https://aws.amazon.com/releasenotes/available-deep-learning-containers-images/ ) 作为起点,但在提取图像时遇到问题我的构建过程。

我的 Dockerfile 如下所示:

# SageMaker PyTorch image
FROM 763104351884.dkr.ecr.us-east-1.amazonaws.com/pytorch-training:1.5.0-gpu-py36-cu101-ubuntu16.04


ENV PATH="/opt/ml/code:${PATH}"

# /opt/ml and all subdirectories are utilized by SageMaker, we use the /code subdirectory to store our user code.
COPY /bert /opt/ml/code

# this environment variable is used by the SageMaker PyTorch container to determine our user code directory.
ENV SAGEMAKER_SUBMIT_DIRECTORY /opt/ml/code

# this environment variable is used by the SageMaker PyTorch container to determine our …
Run Code Online (Sandbox Code Playgroud)

amazon-web-services pytorch amazon-sagemaker

1
推荐指数
1
解决办法
1993
查看次数

AWS Sagemaker AttributeError:无法设置属性错误

我是 python 编程的新手。遵循 AWS 学习路径:

https://aws.amazon.com/getting-started/hands-on/build-train-deploy-machine-learning-model-sagemaker/?trk=el_a134p000003yWILAA2&trkCampaign=DS_SageMaker_Tutorial&sc_channel=el&sc_campaign_Marketing_Scientotc&sc_campaign_Marketing_Scientotc

执行以下块(在 conda_python3 中)时出现错误:

test_data_array = test_data.drop(['y_no', 'y_yes'], axis=1).values #load the data into an array
xgb_predictor.content_type = 'text/csv' # set the data type for an inference
xgb_predictor.serializer = csv_serializer # set the serializer type
predictions = xgb_predictor.predict(test_data_array).decode('utf-8') # predict!
predictions_array = np.fromstring(predictions[1:], sep=',') # and turn the prediction into an 
array
print(predictions_array.shape)
Run Code Online (Sandbox Code Playgroud)

AttributeError Traceback (most recent call last) in 1 test_data_array = test_data.drop(['y_no', 'y_yes'], axis=1).values #将数据加载到数组中----> 2 xgb_predictor.content_type = ' text/csv' # 为推理设置数据类型 3 xgb_predictor.serializer …

python amazon-s3 amazon-web-services amazon-sagemaker

1
推荐指数
1
解决办法
1193
查看次数

sagemaker官方教程是否会产生AttributeError,如何解决?

我正在关注AWS Sagemaker 教程,但我认为步骤 4a 中存在错误。特别是,在第 3 行,我被指示输入:

     s3_input_train = sagemaker.s3_input(s3_data='s3://{}/{}/train'.format(bucket_name, prefix), content_type='csv')
Run Code Online (Sandbox Code Playgroud)

我得到了错误

----> 3 s3_input_train = sagemaker.s3_input(s3_data='s3://{}/{}/train'.format(bucket_name, prefix), content_type='csv')

AttributeError: module 'sagemaker' has no attribute 's3_input'
Run Code Online (Sandbox Code Playgroud)

实际上, usingdir表明 sagemaker 没有名为 s3_input 的属性。如何解决这个问题,以便我可以在教程中继续前进?我尝试使用session.inputs,但这会将我重定向到一个页面,说该页面session已弃用并建议我使用sagemaker.inputs.TrainingInput而不是sagemaker.s3_inputs. 这是前进的好方法吗?

感谢大家的帮助和耐心!

amazon-web-services python-3.x amazon-sagemaker

1
推荐指数
1
解决办法
256
查看次数