Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to build a TensorFlow ServerlessAI platform based on function calculation

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

It is believed that many inexperienced people have no idea about how to build a TensorFlow ServerlessAI platform based on function calculation. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.

Scene introduction

A TensorFlow Serverless AI reasoning platform is established based on function calculation.

Background knowledge

Function Computing Function Compute is an event-driven fully managed computing service. Using function calculations, you don't need to purchase and manage infrastructure such as servers, just write and upload code. Function computing prepares computing resources for you, runs tasks flexibly and reliably, and provides functions such as log query, performance monitoring and alarm. Function computing helps you build applications quickly without having to manage the server (Serverless) and just focus on the function code. Function calculation can be flexibly scaled, and you only need to pay by usage. Summary of advantages: the main advantages of AI-intensive reasoning such as CPU-intensive reasoning based on function calculation 1. Easy to use, only focus on business logic development, greatly improve the efficiency of engineering development.

Self-built solution has too much learning and configuration costs, such as ESS needs to do a variety of different parameter configuration system environment maintenance and upgrade for different scenarios. two。 Free of operation and maintenance, function execution level granularity monitoring and alarm.

3. Millisecond elastic expansion ensures high flexibility and availability, while covering delay-sensitive and cost-sensitive types.

4. In CPU-intensive computing scenarios, by setting a reasonable combined billing mode, there is a cost advantage in the following scenarios:

The request for access has obvious peaks and troughs, and there are not even stable load requests at other times, but there is a sudden change in the number of requests in some periods.

Scene experience

The scenario will introduce the best practices of deep learning AI inference platform using function computing product deployment, calculating Function Compute based on function.

So that developers in the field of artificial intelligence can focus more on the training of algorithm models and the development of business logic, and hand over the operation and maintenance of computing clusters to function computing to improve work efficiency.

The end result: identify whether the animal in the photo is a cat or a dog by uploading a picture of a cat or dog. DEMO sample effect entry: http://sz.mofangdegisn.cn.

Step 1: connect to the ECS server

ECS resource address: https://developer.aliyun.com/adc/scenario/35a73acbb9cb477e8a4a5b22021f23a9 reference article step link ECS

Step 2: activate function computing service

Before using the function to calculate, you need to activate the service on the Aliyun product details page.

Step 3: install the Fun tool

Fun is a tool for supporting the deployment of Serverless applications that can help you easily manage resources such as functional computing, API gateways, and logging services. It assists you with development, build, and deployment operations through a resource configuration file (template.yml). 1. Download the installation package for Fun locally. Please set the value of the following FUN_VERSION variable to the latest version number, which can be found in Releases. The following actions will install and configure Fun on the ECS server.

FUN_VERSION= "v3.6.1" curl-o fun-linux.zip https://gosspublic.alicdn.com/fun/fun-$FUN_VERSION-linux.zip

two。 Install the decompression tool unzip and use unzip to extract the downloaded Fun installation package to the current directory.

Yum-y install unzip unzip fun-linux.zip

3. Move the extracted executable to the system path.

Mv fun-*-linux / usr/local/bin/fun

4. Configure information such as the Ali Cloud account associated with Fun and the timeout for calling SDK.

Fun config

Please refer to the following information to enter your Aliyun account ID, AccessKeyID and AccessKey key and other information.

Aliyun Account ID: the @ symbol in the sub-user name is followed by the main account ID assigned to you. For example, the account ID contained in u-zftb79nc@105997185439 is 105997185439.

Aliyun Access Key ID and Aliyun Access Key Secret: please use the sub-accounts AK ID and AK Secret provided by the platform.

The timeout in seconds for each SDK client invoking: it is recommended to set the timeout period a little longer (for example, 10000) to prevent timeout interruptions when uploading deployment packages. The correct settings are as follows:

Step 4: install Docker

1. Install dependent libraries for Docker.

Yum install-y yum-utils device-mapper-persistent-data lvm2

