4 Steps to install Anaconda and PyTorch on Windows 10
Hi guys:) Today, I would like to share how to install Anaconda and PyTorch (with/without GPU) in Windows 10 such that you can run different deep learning-based applications. Let’s start!
1. Install Anaconda
The first step is to install Anaconda such that you can create different environments for different applications. Note the different applications may require different libraries. For example, some may require OpenCV 3 and some require OpenCV 4. So, it is better to create different environments for different applications.
Please click [here] to go to the official website of Anaconda. Then click “Download” as shown below.
Select the installer based on your OS. Assume that your OS is Windows 10 64-Bit. Figure 2 is an example of selecting the installer.
Start to download the EXE of the installer and then follow the instructions to install Anaconda to your OS. Detailed instructions with screen captures are available at [here].
2. Install CUDA Toolkit (if you have GPU(s))
If you have GPU(s) on your computer and you want to use GPU(s) to speed up your applications, you have to install CUDA Toolkit. Please download CUDA Toolkit [here].
Select your Operating System, Architecture, Version, and Installer Type as shown below.
Click the “Download” button as shown in Figure 3 above and then install the CUDA Toolkit. The newest version of CUDA Toolkit is 11.1 at the time of writing this installation guide. Note that you have to check which GPU you are using and which version of CUDA Toolkit is applicable.
3. Create Conda environment for PyTorch
If you have finished Step 1 and 2, you have successfully installed Anaconda and CUDA Toolkit to your OS.
Please open your Command Prompt by searching ‘cmd’ as shown below.
Then, type the following line to your cmd
conda create -n ailab python=3.7
By typing this line, you are creating a Conda environment called ‘ailab’
Figure 5 shows an example of typing the above line to the cmd.
You should see the following, please type ‘y’ to continue the creation. Note that you may need to wait for a few minutes.
After finishing the creation, type the following line to activate your conda environment ‘ailab’
conda activate ailab
You should see something like the below.
Now, you are inside your Conda environment ‘ailab’. You can install the necessary libraries for deep learning-based applications.
Type the following lines one-by-one (# represents the explanation for the code below),
# install PyTorch and Torchvision libraries with CUDA Toolkit version 11
conda install pytorch torchvision torchaudio cudatoolkit=11.0 -c pytorch
# install Pandas library for handling dataframe, csv data, etc.
pip install pandas
# install matplotlib library for plotting training and testing curves
pip install matplotlib
# install OpenCV library for image pre/post-processing
conda install -c conda-forge opencv
# install Pillow library for reading and writing images
conda install -c anaconda pillow
4. Verify your installation
Here, we are going to verify the installation.
To check the installation of PyTorch with/without GPU(s) available, type the following three lines:
python
import torch
torch.cuda.is_available()
If GPU(s) is/are available for the PyTorch platform, it returns True else False as shown below.
In the above case, we do not have a GPU, hence it returns False.
Congrats
Now, you can try to run different deep learning-based applications on your computer. You may try a simple direct use of a pre-trained AlexNet for Image Classification [here]. Hope you guys find this post useful:)
Thanks for reading my post. If you have any questions, please feel free to send me an email or leave comments here. I am happy to hear from you and any suggestions are welcome. Hope to see you next time! :)