EDUCBA

EDUCBA

MENUMENU
  • Free Tutorials
  • Free Courses
  • Certification Courses
  • 600+ Courses All in One Bundle
  • Login
Home Software Development Software Development Tutorials PyTorch Tutorial PyTorch AMD
Secondary Sidebar
PyTorch Tutorial
  • PyTorch
    • PyTorch Image Classification
    • PyTorch Random
    • PyTorch Variable
    • PyTorch Activation Function
    • Python Formatted String
    • PyTorch GPU
    • PyTorch CUDA
    • PyTorch DataLoader
    • PyTorch LSTM
    • PyTorch Pad
    • PyTorch OpenCL
    • PyTorch Lightning
    • PyTorch SoftMax
    • PyTorch Flatten
    • PyTorch gan
    • PyTorch max
    • PyTorch pip
    • PyTorch Parameter
    • PyTorch Load Model
    • PyTorch Distributed
    • PyTorch BERT
    • PyTorch interpolate
    • PyTorch JIT
    • PyTorch expand
    • PyTorch AMD
    • PyTorch GRU
    • PyTorch rnn
    • PyTorch permute
    • PyTorch argmax
    • PyTorch SGD
    • PyTorch nn
    • PyTorch One Hot Encoding
    • PyTorch Tensors
    • What is PyTorch?
    • PyTorch MSELoss()
    • PyTorch NLLLOSS
    • PyTorch MaxPool2d
    • PyTorch Pretrained Models
    • PyTorch Squeeze
    • PyTorch Reinforcement Learning
    • PyTorch zero_grad
    • PyTorch norm
    • PyTorch VAE
    • PyTorch Early Stopping
    • PyTorch requires_grad
    • PyTorch MNIST
    • PyTorch Conv2d
    • Dataset Pytorch
    • PyTorch tanh
    • PyTorch bmm
    • PyTorch profiler
    • PyTorch unsqueeze
    • PyTorch adam
    • PyTorch backward
    • PyTorch concatenate
    • PyTorch Embedding
    • PyTorch Tensor to NumPy
    • PyTorch Normalize
    • PyTorch ReLU
    • PyTorch Autograd
    • PyTorch Transpose
    • PyTorch Object Detection
    • PyTorch Autoencoder
    • PyTorch Loss
    • PyTorch repeat
    • PyTorch gather
    • PyTorch sequential
    • PyTorch U-NET
    • PyTorch Sigmoid
    • PyTorch Neural Network
    • PyTorch Quantization
    • PyTorch Ignite
    • PyTorch Versions
    • PyTorch TensorBoard
    • PyTorch Dropout
    • PyTorch Model
    • PyTorch optimizer
    • PyTorch ResNet
    • PyTorch CNN
    • PyTorch Detach
    • Single Layer Perceptron
    • PyTorch vs Keras
    • torch.nn Module

PyTorch AMD

PyTorch AMD

Introduction to PyTorch AMD

PyTorch is the framework used for tensor computation and is accelerated by GPU. It has its front end made up of python. On the other hand, AMD (Advanced Micro Devices) is an open-source platform, and PyTorch’s functionalities and capabilities can be extended simply by using the libraries of python. AMD that is Automatic Differentiation, is one such platform supported by PyTorch AMD, is used by using tape-based systems. This includes doing some changes at neural and functional level layers of the neural network.

In this article, we will try to dive into the topic of PyTorch AMD and will try to understand What is PyTorch AMD, how to use PyTorch AMD, image classification models in AMD, its associated examples, and finally give our concluding statement on it.

What is PyTorch AMD?

PyTorch AMD is the container of the framework, allowing us to run the container of AMD’s machine learning framework. For doing so, it is necessary that the docker environment of your system should support the AMD GPU.

The minimum requirements of the single node server are that it should have X86-64 CPU or CPUs along with GPU(s) of AMD instinct MI100 and GPU of Radeon instinct MI50 (S). The operating system used for this should be Centos 8.3 or higher OR Ubuntu 18.04 or higher version. The driver for ROCm should be compatible with the 4.2 version, and the Docker Engine Singularity container is used at runtime.

Start Your Free Software Development Course

Web development, programming languages, Software testing & others

All in One Software Development Bundle(600+ Courses, 50+ projects)
Python TutorialC SharpJavaJavaScript
C Plus PlusSoftware TestingSQLKali Linux
Price
View Courses
600+ Online Courses | 50+ projects | 3000+ Hours | Verifiable Certificates | Lifetime Access
4.6 (86,560 ratings)

By default, the considerations and suppositions made by PyTorch AMD container of frameworks are that the server should contain x-86-64 single or multiple CPUs and should have a minimum of one listing AMD GPU. Furthermore, to run the docker container, the server should have the listed ROCm driver with a specified or higher version installed on it and the required operating system. Finally, the server should contain the docker engine in it to run the container.

If you want to go for installing the Docker engine, kindly visit this link. In order to install singularity in its latest version, if the use of singularity is already planned, then visit this link. For installation of procedures of ROCm as well as validity checks, kindly go through this link.

