Skip to main content

Learning Notes - July 2, 2024

Downloading PyTorch

PyTorch Official Website

Cell Command Execution Environment

Investigating where cell commands run -- initial assessment is that they run in the Jupyter startup environment rather than the corresponding virtual environment, meaning they do not run directly in the current virtual environment.

image-20240702132908034

This form must be used to run commands in the specified environment within a notebook.

Place what you want to run after &&

! source ~/anaconda3/bin/activate Deep_Learing && pip install pandas

image-20240702134255268

Checking if PyTorch is Properly Configured

image-20240702135630993

Use the following code for testing

CUDA

import torch

# Print PyTorch version
print(torch.__version__)

# Check if CUDA (GPU) is available
print(torch.cuda.is_available())

MPS

import torch

# Print PyTorch version
print(torch.__version__)

# Check if MPS is available
if torch.backends.mps.is_available():
mps_device = torch.device("mps")
print("MPS device is available.")
else:
print("MPS device is not available.")

It's Running

image-20240702154137306

image-20240702154158172

image-20240702214630164

Speed Test

M2 CPU: 62.8s

image-20240702220406101

M2 GPU: 23.8s

image-20240702220544868

4090: 15.37s

image-20240703210034773

image-20240703210337914

12 vCPU Intel(R) Xeon(R) Platinum 8352V: 28s

image-20240703211545134