Mixed-precision training for ResNet50 v1.5 modified from DeepLearningExamples.
In this example, we use ActNN by manually constructing the model with the memory-saving layers.
Our training logs are available at Weights & Biases.
- Put the ImageNet dataset to
~/imagenet
- Install required packages
pip install matplotlib tqdm
- Install apex
git clone https://github.com/NVIDIA/apex
cd apex
pip install -v --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./
mkdir -p results/tmp
python3 main.py --dataset cifar10 --arch preact_resnet56 --epochs 200 --num-classes 10 \
-j 0 --weight-decay 1e-4 --batch-size 128 --label-smoothing 0 \
--lr 0.1 --momentum 0.9 --warmup 4 \
-c quantize --ca=True --actnn-level L3 \
--workspace results/tmp --gather-checkpoints ~/data/cifar10
./dist-train 1 0 127.0.0.1 1 resnet50 \
"-c quantize --ca=True --actnn-level L3"\
tmp ~/imagenet 256
./dist-train 1 0 127.0.0.1 1 resnet50 \
"--amp --dynamic-loss-scale -c quantize --ca=True --actnn-level L3"\
tmp ~/imagenet 256
Download model checkpoints
wget https://ml.cs.tsinghua.edu.cn/~jianfei/static/results.tar.gz
tar xzvf results.tar.gz
mkdir results/tmp
python3 main.py --dataset cifar10 --arch preact_resnet56 --epochs 200 --num-classes 100 -j 0 --weight-decay 1e-4 --batch-size 128 --label-smoothing 0 \
-c quantize --ca=True --actnn-level L3 \
--workspace results/tmp --evaluate --training-only \
--resume results/cifar100/checkpoint-10.pth.tar --resume2 results/cifar100/checkpoint-10.pth.tar ~/data/cifar100
quantize config | Overall Bias | Overall Var |
---|---|---|
-c quantize --ca=True --actnn-level L3 | 0.03929 | 0.07694 |