PyTorch will run on macOS X, 64 bit Linux, and 64 bit Windows. Be aware that Windows does not currently offer (easy) support for the use of GPUs in PyTorch. You will need to have either Python 2.7 or Python 3.5 / 3.6 installed on your computer before you install PyTorch, remembering to install the correct version for each Python version. Unless you have a reason not to, it is recommended that you install the Anaconda distribution of Python. This this is available from: https://anaconda.org/anaconda/python.
Anaconda includes all the dependencies of PyTorch, as well as technical, math, and scientific libraries essential to your work in deep learning. These will be used throughout the book, so unless you want to install them all separately, install Anaconda.
The following is a list of the packages and tools that we will be using in this book. They are all installed with Anaconda:
- NumPy: A math library primarily used for working with multidimensional arrays
- Matplotlib: A plotting and visualization library
- SciPy: A package for scientific and technical computing
- Skit-Learn: A library for machine learning
- Pandas: A library for working with data
- IPython: A notebook-style code editor used for writing and running code in a browser
Once you have Anaconda installed, you can now install PyTorch. Go to the PyTorch website at https://pytorch.org/.
The installation matrix on this website is pretty self-explanatory. Simply select your operating system, Python version, and, if you have GPUs, your CUDA version, and then run the appropriate command.
As always, it is good practice to ensure your operating system and dependent packages are up to date before installing PyTorch. Anaconda and PyTorch run on Windows, Linux, and macOS, although Linux is probably the most used and consistent operating system. Throughout this book, I will be using Python 3.7 and Anaconda 3.6.5 running on Linux
Code in this book was written on the Jupyter Notebook and these notebooks are available from the book's website.
You can either choose to set up your PyTorch environment locally on your own machine or remotely on a cloud server. They each have their pros and cons. Working locally has the advantage that it is generally easier and quicker to get started. This is especially true if you are not familiar with SSH and the Linux terminal. It is simply a matter of installing Anaconda and PyTorch, and you are on your way. Also, you get to choose and control your own hardware, and while this is an upfront cost, it is often cheaper in the long run. Once you start expanding hardware requirements, cloud solutions can become expensive. Another advantage of working locally is that you can choose and customize your integrated development envionment (IDE). In fact, Anaconda has its own excellent desktop IDE called Spyder.
There are a few things you need to keep in mind when building your own deep learning hardware and you require GPU acceleration:
- Use NVIDIA CUDA-compliant GPUs (for example, GTX 1060 or GTX 1080)
- A chipset that has at least 16 PCIe lanes
- At least 16 GB of RAM
Working on the cloud does offer the flexibility to work from any machine as well as more easily experiment with different operating systems, platforms, and hardware. You also have the benefit of being able to share and collaborate more easily. It is generally cheap to get started, costing a few dollars a month, or even free, but as your projects become more complex and data intensive, you will need to pay for more capacity.
Let's look briefly at the installation procedures for two cloud server hosts: Digital Ocean and Amazon Web Services.