Hi everybody, welcome to a new tutorial series. In this series we are going to learn how to work with PyTorch. PyTorch is one of the most popular machine learning and deep learning frameworks. It's really fun to work with it and develop cool applications. So I hope you watch the series and learn all about the necessary basics for this framework.
So in this first video I show you how we install PyTorch. So let's start. And for this we go to the official website.
pytorch.org. Then click on Get started, then select the newest pytorch build. So right now this is version 1.3. Then select your operating systems. In my case, it's a Mac, then select the package manager with which you want to install pytorch.
So I highly recommend to use anaconda. And if you haven't installed anaconda yet and don't know how to use it, then please watch my other tutorial about Anaconda, so I will put the link in the description below and then select the newest Python version, so here I select Python 3.7 and Unfortunately on the Mac you can only install the CPU version right now But if you are on Linux or Windows and want to have GPU support, then you can also install or have to install the CUDA toolkit first. So the CUDA toolkit is a development environment for creating high performance GPU accelerated applications.
For this you need an NVIDIA GPU in your machine. And if you have that, then you can go to the website. developer.nvidia.com slash CUDA minus downloads.
And then we have to be careful because right now the newest supported CUDA version by pytorch is CUDA 10.1. So we have to get this version. So right now the newest version is 10.2.
So we have to go to legacy releases, then select the newest CUDA toolkit 10.1, then select your operating system. So for example, Windows Windows 10, then download the installer and follow the instructions. And this will also check if your system is suitable for the CUDA toolkit.
So if this is successful, then we can go back to the PyTorch site and copy this command. So in my case on the Mac, now I need this command. So let's copy this. And now let's open up a terminal. And first of all, we want to create a virtual environment with conda in which we want to install all of our packages and install pytorch.
So let's create a environment, let's say conda, create minus n and now give it a name. So I call this pi torch, simply pi torch, and then also specify the Python version. So let's say Python equals 3.7.
And then hit enter. Now this will create your virtual environment with Python 3.7. Let's hit enter again to proceed.
And this will take a while. And now it's done. So now we can activate this environment with conda activate pytorch.
And now we are inside of this environment. And we can see this because here in the beginning, we have pytorch in parentheses. So this is the name of the environment.
And now let's paste our installation command from the website. So this will install pytorch and all the necessary packages. So this will also take a couple of seconds. Now again, let's hit enter to proceed. And now it's done.
So now we have installed pytorch. And we can verify that by starting Python inside this environment. So let's say type Python and enter.
And now we have Python running and now we can import the torch module. So if the installation was not correct, and right now you would get a module not found error. But in this case, it is correct.
And now we can, for example, create a torch tensor. So let's say x equals torch, dot rand and of size three. And now we want to print our tensor.
So this also works. And And now we can also check if CUDA is available. So we can say tor torch dot CUDA dot is underscore available.
So in my case, it says false. But if you've installed the CUDA toolkit, and also the GPU supported pytorch packages, then this should say true. So yeah, so now we have installed in a pytorch.
and can get started working with it so I hope you enjoyed this and see you in the next tutorial. Bye!