diff --git a/PyTorch/built-in/cv/classification/Densenet121_for_PyTorch/densenet121_1p_main.py b/PyTorch/built-in/cv/classification/Densenet121_for_PyTorch/densenet121_1p_main.py index c4a606d6a91633eb8cb57e8a9d9f717ac9bd4c28..e9a5438e98cc3e3bac2872065fa28046a20fabc5 100644 --- a/PyTorch/built-in/cv/classification/Densenet121_for_PyTorch/densenet121_1p_main.py +++ b/PyTorch/built-in/cv/classification/Densenet121_for_PyTorch/densenet121_1p_main.py @@ -143,6 +143,7 @@ def main(): if args.seed is not None: + seed = args.seed random.seed(seed) os.environ['PYTHONHASHSEED'] = str(seed) np.random.seed(seed) @@ -250,7 +251,8 @@ def main_worker(gpu, ngpus_per_node, args): weight_decay=args.weight_decay) if args.amp: - model, optimizer = amp.initialize(model, optimizer, opt_level=args.opt_level, loss_scale=args.loss_scale, combine_grad=True) + model, optimizer = amp.initialize(model, optimizer, opt_level=args.opt_level, + loss_scale=args.loss_scale, combine_grad=True) # optionally resume from a checkpoint if args.resume: @@ -260,6 +262,7 @@ def main_worker(gpu, ngpus_per_node, args): args.start_epoch = checkpoint['epoch'] best_acc1 = checkpoint['best_acc1'] model.load_state_dict(checkpoint['state_dict']) + model = nn.DataParallel(model) optimizer.load_state_dict(checkpoint['optimizer']) if args.amp: amp.load_state_dict(checkpoint['amp']) diff --git a/PyTorch/built-in/cv/classification/Densenet121_for_PyTorch/densenet121_8p_main.py b/PyTorch/built-in/cv/classification/Densenet121_for_PyTorch/densenet121_8p_main.py index f2b148daa42c7e17c176bb4507e67116bbfe1fab..46b32dd9b881c381581afa6ff07b2009cb195934 100644 --- a/PyTorch/built-in/cv/classification/Densenet121_for_PyTorch/densenet121_8p_main.py +++ b/PyTorch/built-in/cv/classification/Densenet121_for_PyTorch/densenet121_8p_main.py @@ -153,6 +153,7 @@ def main(): print("===============main()=================") if args.seed is not None: + seed = args.seed random.seed(args.seed) torch.manual_seed(args.seed) cudnn.deterministic = True @@ -288,8 +289,10 @@ def main_worker(gpu, ngpus_per_node, args): weight_decay=args.weight_decay) if args.amp: - model, optimizer = amp.initialize(model, optimizer, opt_level=args.opt_level, loss_scale=args.loss_scale, combine_grad=True) - model = torch.nn.parallel.DistributedDataParallel(model, device_ids=[args.gpu], broadcast_buffers=False) + model, optimizer = amp.initialize(model, optimizer, opt_level=args.opt_level, + loss_scale=args.loss_scale, combine_grad=True) + model = torch.nn.parallel.DistributedDataParallel(model, device_ids=[args.gpu], + broadcast_buffers=False) # optionally resume from a checkpoint if args.resume: @@ -299,6 +302,7 @@ def main_worker(gpu, ngpus_per_node, args): args.start_epoch = checkpoint['epoch'] best_acc1 = checkpoint['best_acc1'] model.load_state_dict(checkpoint['state_dict']) + model = nn.DataParallel(model) optimizer.load_state_dict(checkpoint['optimizer']) if args.amp: amp.load_state_dict(checkpoint['amp']) @@ -330,7 +334,8 @@ def main_worker(gpu, ngpus_per_node, args): best_acc1 = max(acc1, best_acc1) if not args.multiprocessing_distributed or (args.multiprocessing_distributed - and args.rank % ngpus_per_node == 0 and epoch == args.epochs - 1): + and args.rank % ngpus_per_node == 0 + and epoch == args.epochs - 1): if args.amp: save_checkpoint({ 'epoch': epoch + 1, diff --git a/PyTorch/built-in/cv/classification/Densenet121_for_PyTorch/docker_start.sh b/PyTorch/built-in/cv/classification/Densenet121_for_PyTorch/docker_start.sh index 944bca3cdac8e3f2d47ceb0e2b6eb181a405de11..cf8052518d25e80d6df572348dc18c47e1fced7b 100644 --- a/PyTorch/built-in/cv/classification/Densenet121_for_PyTorch/docker_start.sh +++ b/PyTorch/built-in/cv/classification/Densenet121_for_PyTorch/docker_start.sh @@ -4,7 +4,7 @@ docker_image=$1 data_dir=$2 model_dir=$3 -docker run -it --ipc=host \ +docker run -it -u root --ipc=host \ --device=/dev/davinci0 \ --device=/dev/davinci1 \ --device=/dev/davinci2 \ @@ -22,4 +22,4 @@ docker run -it --ipc=host \ -v /var/log/npu/conf/slog/slog.conf:/var/log/npu/conf/slog/slog.conf \ -v /var/log/npu/slog/:/var/log/npu/slog -v /var/log/npu/profiling/:/var/log/npu/profiling \ -v /var/log/npu/dump/:/var/log/npu/dump -v /var/log/npu/:/usr/slog ${docker_image} \ - /bin/bash \ No newline at end of file + /bin/bash diff --git a/PyTorch/built-in/cv/classification/Densenet121_for_PyTorch/sdk_infer/docker_start_infer.sh b/PyTorch/built-in/cv/classification/Densenet121_for_PyTorch/sdk_infer/docker_start_infer.sh index 072b0819ae7edbe63d62c98a039c43469157f792..deac57c423852de8cb899170a1f539fa15f2a3dd 100644 --- a/PyTorch/built-in/cv/classification/Densenet121_for_PyTorch/sdk_infer/docker_start_infer.sh +++ b/PyTorch/built-in/cv/classification/Densenet121_for_PyTorch/sdk_infer/docker_start_infer.sh @@ -37,7 +37,7 @@ function param_check() { param_check -docker run -it \ +docker run -it -u root \ --device=/dev/davinci0 \ --device=/dev/davinci_manager \ --device=/dev/devmm_svm \ diff --git a/PyTorch/built-in/cv/classification/Densenet121_for_PyTorch/sdk_infer/sdk_run_infer/pipeline/densenet121_opencv.pipeline b/PyTorch/built-in/cv/classification/Densenet121_for_PyTorch/sdk_infer/sdk_run_infer/pipeline/densenet121_opencv.pipeline index 4357b974bca2d95b5b4a05cf470cdafd3b46c4a9..4027490b114a93c9f7230580b35485e5515dc231 100644 --- a/PyTorch/built-in/cv/classification/Densenet121_for_PyTorch/sdk_infer/sdk_run_infer/pipeline/densenet121_opencv.pipeline +++ b/PyTorch/built-in/cv/classification/Densenet121_for_PyTorch/sdk_infer/sdk_run_infer/pipeline/densenet121_opencv.pipeline @@ -38,7 +38,7 @@ "mxpi_tensorinfer0": { "props": { "dataSource": "mxpi_opencvcentercrop0", - "modelPath": "./models/densenet121/densenet121_304.om", + "modelPath": "./models/densenet121/densenet121_pytorch_1.3.om", "waitingTime": "2000", "outputDeviceId": "-1" }, @@ -50,7 +50,7 @@ "dataSource": "mxpi_tensorinfer0", "postProcessConfigPath": "./models/densenet121/densenet121_aipp.cfg", "labelPath": "./models/densenet121/imagenet1000_clsidx_to_labels.names", - "postProcessLibPath": "../../../lib/modelpostprocessors/libresnet50postprocess.so" + "postProcessLibPath": "../../../../lib/modelpostprocessors/libresnet50postprocess.so" }, "factory": "mxpi_classpostprocessor", "next": "mxpi_dataserialize0" diff --git a/PyTorch/built-in/cv/classification/Densenet121_for_PyTorch/sdk_infer/sdk_run_infer/run_densenet.sh b/PyTorch/built-in/cv/classification/Densenet121_for_PyTorch/sdk_infer/sdk_run_infer/run_densenet.sh index fe7de0829651e3b810bf1c617a19659ee2f6cdd9..7d04a39fa15c13e1d670558fc6be3cffaad1f5e2 100644 --- a/PyTorch/built-in/cv/classification/Densenet121_for_PyTorch/sdk_infer/sdk_run_infer/run_densenet.sh +++ b/PyTorch/built-in/cv/classification/Densenet121_for_PyTorch/sdk_infer/sdk_run_infer/run_densenet.sh @@ -22,12 +22,5 @@ CUR_PATH=$(cd "$(dirname "$0")" || { warn "Failed to check path/to/run.sh" ; exi info() { echo -e "\033[1;34m[INFO ][MxStream] $1\033[1;37m" ; } warn() { echo >&2 -e "\033[1;31m[WARN ][MxStream] $1\033[1;37m" ; } -export LD_LIBRARY_PATH=${MX_SDK_HOME}/lib:${MX_SDK_HOME}/opensource/lib:${MX_SDK_HOME}/opensource/lib64:/usr/local/Ascend/ascend-toolkit/latest/acllib/lib64:${LD_LIBRARY_PATH} -export GST_PLUGIN_SCANNER=${MX_SDK_HOME}/opensource/libexec/gstreamer-1.0/gst-plugin-scanner -export GST_PLUGIN_PATH=${MX_SDK_HOME}/opensource/lib/gstreamer-1.0:${MX_SDK_HOME}/lib/plugins - -#to set PYTHONPATH, import the StreamManagerApi.py -export PYTHONPATH=$PYTHONPATH:${MX_SDK_HOME}/python - -python3.7 main_densenet_opencv.py +python3 main_densenet_opencv.py exit 0 diff --git a/PyTorch/built-in/cv/classification/Densenet121_for_PyTorch/test/train_full_1p.sh b/PyTorch/built-in/cv/classification/Densenet121_for_PyTorch/test/train_full_1p.sh index 80dcfbf8c367277369e6e12fd8d8326c59965e1b..39e1cb45c4043d50633b14203b958fcc7dfbca4b 100644 --- a/PyTorch/built-in/cv/classification/Densenet121_for_PyTorch/test/train_full_1p.sh +++ b/PyTorch/built-in/cv/classification/Densenet121_for_PyTorch/test/train_full_1p.sh @@ -175,4 +175,4 @@ echo "ActualFPS = ${ActualFPS}" >> ${test_path_dir}/output/$ASCEND_DEVICE_ID/${C echo "TrainingTime = ${TrainingTime}" >> ${test_path_dir}/output/$ASCEND_DEVICE_ID/${CaseName}.log echo "ActualLoss = ${ActualLoss}" >> ${test_path_dir}/output/$ASCEND_DEVICE_ID/${CaseName}.log echo "E2ETrainingTime = ${e2e_time}" >> ${test_path_dir}/output/$ASCEND_DEVICE_ID/${CaseName}.log -echo "TrainAccuracy = ${train_accuracy}" >> ${test_path_dir}/output/$ASCEND_DEVICE_ID/${CaseName}.log \ No newline at end of file +echo "TrainAccuracy = ${train_accuracy}" >> ${test_path_dir}/output/$ASCEND_DEVICE_ID/${CaseName}.log diff --git a/PyTorch/built-in/cv/classification/Densenet121_for_PyTorch/test/train_full_8p.sh b/PyTorch/built-in/cv/classification/Densenet121_for_PyTorch/test/train_full_8p.sh index 4c8482b67c8482f936551b35b8c1b09da2be2b97..1b00b4168e60496351962e7e488a3626ca3c69aa 100644 --- a/PyTorch/built-in/cv/classification/Densenet121_for_PyTorch/test/train_full_8p.sh +++ b/PyTorch/built-in/cv/classification/Densenet121_for_PyTorch/test/train_full_8p.sh @@ -133,7 +133,7 @@ then --device-list '0,1,2,3,4,5,6,7' \ --amp \ --benchmark 0 \ - --data $data_path > ${test_path_dir}/output/$ASCEND_DEVICE_ID/train_$ASCEND_DEVICE_ID.log 2>&1 & + --data $data_path > ${test_path_dir}/output/$ASCEND_DEVICE_ID/train_$ASCEND_DEVICE_ID.log 2>&1 & done else for i in $(seq 0 7) @@ -213,4 +213,4 @@ echo "ActualFPS = ${ActualFPS}" >> ${test_path_dir}/output/$ASCEND_DEVICE_ID/${C echo "TrainingTime = ${TrainingTime}" >> ${test_path_dir}/output/$ASCEND_DEVICE_ID/${CaseName}.log echo "ActualLoss = ${ActualLoss}" >> ${test_path_dir}/output/$ASCEND_DEVICE_ID/${CaseName}.log echo "TrainAccuracy = ${train_accuracy}" >> ${test_path_dir}/output/$ASCEND_DEVICE_ID/${CaseName}.log -echo "E2ETrainingTime = ${e2e_time}" >> ${test_path_dir}/output/$ASCEND_DEVICE_ID/${CaseName}.log \ No newline at end of file +echo "E2ETrainingTime = ${e2e_time}" >> ${test_path_dir}/output/$ASCEND_DEVICE_ID/${CaseName}.log diff --git a/PyTorch/built-in/cv/classification/Densenet121_for_PyTorch/test/train_performance_1p.sh b/PyTorch/built-in/cv/classification/Densenet121_for_PyTorch/test/train_performance_1p.sh index 48c18be1d4927f29d56aa019aa18e8535431fe2c..d57dbe2a7334f83cebdad775d1853771f944daa2 100644 --- a/PyTorch/built-in/cv/classification/Densenet121_for_PyTorch/test/train_performance_1p.sh +++ b/PyTorch/built-in/cv/classification/Densenet121_for_PyTorch/test/train_performance_1p.sh @@ -176,4 +176,4 @@ echo "CaseName = ${CaseName}" >> ${test_path_dir}/output/$ASCEND_DEVICE_ID/${Cas echo "ActualFPS = ${ActualFPS}" >> ${test_path_dir}/output/$ASCEND_DEVICE_ID/${CaseName}.log echo "TrainingTime = ${TrainingTime}" >> ${test_path_dir}/output/$ASCEND_DEVICE_ID/${CaseName}.log echo "ActualLoss = ${ActualLoss}" >> ${test_path_dir}/output/$ASCEND_DEVICE_ID/${CaseName}.log -echo "E2ETrainingTime = ${e2e_time}" >> ${test_path_dir}/output/$ASCEND_DEVICE_ID/${CaseName}.log \ No newline at end of file +echo "E2ETrainingTime = ${e2e_time}" >> ${test_path_dir}/output/$ASCEND_DEVICE_ID/${CaseName}.log diff --git a/PyTorch/built-in/cv/classification/Densenet121_for_PyTorch/test/train_performance_8p.sh b/PyTorch/built-in/cv/classification/Densenet121_for_PyTorch/test/train_performance_8p.sh index 0175d3c3e47253f5c5a152b4164108521b25bd31..2f9653a51feb6e8c188ed1650a8e148477fce551 100644 --- a/PyTorch/built-in/cv/classification/Densenet121_for_PyTorch/test/train_performance_8p.sh +++ b/PyTorch/built-in/cv/classification/Densenet121_for_PyTorch/test/train_performance_8p.sh @@ -219,4 +219,4 @@ echo "CaseName = ${CaseName}" >> ${test_path_dir}/output/$ASCEND_DEVICE_ID/${Cas echo "ActualFPS = ${ActualFPS}" >> ${test_path_dir}/output/$ASCEND_DEVICE_ID/${CaseName}.log echo "TrainingTime = ${TrainingTime}" >> ${test_path_dir}/output/$ASCEND_DEVICE_ID/${CaseName}.log echo "ActualLoss = ${ActualLoss}" >> ${test_path_dir}/output/$ASCEND_DEVICE_ID/${CaseName}.log -echo "E2ETrainingTime = ${e2e_time}" >> ${test_path_dir}/output/$ASCEND_DEVICE_ID/${CaseName}.log \ No newline at end of file +echo "E2ETrainingTime = ${e2e_time}" >> ${test_path_dir}/output/$ASCEND_DEVICE_ID/${CaseName}.log