optimized_execution() takes 1 positional argument but 2 were given

Viewed 728

I'm following the pytorch sagemaker docs here and I'm stuck on this line

torch.jit.optimized_execution(True, {'target_device': 'eia:device ordinal'})

When I run it, I get the error optimized_execution() takes 1 positional argument but 2 were given. I'm using pytorch 1.3.1, but I tried with 1.4.0 and was running into similar problems. Can I use optimized execution without this second argument? How can I specify the accelerator?

2 Answers

(I'll refer to the Elastic Inference enabled PyTorch framework as "PyTorch-EI" for convenience)

Are you using SageMaker through notebook or hosting? SageMaker notebook support is not currently released, so there's no official notebook kernel / Conda environment that you can activate that will have the Elastic Inference enabled PyTorch framework. You could however create your own by activating the pytorch_p36 environment (which has standard PyTorch), uninstalling PyTorch, and then installing using the PyTorch-EI 1.3.1 framework wheel - linked from here.

SageMaker hosting does currently support PyTorch-EI out of the box. If you're currently using SageMaker hosting and having issues, share some of your inference code + what container you're using. List of containers can be found at here.

Also note that EC2 currently supports Elastic Inference through the DLAMI v27.0. The Conda environment name is amazonei_pytorch_p36.

I misread the documentation. It says the Elastic Inference enabled PyTorch framework accepts two parameters for this context, while the vanilla PyTorch framework accepts only one parameter.. It should work for torch 1.3.1 because that is all sagemaker supports as of now.

Related