
PyTorch is a flexible machine learning library for building deep learning models that can perform a wide range of tasks such as image recognition and language processing.
This article explains how to build a PyTorch container image using the Vultr Container Registry.
Deploy an instance using Vultr's GPU Marketplace App
Access the server using SSH.
Start the Docker service.
Add the non-root user to the Docker group. For example, linuxuser.
Switch to the user:
Create a new directory to store your PyTorch project files.
Switch to the directory.
Clone the Pytorch project repository using Git.
List all files and verify that a new pytorch directory is available.
Switch to the pytorch project directory.
List all directory files and verify that the available Dockerfile resources.
The PyTorch project directory includes the following Dockerfile resources:
Dockerfile: Contains the PyTorch build context for both CPU systems.docker.makefile: Contains advanced GPU build context and image automation directives with support for custom dependency packages.Use the above resources in the next sections to build a CPU or GPU system container image.
Follow the steps below to build a new PyTorch container image for CPU systems using the Dockerfile resource on your server.
Build a new PyTorch container image using the Dockerfile resource. Replace pytorch-image with your desired image name.
View all Docker images and verify that your new Pytoch image is available.
Output:
Follow the steps below to build a new PyTorch container image for GPU systems using docker.Makefile that contains the CUDA dependency build context compatible with NVIDIA GPU servers.
Build a new PyTorch container image for GPU using the docker.Makefile.
Wait at least 2 hours for the build process to complete. When successful, your output should look like the one below:
View all Docker images on the server and verify that a new root/pytorch image is available.
Output:
Verify the PyTorch GPU image target CUDA version and verify that your system uses the driver version or higher.
Output:
Based on the above output, NVIDIA GPU Servers with CUDA version 12.1 or higher can run your PyTorch GPU container image.
Open the Vultr Console.
Click Products and navigate to Container Registry on the main navigation bar.
Click your target Vultr Container Registry to open the management panel and view the registry access credentials.
Copy the Registry URL value, Username, and API Key to use when accessing the registry.
Switch to your server terminal session and log in to your Vultr Container Registry. Replace exampleregistry, exampleuser, registry-password with your actual registry details.
Tag your PyTorch container image with your desired Vultr Container Registry tag. For example, tag your PyTorch GPU image ID with your registry repository tag such as sjc.vultrcr.com/exampleregistry/pytorch-gpu-image.
The above command tags the Docker image with container ID d3674f1db4d5 with your Vultr Container Registry tag.
View all Docker images on the server and verify that the new tagged image is available.
Output:
Push the tagged image to your Vultr Container Registry repository.
Open your Vultr Container Registry management panel and click Repositories on the top navigation bar to verify that the new repository is available.
0 Comments
Be the first to comment and share your perspective with the community.