In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
This article is about the realization of ancient poetry creation program by Serverless and AI. The editor thinks it is very practical, so I share it with you to learn. Without saying much, let's read on.
Dependent tool
This project is developed under MacOS, the tools involved are platform-independent, and should also be applicable to Linux and Windows desktop systems. Before starting this example, make sure that the following tools are installed correctly, updated to the latest version, and configured correctly.
DockerFunFcli
The Fun and Fcli tools rely on docker to simulate the local environment.
For MacOS users, you can use homebrew to install:
Brew cask install dockerbrew tap vangie/formulabrew install funbrew install fcli
After Windows and Linux are installed, remember to initialize the configuration by executing fun config first.
Note that if you have already installed fun, make sure that the fun version is above 3.2.0.
$fun-version3.2.2 background
AI model serving is a typical application scenario of function calculation. After training the model, data scientists often need to find a software engineer to turn the model into a system or service, which is often called model serving. Function computing does not need operation and elastic scaling, which is exactly in line with the demand of data scientists for highly available distributed systems. This article will introduce an example of deploying a TensorFlow CharRNN-trained model for automatically writing five-character quatrains to functional computing.
Basically all FaaS platforms set code package restrictions in order to reduce the cold start of the platform, and function calculation is no exception. Because the files of python TensorFlow dependent libraries and training models are hundreds of megabytes, even the compression far exceeds the limit of the function calculating the 50m code package size. For such super-large files, the function calculation command line Fun tool natively supports this large dependency deployment (version 3.2.0 or above), just follow the prompts of the wizard.
Get started quickly. Clone poetry project git clone https://github.com/vangie/poetry.git2. Installation dependency
Because the script of the training model is time-consuming, the trained model has been stored in the model directory in advance. If you want to retrain the model, just execute make train.
$fun installusing template: template.ymlstart installing function dependencies without dockerbuilding poetry/poetryFunfile exist Fun will use container to build forcelyStep 1ax 3: FROM registry.cn-beijing.aliyuncs.com/aliyunfc/runtime-python3.6:build-1.7.7-- > 373f5819463bStep 2 4823-b1ec-afb05e471666:latestcopying function artifact to/ Users/ellison/poetrycopy from container 3: WORKDIR / code-- > Using cache- > f9f03330dddeStep 3 RUN fun-install pip install tensorflow 3: RUN fun-install pip install tensorflow-- > Using cache- > af9e756d07c7sha256:af9e756d07c77ac25548fa173997065c9ea8d92e98c760b1b12bab1f3f63b112Successfully built af9e756d07c7Successfully tagged fun-cache-1b39d414-0348-4823-b1ec-afb05e471666:latestcopying function artifact to/ Users/ellison/poetrycopy from container / mnt/auto/. To localNasDirInstall SuccessTips for next step==* Invoke Event Function: fun local invoke* Invoke Http Function: fun local start* Build Http Function: fun build* Deploy Resources: fun deploy3. Local running function
Execute fun local invoke to run the function locally, and the correct response is as follows:
$fun local invoke poetryMissing invokeName argument, Fun will use the first function poetry/poetry as invokeNameskip pulling image aliyunfc/runtime-python3.6:1.7.7...FunctionCompute python3 runtime inited.FC Invoke Start RequestId: b125bd4b-0d23-447b-8d8c-df36808a458b. (omitted part of the log) Dog Flower Shangshui Wind, mid-autumn in January. No one goes to the river, but there is no one in the mountains. In the middle of the river and mountain, it will not be repaid for a while. I don't know where the landscape is, and Jiang Yang has nothing to see. The mountain wind blows the color of the water, and the autumn water flows into the clouds. The water moon often sees each other, and the mountain city enters the water. There are no rivers and clouds everywhere, and spring water does not return to each other. The spring river of Nomi is far away, and the autumn wind falls deep on the moon. RequestId: 938334c4-5407-4a72-93e1-6d59e52774d8 Billed Duration: 14074 ms Memory Size: 1998 MB Max Memory Used: 226 MB4. Deployment function
Deploy the function through fun deploy and upload the function to nas.
Fun deploy
Fun automatically completes dependency deployment, and when fun deploy detects that the packaging dependency exceeds the platform limit (50m), it goes to the configuration wizard to help users automate the configuration.
After selecting "Y", you don't need to do anything else until the deployment is complete.
5. Run the remote function
Call the remote function through fun invoke (you can also call it through the function calculation console):
$fun invokeusing template: template.ymlMissing invokeName argument, Fun will use the first function poetry/poetry as invokeName= FC invoke Logs begin = omit part of the log. Restored from: / mnt/auto/model/poetry/model-10000FC Invoke End RequestId: c0d7947d-7c44-428e-a5a0-30e6da6d1d0fDuration: 18637.47 ms, Billed Duration: 18700 ms, Memory Size: 2048 MB, Max Memory Used: 201.10 MB= FC invoke Logs end = FC Invoke Result: this month, not without years. No matter what happens when there is no time to go, who deserves the old year. I don't know where there is no limit, Acacia is in the mountains. Why not know the guest, why not sometimes. Knowing each other without seeing is not the heart of the people. Not without years, when in the hometown. It is not everyone who knows not to be on the road in the mountains.
On Serverless and AI to achieve ancient poetry creation program to share here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.