Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install CUDA in Google Colab GPU's

It seems that Google Colab GPU's doesn't come with CUDA Toolkit, how can I install CUDA in Google Colab GPU's. I am getting this error in installing mxnet in Google Colab.

Installing collected packages: mxnet Successfully installed mxnet-1.2.0 

ERROR: Incomplete installation for leveraging GPUs for computations. Please make sure you have CUDA installed and run the following line in your terminal and try again:

pip uninstall -y mxnet && pip install mxnet-cu90==1.1.0 

Adjust 'cu90' depending on your CUDA version ('cu75' and 'cu80' are also available). You can also disable GPU usage altogether by invoking turicreate.config.set_num_gpus(0). An exception has occurred, use %tb to see the full traceback.

SystemExit: 1 
like image 470
namerbenz Avatar asked May 28 '18 06:05

namerbenz


People also ask

How do I check my colab CUDA version?

Google Colab has a large number of pre-installed libraries. Cuda is also pre-installed there. You can check this by simply opening a new notebook and type ! nvcc --version which would return the installed Cuda version.

How do I enable CUDA on my graphics card?

Enable CUDA optimization by going to the system menu, and select Edit > Preferences. Click on the Editing tab and then select the "Enable NVIDIA CUDA /ATI Stream technology to speed up video effect preview/render" check box within the GPU acceleration area. Click on the OK button to save your changes.


2 Answers

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.

GPU Settings Screenshot

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.cuda confirmation screenshot

After that to check if PyTorch is capable of using GPU, run the following code.

import torch torch.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 tf tf.test.gpu_device_name() # Standard output is '/device:GPU:0' 
like image 180
Ahwar Avatar answered Sep 23 '22 18:09

Ahwar


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.

Here is mine: enter image description here

like image 34
Anwarvic Avatar answered Sep 19 '22 18:09

Anwarvic