Deep Learning Frameworks

From Grid5000
Jump to navigation Jump to search

This page describes installation steps of common Deep Learning frameworks.

pip will be used to install the frameworks (conda could be used much the same way). Installation is performed under your home directory.

Reserve some GPU nodes with OAR

  • Reserve a node with some GPUs (see the Hardware page for the list of sites and clusters with GPUs).

For instance, to reserve one GPU using OAR:

$ oarsub -I -l gpu=1

(remember to add '-q production' option if you want to reserve a GPU from Nancy "production" resources)


To reserve the full node:

$ oarsub -I -l host=1

To reserve a gpu or a full node on a specific cluster, add to the oarsub command:

-p cluster=<clustername>
  • Once connected to the node, check GPU presence and the available CUDA version:
$ nvidia-smi 
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 418.67       Driver Version: 418.67       CUDA Version: 10.1     |
(...)

PyTorch

For instance (as of May 2020), selecting “Stable”, “Linux”, “Pip”, “Python”, “Cuda 10.1” gives this command to execute:

$ pip3 install torch==1.5.0+cu101 torchvision==0.6.0+cu101 -f https://download.pytorch.org/whl/torch_stable.html
  • Check if PyTorch is correctly installed to works with GPU:
$ python3 -c "import torch; print(torch.cuda.is_available())"

Tensorflow (with Keras)

  • Go on Tensorflow website to see the installation commands. As of May 2020 (tensorflow v2.2.0), it is:
$ pip3 install --upgrade pip
$ pip3 install tensorflow
  • To use GPUs, TensorFlow requires CudNN library. We provide it as a module to load:
$ module load cudnn
  • Now check if TensorFlow is correctly installed to works with GPU:
$ python3 -c "import tensorflow as tf; print('Num GPUs Available:', len(tf.config.experimental.list_physical_devices('GPU')))"

Note: This install TensorFlow v2. If you need TensorFlow v1, see https://www.tensorflow.org/guide/migrate

MXNet

  • Go on MXNet website to see the installation command that suits you.

For instance (as of May 2020), selecting “Linux”, “Python”, “GPU” and “Pip”, the command to execute (in order to use Cuda 10.1) is:

$ pip3 install mxnet-cu101
  • Check if PyTorch is correctly installed to works with GPU:
$ python3 -c "import mxnet; print('Num GPUs Available:', mxnet.context.num_gpus())"

Additional resources

  • An in-depth tutorial contributed by a Grid'5000 user, Ismael Bada
  • Many Docker images exist with ready-to-use Deep Learning software stack. They can be executed using Docker or Singularity tools (using appropriate options to enable GPU usage). See wiki pages to learn how to use these tools in Grid'5000.
  • If you want to use virtualenv to manage your Python packages, it is available in Grid'5000 standard environments. Create your environment with python3 -m venv <env_directory> and activate it using source <env_directory>/bin/activate before using pip and installed packages.
  • If you prefer to use conda to manage your Python packages, it is available in Grid'5000 as a module. Just execute "module load miniconda3" from a node or a frontend to make it available.