Paperspace is another interesting way to perform deep learning in the cloud. It might be the easiest way to train deep learning models in the cloud. To set up a cloud instance with Paperspace, you can log in to their console, provision a new machine, and connect to it from your web browser:
- Start by signing up for a Paperspace account, log in to the console, and go into the Virtual Machine section by selecting Core or Compute. Paperspace has an RStudio TensorFlow template with NVIDIA GPU libraries (CUDA 8.0 and cuDNN 6.0) already installed, along with the GPU version of TensorFlow and Keras for R. You will see this machine type when you select Public Templates, as shown in the following screenshot:
Figure 10.32: Paperspace portal
- You will be given a choice of three GPU instances and the choice of pay by the hour or monthly. Select the cheapest option (currently P4000 at $0.40 per hour) and the hourly pricing. Scroll down to the bottom of the page and press the Create button. After a few minutes, your machine will be provisioned and you will be able to access it through your browser. An example of an RStudio Paperspace instance is shown as follows:
Figure 10.33: Accessing the virtual machine's desktop from a web page and running RStudio for a Paperspace instance
By default, Keras is already installed, so you can go ahead and train deep learning models using Keras. However, we are also going to install MXNet on our instance:
- The first step is to open RStudio and install a few packages. Execute the following commands from RStudio:
install.packages("devtools")
install.packages(c("imager","DiagrammeR","influenceR","rgexf"))
- The next step is to access the Terminal (or shell) for the instance you just created. You can go back to the console page and do it from there. Alternatively, click on the circle target in the top right corner of the desktop (see the previous screenshot). This also gives you other options such as synchronizing copy-and-paste between your local computer and the VM.
- Once you have logged in to the Terminal for the instance, running the following commands will install MXNet:
sudo apt-get update
sudo dpkg --configure -a
sudo apt-get install -y build-essential git
export CUDA_HOME=/usr/local/cuda
git clone --recursive https://github.com/apache/incubator-mxnet
cd incubator-mxnet
make -j $(nproc) USE_OPENCV=1 USE_BLAS=blas USE_CUDA=1 USE_CUDA_PATH=/usr/local/cuda USE_CUDNN=1
sudo ldconfig /usr/local/cuda/lib64
sudo make rpkg
- You also need to add the following line to the end of the .profile file:
export CUDA_HOME=/usr/local/cuda
When you are done, restart the instance. You now have a machine that can train Keras and MXNet deep learning models in the cloud. For more details on using RStudio in Paperspace, see https://tensorflow.rstudio.com/tools/cloud_desktop_gpu.html.