---
title: 设置NPU为默认设备
description: "在入口文件official/vision/image_classification/resnet/resnet_ctl_imagenet_main.py的开头添加如下代码，添加完成后该迁移点即完成。"
url: https://www.hiascend.com/document/detail/zh/TensorFlowCommercial/latest/migration/tfmigr2/tfmigr2_000092.html
sourcePath: /source/zh/TensorFlowCommercial/900/migration/tfmigr2/tfmigr2_000092.html
indexId: 41e1814a64d904765f7c9f82c075c86186bfd01074f14e257b348a8de0b1442e73
---
# 设置NPU为默认设备

在入口文件official/vision/image_classification/resnet/resnet_ctl_imagenet_main.py的开头添加如下代码，添加完成后该迁移点即完成。

```
import npu_device as npu
npu.open().as_default()
```
