gummybear
gummybear

Reputation: 21

Google Colab GPUs Tensorflow 1.x

Does anyone know how to utilize Google Colab/Colab Pro's GPUs for tensorflow versions 1.x? I tried downgrading my CUDA from 10.1 to 10.0 (which didn't work) as well as pip installing tensorflow gpu==1.14 (which is advised against, as may slow down performance)

Upvotes: 2

Views: 1900

Answers (2)

user11530462
user11530462

Reputation:

To perform that, first you have to uninstall current CUDA version from Google Colab as shown below

!apt-get --purge remove cuda nvidia* libnvidia-*
!dpkg -l | grep cuda- | awk '{print $2}' | xargs -n1 dpkg --purge
!apt-get remove cuda-*
!apt autoremove
!apt-get update

In second step, you can download CUDA 10.0 and install as shown below

!wget  --no-clobber https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-repo-ubuntu1804_10.0.130-1_amd64.deb
!dpkg -i cuda-repo-ubuntu1804_10.0.130-1_amd64.deb
!sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub
!apt-get update
!apt-get install cuda-10-0

While running, it prompted with *** cuda.list (Y/I/N/O/D/Z) [default=N] ?, then you have to provide Y(Y or I : install the package maintainer's version)

After Installation, if you can check CUDA version as shown below

!nvcc --version

Output:

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2018 NVIDIA Corporation
Built on Sat_Aug_25_21:08:01_CDT_2018
Cuda compilation tools, release 10.0, V10.0.130

Finally, you can install Tensorflow GPU using pip as shown below

!pip install tensorflow_gpu ==1.14

Upvotes: 2

afrendeiro
afrendeiro

Reputation: 2544

Google Colab supports various tensorflow versions using the %tensoflow magic: https://colab.research.google.com/notebooks/tensorflow_version.ipynb

%tensorflow_version 1.x
import tensorflow as tf
print(tf.__version__, tf.test.is_gpu_available())

Upvotes: 0

Related Questions