 Welcome to my PyTorch video tutorial series. Today we are going to see how to install PyTorch on OSX in roughly 10 minutes. We will start with Xcode. We will see how to install it or update it, specifically to the version 8.3.2. Then we will see how to install the additional components. We will move on and install Homebrew on our system. And I will repeat the word system I think 15 times at least. So we will see how to install and update and upgrade all the packages. And then finally how to install Git on our system. Then we will install Anaconda or Miniconda. So we will start with the installation, the activation, which means modifying our system path and then sourcing our configuration file. And then we will install three essential Python packages, Matplotlib, iPython and Jupyter. Then we will add this homebrew channel to our environment. Finally we will install Torch and TorchVision through Konda. In order to be able to accelerate computations on the graphic processing unit, we are going to see how to set up your machine to be CUDA ready. So the CUDA chapter contains the following. We will see how to update or install the drivers on our machine. Then how we are going to install the toolkit. And finally we will download and install the CUDNN library. Finally we will install by Torch from source. So we will have to install first the dependencies. Downgrade the C-lang from the version 8.1.0 to the version 8.0.0 because it's otherwise not compatible with the current version of the CUDA for OX10. Then we will just have to set up CMake to know about where Anaconda is installed. And then finally we will be able to install PyTorch from source code and then validate its successful installation. Let's start by installing or updating our Xcode. Let's check the progress of the installation. Here we can see it's still downloading. And here we go, it's installed. Let's check the version. Yes, we'd like to install additional required components. And there we go. Xcode has been installed and the current version is the 8.3.2. As the second step, we are going to install Homebrew on our system. So we can type this command and press enter. Homebrew will be installed on the system. Since it's already available on my system, I will skip this point. We can type brew-update. Once more, brew-update. And then brew-upgrade. Then we need to install Git. So we are going to do brew-install-kit. And we can see that it's already available on my system. Now we'd like to install Anaconda on our system. So we can type brew-cask-search-conda. And we will see that there are two available packages. One is called Anaconda and the other one is called Miniconda. On my system, I would like to install Miniconda, which is a smaller Anaconda. So, brew-cask-install-miniconda. We see that Miniconda is going to be installed in my home directory slash miniconda3. And therefore, we will have to add to our path the directory home slash miniconda3 slash bin. I'm going to copy this line. And then I'm going to edit my BESHO RC. So you will have to edit your profile or profile RC. So, at the end, I can add konda. And we paste the command. They told us. Let's save and quit. So now we can source our BESHO RC. And let's see if we have installed Python, for example. So we type Python. And we can see that we have Python 3.6.0 from Continuum Analytics Inc. If we check where it is installed, we can type which Python. And then we can see that it is installed in my home directory. So user headcode and miniconda3 slash bin slash Python. Now I will install other two packages, which I think they are essential for using Python on my computer. So I will type konda install matplotlibypython and Jupyter. Yes. And there we go. Finally, to install PyTorch and TorchVision, we can type konda config dash dash add channels submit. And then finally, we can type konda install pyTorch and TorchVision. We can answer yes. And that's pretty much it. Ipython, we just installed it, which is going to use the Python 3.6.0. We can now type import torch and we can see torch and torchVision are both available. We are going to be just going with the first one for the moment. And then let's call t, our tensor. For example, we can have it torch.rand of five values. Don't worry if you don't understand what I'm typing so far. It's just to show you that the system is actually up and running. So if we just print the result of t, we have a random tensor of dimension five, populated by numbers from zero included and one excluded. Let's try to go further since this Macware have just installed PyTorch. It has also NVIDIA GPO. I would like perhaps to accelerate computation on the graphic processing unit. So let's see if I can send this tensor to the GPO. So let's call my tensor r and let's have it equal to t, but send to my GPO. If I just type enter, we are going to see that there is an error. PyTorch is telling us that torch has not been compiled with CUDA enable. To install PyTorch with the CUDA enable, we will have to install PyTorch from source code. So let's quit for the moment. I Python and update the drivers of our system. So we can go on system preferences, click on CUDA, and then install CUDA update. And we are done. We can click on close. And we can see now that the current version is the 8.0.81. And let's go now back to the terminal. Let's open a new window here in T-Max. And let's install first of all CUDA. And that was pretty quick. So let's also install now the CUDN library. To do so, we are going to go on our browser. We can type CUDN download. We agree. And then we select the correct version. So download CUDN version 6.0 for CUDA 8. And we choose our CUDN version 6.0 library for OSX. You can click here. So let's move into download and CUDA. So here we are going to see two folders include and lib. Go inside include. We have a sudnn.h. So let's do sudo move sudnn into slash user local CUDA include. And then let's go one level up and inside lib. And here we have the actual library. So we can do again sudo move all these three guys into user local CUDA and lib. And we have installed CUDN. So now we can clone our PyTorch. So let's go in our environment. Let's go on the website of PyTorch. PyTorch.org. You can click on fork me on github. Clone and download copy. So we go git clone our repository. That is named PyTorch. We can cd into PyTorch. Let's follow here. There are some instructions down there down the page. So we had to install some additional packages. And here on OSX. So we can do conda install these guys first. And yes. So let's say we have the most updated version of Xcode. So if we type clang-version we should see something like Apple LLVM version 810. And the unfortunate news is that the current CUDA version we have just installed is not compatible with this version of the command line tools. So we are going to go on the downloads for the Apple developers. We are going to look for the command line tools macOS 10.12 for Xcode 8.2. We can download it and install it. Okay, I agree. Install. And there we go. So yeah, move to trash, thank you. So we are back to our terminal. And now we can type. So the Xcode select switch library developer command line tools. And now if we type clang-version we see that we have installed instead now the Apple LLVM version 8.0.0. Let's export now DC make prefix path. Which is basically the location of our mini conda. So we are going to paste this one and then type. Finally, we can copy this last instruction. Which will be installing our pytorch from source. And it finished right now. So let's verify that the installation actually worked. So let's type a python. And then let's import torch. So import torch. Let's call T our tensor. And it's equal torch dot rend of five values. And this is the output of T. So let's call now R our CUDA tensor. And we can type T dot CUDA. And let's see, done. So if we print out R we can see it's a CUDA float tensor of size five. Yay.