Installing PyTorch on Myriad as a normal user can seem like a daunting task, but it is actually quite simple if you follow the right steps. In this tutorial, we will walk you through the process of installing PyTorch on Myriad and running some examples on GPUs.
Step 1: Log in to Myriad
First, log in to the Myriad system using your username and password. Make sure that you have the necessary permissions to install software on the system.
Step 2: Install Anaconda
Next, we will install Anaconda, which is a popular package manager and environment manager for Python. Anaconda makes it easy to manage Python packages and dependencies. You can download Anaconda from the official website (https://www.anaconda.com/products/distribution).
After downloading the Anaconda installer, run the following command to install Anaconda:
bash Anaconda3-2021.11-Linux-x86_64.sh
Follow the instructions on the screen to complete the installation process.
Step 3: Create a new conda environment
Once Anaconda is installed, we will create a new conda environment for PyTorch. Conda environments allow you to isolate your Python packages and dependencies, making it easier to manage different versions of packages.
Run the following command to create a new conda environment named "pytorch-env":
conda create -n pytorch-env python=3.8
Activate the conda environment by running the following command:
conda activate pytorch-env
Step 4: Install PyTorch
Now that we have created a new conda environment, we can install PyTorch using the conda package manager. Run the following command to install PyTorch:
conda install pytorch torchvision torchaudio cudatoolkit=11.1 -c pytorch
This command will install PyTorch, torchvision, torchaudio, and the necessary CUDA toolkit for GPU acceleration.
Step 5: Running examples on GPUs
Now that PyTorch is installed on Myriad, we can run some examples on GPUs to test the installation. First, activate the conda environment by running:
conda activate pytorch-env
Next, launch a Python shell by running the following command:
python
Import the necessary PyTorch modules and check if CUDA is available:
import torch
print(torch.cuda.is_available())
If CUDA is available, you can run some example code on GPUs. For example, you can create a tensor on the GPU and perform some computations:
# Create a tensor on the GPU
x = torch.tensor([1, 2, 3]).cuda()
# Perform some computations
y = x * 2
# Print the result
print(y)
This code will create a PyTorch tensor on the GPU, multiply it by 2, and print the result.
In this tutorial, we have walked you through the process of installing PyTorch on Myriad as a normal user and running some examples on GPUs. By following these steps, you can start working with PyTorch on Myriad and take advantage of GPU acceleration for deep learning tasks.
I'm confused why this works – your nvidia-smi shows cuda 11.2, but torch the torch installed requires 11.7. Is 11.7 also installed and torch is able to find that too?