How to install CUDA in Google Colab GPU's
Cuda is not showing on your notebook because you have not enabled GPU in Colab.
The Google Colab comes with both options GPU or without GPU.You can enable or disable GPU in runtime settings
Go to Menu > Runtime > Change runtime.
Change hardware acceleration to GPU.
To check if GPU is running or not, run the following command
!nvidia-smi
If the output is like the following image it means your GPU and cuda are working. You can see the CUDA version also.
After that to check if PyTorch is capable of using GPU, run the following code.
import torchtorch.cuda.is_available()# Output would be True if Pytorch is using GPU otherwise it would be False.
To check if TensorFlow is capable of using GPU, run the following code.
import tensorflow as tftf.test.gpu_device_name()# Standard output is '/device:GPU:0'
I pretty much believe that Google Colab has Cuda pre-installed... You can make sure by opening a new notebook and type !nvcc --version
which would return the installed Cuda version.
- Go here: https://developer.nvidia.com/cuda-downloads
- Select Linux -> x86_64 -> Ubuntu -> 16.04 -> deb (local)
- Copy link from the download button.
- Now you have to compose the sequence of commands. First one will be the call to wget that will download CUDA installer from the link you saved on step 3
- There will be installation instruction under "Base installer" section. Copy them as well, but remove
sudo
from all the lines. - Preface each line with commands with
!
, insert into a cell and run - For me the command sequence was the following:
!wget https://developer.nvidia.com/compute/cuda/9.2/Prod/local_installers/cuda-repo-ubuntu1604-9-2-local_9.2.88-1_amd64 -O cuda-repo-ubuntu1604-9-2-local_9.2.88-1_amd64.deb!dpkg -i cuda-repo-ubuntu1604-9-2-local_9.2.88-1_amd64.deb!apt-key add /var/cuda-repo-9-2-local/7fa2af80.pub!apt-get update!apt-get install cuda
- Now finally install mxnet. As cuda version I installed above is 9.2 I had to slighly change your command:
!pip install mxnet-cu92
Successfully installed graphviz-0.8.3 mxnet-cu92-1.2.0