How to Use PyTorch AMD?

AMD is an open-source platform and has high performance and flexibility. It comes along with various libraries, compilers, and languages that can be used by developers and communities working in Machine Learning, Artificial Intelligence, and HPC technology to make their task of coding easy, fast, and implementing complex logic and functionalities in it. The biggest task is that PyTorch AMD provides you with containers.

In order to get and run the container in PyTorch AMD, we can make use of the following command –

Docker pull “name of the container”

For example, for AMDih container of PyTorch, the command would be –

docker pull AMDih / PyTorch : rocm4.2_ubuntu18.04_py3.6_PyTorch_1.9.0

Image classification models in AMD

Broadly, image classification can be done by using either of the two technologies of PyTorch or tensorflow in AMD. Some of the products include AMD Radeon instinct MI50, AMD Instinct MI100, while for tensorflow same products can be used.

There are various models that can be used in AMD for image classifications. Some of them are as listed below –

  • Efficent b0 and b7
  • Resnet 101 and 50
  • Inceptive v3

For running a particular image container in PyTorch AMD, you will have to give a check on the operating system on which you have installed and the software and its version that you have installed in the process of running the containers of AMD. Some of the steps that need to be followed for running the containers are as given below –

  • A search of the tab named Tags and then hit into the container image release that is located inside it, which you are about to run.
  • Now, inside the column of the pull tag, try clicking on the command icon, which will help you copy the docker pull command.
  • You will have to paste the command you have copied by opening a command prompt in your system. At this step, the beginning of pulling the image of the container happens. Before you go for the next step, make sure that the pulling of the docker completes.
  • Now, the container image that is pulled should be run. For running the container, you will have to choose the mode of interactive or non-interactive as per necessity and scenario.
  • While running the command, the “-it” parameter stands for the interactive mode running.
  • The option “–rm” specifies that the container should be deleted after finishing.
  • The parameter “-v” is used for specifying the directory for mounting.
  • The absolute path to the file or directory of the host system, which we will need to access in the container, is specified by using the parameter local_dir.
  • The target directory’s absolute path is specified by using the container_dir parameter when you are present in the container.
  • xx is the version of the container.
  • When you want to run particular command inside the image, the command parameter should be specified.

Examples of PyTorch AMD

Let us consider one example of PyTorch AMD –

def sampleEducbaExample(args, educbaModel, sampleEducbaExample_loader):
educbaModel.eval()
corectionPrecision = 0
cumulativeCount = 0
with torch.no_grad():
for data, target in sampleEducbaExample_loader:
achievedOutput = educbaModel(data)
predictedValue = achievedOutput.argmax(dim=1)
corectionPrecision += predictedValue.eq(target.view_as(predictedValue)).sum()
cumulativeCount += args.sampleEducbaExample_batch_size
cumulativeCorrections = corectionPrecision.copy().get().float_precision().long().item()
print('Test set: Accuracy: {}/{} ({:.0f}%)'.format(
cumulativeCorrections, cumulativeCount,
100.* cumulativeCorrections / cumulativeCount))

The output of the execution of the above program gives the following result on the console panel –

PyTorch AMD output 1

Here, we have carried out the predictions in a secure manner from end to end. Both server and client are completely unaware. The server has no idea about the output of classification and input of data, and the client is not aware of the server’s model weights.

Conclusion

We can use PyTorch AMD to improve the user’s data protection and secure machine learning. The docker container of PyTorch 3.6 internally provides AMD support.

Recommended Articles

This is a guide to PyTorch AMD. Here we discuss What is PyTorch AMD, how to use PyTorch AMD, image classification models in AMD. You may also have a look at the following articles to learn more –

  1. Dataset Pytorch
  2. PyTorch Versions
  3. PyTorch TensorBoard
  4. PyTorch Conv2d
0 Shares
Share
Tweet
Share
Primary Sidebar
Footer
About Us
  • Blog
  • Who is EDUCBA?
  • Sign Up
  • Live Classes
  • Corporate Training
  • Certificate from Top Institutions
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions
  • Privacy Policy
  •  
Apps
  • iPhone & iPad
  • Android
Resources
  • Free Courses
  • Java Tutorials
  • Python Tutorials
  • All Tutorials
Certification Courses
  • All Courses
  • Software Development Course - All in One Bundle
  • Become a Python Developer
  • Java Course
  • Become a Selenium Automation Tester
  • Become an IoT Developer
  • ASP.NET Course
  • VB.NET Course
  • PHP Course

ISO 10004:2018 & ISO 9001:2015 Certified

© 2022 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA
Free Software Development Course

C# Programming, Conditional Constructs, Loops, Arrays, OOPS Concept

*Please provide your correct email id. Login details for this Free course will be emailed to you

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA Login

Forgot Password?

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA
Free Software Development Course

Web development, programming languages, Software testing & others

*Please provide your correct email id. Login details for this Free course will be emailed to you

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

By signing up, you agree to our Terms of Use and Privacy Policy.

Let’s Get Started

By signing up, you agree to our Terms of Use and Privacy Policy.

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy

Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more