two。 Add software source information for docker-ce.

Yum-config-manager-- add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

3. Install docker-ce.

Yum makecache fastyum-y install docker-ce

4. Start the Docker service.

Systemctl start docker step 5: create a NAS file system mount point

1. Log into the NAS console. two。 Select File system > File system list. 3. Select the region where the cloud resource is located in the upper left corner. 4. Locate the file system corresponding to NAS file system ID in the resource information bar on the left side of the experience page, and click more > add mount points. 5. On the add mount point page, configure the following parameters.

6. Check the mount point address, as shown in the following figure.

Step 6: download the project code

1. Install the Git tool and use Git to clone the project code locally.

Yum-y install gitgit clone https://github.com/awesome-fc/cat-dog-classify.git

two。 Edit the deployment template file template.yml of FUN in the project, and modify the log service project name and NAS storage mount configuration. a. Use vim to open the template file.

Cd cat-dog-classifyvim template.yml

b. Enter the following command to globally replace the log service project name.

:% s/log-ai-pro/log-ai-test/g

Log-ai-test in the command is the modified project name, which you can replace with your custom project name.

c. Modify the NAS mount configuration. The default auto method will automatically create a NAS file system. Here we modify the information filled in for the pre-created NAS file system of the platform.

VpcConfig: VpcId: 'vpc-uf6u8*zf1r4' VSwitchIds: [' vsw-uf6*038fy'] SecurityGroupId: 'sg-uf6e*w6qz' NasConfig: UserId: 10003 GroupId: 10003 MountPoints:-ServerAddr:' 33 pieces of fruit.

The modified parameters are described as follows:

The VpcId, VSwitchId and SecurityGroupId information in VpcConfig can be viewed on the instance details page of the ECS console.

The value of ServerAddr is changed to the mount point address in step 3. After modification, as shown in the following figure:

Step 7: upload dependent files to NAS

1. Execute the following command to initialize NAS.

Fun nas init

two。 View the directory location of the local NAS.

Fun nas info

The output of the command is as follows:

3. Execute the following command to install related dependencies.

Fun install-v

The result of the successful execution of the command is as follows.

This command will follow the definition in the Funfile file:

Download the dependency to the .fun / nas/auto-default/classify/python directory.

Copy the model file from model to the .fun / nas/auto-default/classify/model/ directory. 4. Synchronize the local NAS directory to Ali Cloud NAS storage.

Fun nas sync

The result of the command execution is shown below. It shows that there are about 700m synchronized files with more content, and the synchronization time is about 40 minutes. Please wait patiently.

5. Check to see if the file is uploaded to the remote NAS directory.

Fun nas ls nas://classify:/mnt/auto/ step 9: deploy to the function computing platform

Deploy the function to the function computing platform by doing the following:

Fun deploy-y

The execution result is shown in the figure below, where 19176540-18576685985*.test.functioncompute.com is the temporary domain name assigned by the function computing platform, with a validity period of 10 days and a limit of 1000 calls per day. If the following error message appears during deployment. Cause of the problem: the log project name defined in the template configuration file already exists. Solution: please modify the log project name in the template.yml file.

Step 9: test the forecasting service

1. After the deployment is complete, wait about 30 seconds to open the temporary domain name in the browser, as shown in the following figure. If an error similar to the following introduction module occurs when visiting the page. The reason for the problem: due to network problems, the content of NAS synchronization is incomplete. Solution: please re-execute the command fun nas sync.

two。 Upload a picture of a cat or dog. 3. Click the Predict button to view the prediction recognition results. Function computing has the characteristic of dynamic scalability, and automatically flexibly expands the execution environment to the execution environment according to the amount of concurrent requests. When the reserved instance does not meet the request to call the function, the function calculation automatically expands the instance as needed for the function to execute, and the call has a cold start process.

After reading the above, have you mastered the method of building a TensorFlow ServerlessAI platform based on function calculation? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report