TensorFlow
Different versions of TensorFlow are installed 2.0, 1.12, 1.10, 1.8 and 1.4.
As soon as version 2.1 will be available in Anaconda, it will replace the 2.0 version since it is a developer preview. |
Selecting a GPU
Since the use of TensorFlow and Keras reserve the memory of every GPU available, we must first select a free card at the top of the notebook. Otherwise, other students or staff members will not be able to work.
Let’s see which one are available with gpustat and select one by setting the following CUDA variables with %env :
Show GPUs status
!gpustat
Output of gpustat
gpu-8k Fri Feb 7 14:46:03 2020 440.33.01
[0] GeForce GTX 980 | 38 C, 0 % | 0 / 4042 MB |
[1] GeForce GTX 980 | 42 C, 0 % | 0 / 4043 MB |
[2] GeForce GTX 980 | 42 C, 0 % | 0 / 4043 MB |
[3] GeForce GTX 980 | 42 C, 0 % | 0 / 4043 MB |
Setting CUDA_VISIBLE_DEVICES variable
%env CUDA_DEVICE_ORDER=PCI_BUS_ID
%env CUDA_VISIBLE_DEVICES=2
!echo "CUDA_VISIBLE_DEVICES : $CUDA_VISIBLE_DEVICES"

Figure 1. Example notebook
You can go to https://www.tensorflow.org/tutorials/quickstart/beginner to try out the same code used in the screenshot.