Neuron guide
누리온 지침서뉴론 지침서활용정보MyKSC 지침서
  • Neuron guidelines
  • SYSTEM
    • System Overview and Configuration
    • User Environment
    • User Programming Environment
    • Running Jobs Through Scheduler (SLURM)
    • User Support
  • Software
    • Gaussian16 on GPU
  • APPENDIX
    • Main Keywords for Job Scripts
    • Conda
    • Singularity Container
    • Lustre stripe
    • Neuron Jupyter
    • How to Use Keras-Based Multi-GPU
    • How to Install Conda-based Horovod
    • Parallelizing Deep Learning Frameworks with Horovod
    • Using AI with Multiple Nodes
  • External link
    • Nurion Guide (Kor)
    • Neuron Guide(Kor)
Powered by GitBook
On this page
  • A. Code modifications and job submission methods for using Multi-GPU
  • 1. Add the [from keras.utils import multi_gpu_model] module
  • 2. Declare the use of multi-GPU in the code
  • 3. Job submission script
  1. APPENDIX

How to Use Keras-Based Multi-GPU

Keras is an open-source neural network library written in Python. It is a high-level neural network API that can run on top of MXNet, Deeplearning4j, TensorFlow, Microsoft Cognitive Toolkit, or Theano. In the NEURON system, queues like cas_v100_2, cas_v100nv_4, cas_v100nv_8, and amd_a100nv_8 are equipped with 2, 4, or 8 GPUs per node, providing an environment where multiple GPUs can be used for neural network training even within a single node.

A. Code modifications and job submission methods for using Multi-GPU

1. Add the [from keras.utils import multi_gpu_model] module

import keras
from keras.datasets import cifar10
from keras.models import Sequential
from keras.layers import Dense, Dropout, Activation, Flatten
from keras.layers import Conv2D, MaxPooling2D
from keras.utils import multi_gpu_model
import os

2. Declare the use of multi-GPU in the code

# initiate RMSprop optimizer
 opt = keras.optimizers.rmsprop(lr=0.0001, decay=1e-6)
 # multi-gpu
 model = multi_gpu_model(model, gpus=2)
 # Let's train the model using RMSprop
 model.compile(loss='categorical_crossentropy', optimizer=opt, metrics=['accuracy'])

※ Set the number of GPUs to the desired amount. (For example, in a cas_v100nv_4 node, set gpus=4)

3. Job submission script

#!/bin/sh
 #SBATCH -J keras
 #SBATCH --time=24:00:00
 #SBATCH -o %x_%j.out
 #SBATCH -e %x_%j.err
 #SBATCH -p ivy_v100_2
 #SBATCH --comment tensorflow
 #SBATCH --gres=gpu:2
 #SBATCH -N 1
 
 module purge
 module load  gcc/8.3.0 cuda/10.0 cudampi/openmpi-3.1.0 conda/tensorflow_1.13
 
 srun python example.py

Last updated on November 11, 2024.

PreviousNeuron JupyterNextHow to Install Conda-based Horovod

Last updated 6 months ago