cancel
Showing results for 
Search instead for 
Did you mean: 

Machine Learning API in Cloud Application Programming Model

WouterLemaire
Active Contributor
0 Kudos

Hi all,

Has anyone tried to use the Machine Learning API in a hook function of your Java based Cloud Appication Programming Model Project in SAP Web IDE?

I try to use the code of the following blog in a function import of my CAP project.

https://blogs.sap.com/2018/07/29/production-ready-integration-of-sap-leonardo-machine-learning-found...

Everytime I run the code, the service crashes on the invoke function and returns the following error:

---- SAP Metaspace Statistics (Non-Class Space) ---- MaxMetaspaceSize: 107372544. Metaspace Colaescation is ON. -- VirtualSpaceList -- 43 space(s). Non-Current Nodes: Used: 92160K, Comitted: 92160K, Reserved: 92160K. Current Space: Used: 980K, Comitted: 1024K, Reserved: 2048K. Total (current and noncurrent): Used: 93140K, Comitted: 93184K, Reserved: 94208K. Chunk Composition: special normal: used: 1 free: 0 special padding: used: 3 free: 5 special leftover: used: 0 free: 0 special coalesced: used: 0 free: 0 special split: used: 162 free: 38 small normal: used: 49 free: 353 small padding: used: 51 free: 194 small leftover: used: 0 free: 0 small coalesced: used: 1 free: 0 small split: used: 0 free: 0 medium normal: used: 1337 free: 0 medium padding: used: 0 free: 0 medium leftover: used: 0 free: 0 medium coalesced: used: 0 free: 0 medium split: used: 0 free: 0 humongous normal: used: 4 free: 0 humongous padding: used: 0 free: 0 humongous leftover: used: 0 free: 0 humongous coalesced: used: 0 free: 0 humongous split: used: 0 free: 0 -- Metaspaces -- 173 live Metaspaces. special Chunks: 73 non-current chunks: Used: 71K, Free: 1K. 93 current chunks: Used: 69K, Free: 23K. Total: 166 chunks: Used: 140K, Free: 25K. small Chunks: 25 non-current chunks: Used: 99K, Free: 0K. 76 current chunks: Used: 116K, Free: 187K. Total: 101 chunks: Used: 216K, Free: 187K. medium Chunks: 1333 non-current chunks: Used: 85286K, Free: 25K. 4 current chunks: Used: 107K, Free: 148K. Total: 1337 chunks: Used: 85394K, Free: 174K. humongous Chunks: 4 non-current chunks: Used: 4769K, Free: 1K. 0 current chunks: Used: 0K, Free: 0K. Total: 4 chunks: Used: 4769K, Free: 1K. Total: 1435 non-current chunks: Used: 90227K, Free: 28K. 173 current chunks: Used: 292K, Free: 360K. Total: 1608 chunks: Used: 90520K, Free: 388K. Accumulated Free Blocks: 26509 -- ChunkManager -- 43 special chunks, total size 43K. 547 small chunks, total size 2188K. 0 medium chunks, total size 0K. 0 homungous chunks, total size 0K. Resource exhaustion event. ResourceExhausted! (1/0)

Any idea what this means? Do I not have enough resources on my trial account?

Thank you in advance for your help.

Kr, Wouter

WouterLemaire
Active Contributor
0 Kudos

Thank you all for helping!

It works thanks to this setting in mta.yml:

JBP_CONFIG_SAPJVM_MEMORY_SIZES:'metaspace:256m..'

I was not able to set this is the correct answer because it was a reply on another answer.

Kr, Wouter

Accepted Solutions (1)

Accepted Solutions (1)

nice2mitja
Employee
Employee

Hi there,

sounds like you are running out of "Metaspace" (a native memory region used by the Java Virtual Machine to manage Java objects). Please try to increase the metaspace size (current size is ~100MB) and restage your application:

cf set-env <APP_NAME> JAVA_OPTS '-XX:MaxMetaspaceSize=256M'
cf restage <APP_NAME>

Does the application start fine this time?

Best regards,

Mitja

WouterLemaire
Active Contributor

Thanks! I tried it but got the same result...

For your information, I'm using Web IDE and I've added the parameter in the mta.yml:

cschubert
Participant

Hi Wouter,

you could also try to adjust the following variable:

JBP_CONFIG_SAPJVM_MEMORY_SIZES: 'metaspace:256m..'

I'm not 100% sure, which variable is used where, but for us this worked.

Greetings

Chris

0 Kudos

Hi everyone,

I am following this blog https://blogs.sap.com/2018/07/29/production-ready-integration-of-sap-leonardo-machine-learning-found... to implement ml services using sdk in web ide.

I am stuck at creating user provided variable.What name should be provide in key and value.

I have already set ALLOW_MOCKED_AUTH_HEADER to true.But I am confused how to add the below VCAP_SERVICES format as key and value?

Can someone help me..

VCAP_SERVICES='{ "ml-foundation-trial-beta": [{"name": "mlf-trial-beta","instance_name": "mlf-trial-beta","binding_name": null, "credentials": {"clientid": " ", "clientsecret": " ", "serviceurls": { "TRANSLATION_URL": " https://mlftrial-machine-translation.cfapps.eu10.hana.ondemand.com/api/v2/text/translation", "TEXT_CLASSIFIER_URL": " https://mlftrial-text-classifier.cfapps.eu10.hana.ondemand.com/api/v2/text/classification", }, "url": " " }, } ] }'

Answers (2)

Answers (2)

former_member241648
Participant

Hi Wouter,

I tried running the blog as described and it still works. I also tried changing the metaspace parameter in the manifest.yml file to 256mb and a ‘cf push’ changed that on the platform, too.

Do you have a larger overall project which might impact the metaspace? Could you verify that the parameter got propagated from mta.yml to the JRE?

Best,
Georg

nice2mitja
Employee
Employee

Would you mind sharing the log again, so I can check whether settings got picked up properly and if it's indeed the same issue?

Cheers,

Mitja