ZinuoCai commented on issue #5092:
URL: https://github.com/apache/openwhisk/issues/5092#issuecomment-799912488
I ask the question because I want to add a gpu memory limit to the pod. I
have change the code of OpenWhisk to satisfy the requirements, but I fail to
create the action with openwhisk-cli because it does not support self-defined
limit keywords. We can create an action with the restful API. I release my code
below.
```py
import requests
code = "[your code here]"
action_name = '[your action name]'
img = '[docker image name]'
# a special limit in my case
gpu_memory = 1024
headers = {
'accept': 'application/json',
'Content-Type': 'application/json',
}
# change the below to your identity information
auth = ('23bc46b1-71f6-4ed5-8c54-816aa4f8c502',
'123zO3xZCLrMN6v2BKK1dXYFpXlPkccOFqm12CdAsMgRU4VrNZ9lyGVCGuMDGIwP')
url = 'https://127.0.0.1:31001/api/v1/namespaces/guest/actions/%s' %
action_name
data = """
{
"exec":{
"kind":"blackbox",
"image": "%s",
"code":"%s",
"binary":false
},
"limits":{
"gpuMemory": %d
}
}
""" % (img, code, gpu_memory)
response = requests.put(url, headers=headers, data=data, verify=False,
auth=auth)
print(response.content)
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]