Creation of Dockerfile – Vertex AI Workbench and Custom Model Training
A Dockerfile is a text file that is read from top to bottom by Docker. It comprises of a series of instructions that instruct Docker how to build the Docker image. A Dockerfile is a recipe for creating Docker images and executing a separate build command that generates the Docker image from that recipe.
We need to enable the APIs of container registry and artifacts registry before we build the docker images. Follow below steps to enable them.
Step 1: APIs and services
All the APIs of the platform can be enabled or disabled through APIs and services. APIs and services can be opened navigation menu as shown in Figure 4.8:
Figure 4.8: Open APIs and services of platform
- Open the navigation menu and select APIs and services.
- Alternatively, users can search for APIs and services in the search box.
- Click on Enabled APIs and services.
Step 2: Landing page of APIs and services
Landing page of APIs are services as shown in Figure 4.9:
Figure 4.9: APIs and services of GCP
- Search for container registry in the search box.
Step 3: Container registry search results
Search results for container registry is as shown in Figure 4.10:
Figure 4.10: Search results of APIs
- Right click to enable the Google Container Registry API.
- Right click on enable Artifact Registry API.
Step 4: Container registry API enablement
Container Registry is a centralized location where teams can maintain Docker images, perform vulnerability analysis, and implement fine-grained access control. Follow the step in Figure 4.11 to enable Container registry API:
Figure 4.11: Container registry API
- Click ENABLE.
Step 5: Artifacts registry API enablement
Artifact Registry supports container images and non-container artifacts. Artifact Registry enhances and expands Container Registry’s features, such as customer-managed encryption keys, VPC-SC support, Pub/Sub notifications, delivering important security, scalability, and control advancements, and more.
Follow the action shown in Figure 4.12 to enable container registry API:
Figure 4.12: Artifacts registry API
- ENABLE the Artifact registry API.
After enabling both the APIs, let us navigate back to the workbench and launch terminal. Refer to the following figure (double click on Terminal).
Step 6: Directory creation
Launch terminal (refer Figure 4.6, point no. 11) and follow the steps described in Figure 4.13 to create directory in the workbench:
Figure 4.13: Directory creation in the terminal
- Type the following commands one after the other in the Terminal window.
We create new directory call price_pred, and create Dockerfile inside the price_pred directory:
mkdir price_pred
cd price_pred
touch Dockerfile
- Dockerfile will be created inside the price_pred folder (file will have no contents, double click on the file to open it).
Step 7: Edit Dockerfile
Enter the commands in the Dockerfile as shown in Figure 4.14:
Figure 4.14: Editing Dockerfile
- Type the following commands:
FROM gcr.io/deeplearning-platform-release/tf2-cpu.2-6
WORKDIR /
COPY trainer /trainer
ENTRYPOINT [“python”,”-m”,”trainer.train”]
Explanation for the commands is provided below:
- Docker image will be built using the container images that is available in the gcr.io. (refer figure for more details).
- A working directory is set.
- It will copy the trainer folder to the working directory (trainer folder is yet to be created in the JupyterLab, trainer folder contains train.py file for model training)
- ENTRYPOINT point towards executables that execute when the container starts.
Save the Dockerfile (Ctrl + S) and close the file.
Container registry of GCP provides the repository of deep learning containers. Deep learning containers are Docker containers providing data science frameworks, libraries, and tools. These performance-optimized containers enable users to experiment and deploy processes rapidly. They are hosted at different data centers.
- gcr.io hosts images in U.S. data centers, however the location may vary.
- us.gcr.io hosts container images in EU region.
- eu.gcr.io hosts container images in US region.
- asia.gcr.io hosts container images in Asia region.
Figure 4.15 shows the repository for the gcr.io:
Figure 4.15: Container registry for gcr.io
You may also like
Archives
- September 2024
- August 2024
- July 2024
- June 2024
- May 2024
- April 2024
- March 2024
- February 2024
- January 2024
- December 2023
- November 2023
- September 2023
- August 2023
- June 2023
- May 2023
- April 2023
- February 2023
- January 2023
- November 2022
- October 2022
- September 2022
- August 2022
- June 2022
- April 2022
- March 2022
- February 2022
- January 2022
- December 2021
- November 2021
- October 2021
Calendar
M | T | W | T | F | S | S |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |
Leave a Reply