Skip to content

Latest commit

 

History

History
40 lines (35 loc) · 1.58 KB

File metadata and controls

40 lines (35 loc) · 1.58 KB

Backbone

Example of backbone model training is based on pytorch vision, We also forked a version and added some features to get better performance in ROCm.

ResNet50

  1. prepare code and data
git clone https://github.com/amd-fuweiy/vision 

then, revise the DATAPATH in run_train.sh to according to your data path. You can also revise MODEL to other existing models.

  1. MIOpen tuning (optional) MIOpen is an AMD library for accelerating convolution kernels. Through tuning, we can get better performance with limited extra efforts. For more details please refer to MIOpen tuning guide.
export MIOPEN_FIND_MODE=1
export MIOPEN_FIND_ENFORCE=4
bash run_train.sh
  1. Train
unset MIOPEN_FIND_MODE
unset MIOPEN_FIND_ENFORCE
bash run_train.sh
  1. Train with NHWC layout (optional) Using NHWC layout sometimes can get better performance since it would save time for transpose tensors.
export PYTORCH_MIOPEN_SUGGEST_NHWC=1
export PYTORCH_MIOPEN_SUGGEST_NHWC_BATCHNORM=1

also need to change layout of input and model:

data = data.to(memory_format=torch.channels_last) # in train.py line 28
model = model.to(memory_format=torch.channels_last) # in train.py line 248
model = torch.compile(model) # to get better performance

In the example, we have enabled these features, you can directly run run_train.sh to use NHWC layout out-of-the-box.