From the course: Up and Running with PyTorch by Pearson

Unlock this course with a free trial

Join today to access over 25,600 courses taught by industry experts.

Working with devices

Working with devices

So, the second bit of the core of what makes PyTorch unique or powerful is its ability to run computations on, in general, accelerator devices. Most of the time, those accelerator devices are graphical processing units or GPUs. PyTorch makes it as simple and boring, in a sense, as possible. If you do want to just see whether or not Torch can identify any potential devices or For GPUs, you can run the torch.cuda is available function. In this case, we're actually printing out as false because this Google Colab notebook, I started with just the CPU runtime. So this is a good kind of practical or hopefully realistic example of what can happen. say we ran all of this code. We find out that we forgot to attach a GPU runtime. We change our runtime type. We can see here we have our CPU. Let's attach a T4 GPU. We save that. Notice up here that we're trying to connect to a new machine. Google Colab essentially has to reprovision its virtual machine. So now if we try to run any torch function…

Contents