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/01 Report--
Today, I will talk to you about how to quickly set up the Serverless AI application to write poems. Many people may not know much about it. In order to make you understand better, the editor has summarized the following contents for you. I hope you can get something from this article.
Preface
First of all, we will introduce several more important concepts that have emerged:
Function computing (Function Compute): function computing is an event-driven service. Through function calculation, users do not need to manage the operation of the server, but only need to write code and upload. The function calculation prepares the computing resources and runs the user code in an elastic way, while the user only needs to pay according to the resources consumed by the actual code. Function to calculate more information.
Fun: Fun is a tool for supporting Serverless application deployment, which can help you easily manage resources such as function computing, API gateways, log services, and so on. It assists you in developing, building, and deploying operations through a resource configuration file (template.yml). More documentation references for Fun.
Note: the technique introduced requires Fun version 3.2.0 or greater.
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.
Docker
Fun
Fcli
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
For Windows and Linux user installation, please refer to:
Https://github.com/aliyun/fun/blob/master/docs/usage/installation.md
Https://github.com/aliyun/fcli/releases
After installation, 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.
Cdn.nlark.com/yuque/0/2019/png/502931/1577342619409-f43d3642-5526-458c-8519-96e4d61fbb4a.png ">
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.
At this point, the ancient poetry creation program has been successfully deployed to the function calculation.
After reading the above, do you have any further understanding of how to quickly build a Serverless AI app to write poetry? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
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.