[{"data":1,"prerenderedAt":144},["ShallowReactive",2],{"content-query-xdzDtLXHnq":3},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"date":10,"cover":11,"type":12,"category":13,"body":14,"_type":138,"_id":139,"_source":140,"_file":141,"_stem":142,"_extension":143},"/technology-blogs/zh/1824","zh",false,"","【MindSpore易点通】在开发环境中如何使用MindInsight在线调试器","在线调试器在开发环境上相对离线调试器有着更高的要求，现仅支持单机单卡。","2022-09-15","https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2022/09/26/9dd3596861444a79a2afd71603b40abd.png","technology-blogs","基础知识",{"type":15,"children":16,"toc":135},"root",[17,25,31,36,41,46,56,61,66,71,81,86,95,100,108,113,122,127],{"type":18,"tag":19,"props":20,"children":22},"element","h1",{"id":21},"mindspore易点通在开发环境中如何使用mindinsight在线调试器",[23],{"type":24,"value":8},"text",{"type":18,"tag":26,"props":27,"children":28},"p",{},[29],{"type":24,"value":30},"背景信息",{"type":18,"tag":26,"props":32,"children":33},{},[34],{"type":24,"value":35},"在使用开发环境训练任务过程中，为方便开发人员更形象地观察到实时训练任务中的数值变化情况以分析精度问题，ModelArts在线调节器应运而生。与离线调试器的区别在于，离线调试器只能待整个任务运行完成后（收集到整个任务过程的dump数据后）方可查看相应数值。",{"type":18,"tag":26,"props":37,"children":38},{},[39],{"type":24,"value":40},"在线调试器在开发环境上相对离线调试器有着更高的要求，现仅支持单机单卡。（离线调试器支持单机多卡）",{"type":18,"tag":26,"props":42,"children":43},{},[44],{"type":24,"value":45},"1、创建开发环境并在线打开 在ModelArts控制台，进入“开发环境管理 > DevContainer”页面，创建开发环境实例，创建成功后，单击开发环境实例操作栏右侧的“打开 > 打开Notebook”，在线打开运行中的开发环境。 打开方式如下图所示： 2、启动MindInsight在线调试器 在创建开发环境并在线打开后，点击如下图所示的按钮，创建.ipynb文件。 在对话框中输入Mindinsight相应命令启动Mindinsight后，即可展示界面。",{"type":18,"tag":47,"props":48,"children":50},"pre",{"code":49},"%reload_ext mindinsight\n%mindinsight --port {PORT} --enable-debugger 1 --debugger-port 5412\n",[51],{"type":18,"tag":52,"props":53,"children":54},"code",{"__ignoreMap":7},[55],{"type":24,"value":49},{"type":18,"tag":26,"props":57,"children":58},{},[59],{"type":24,"value":60},"参数解释：",{"type":18,"tag":26,"props":62,"children":63},{},[64],{"type":24,"value":65},"--port {PORT}：指定Web可视化服务端口。可以不设置，默认使用8080端口。如果8080端口被占用了，需要在1~65535任意指定一个端口。 --enable-debugger:MindInsight调试器功能开启选项，若取值为True或1, 则开启MindInsight侧调试器；默认为False，不开启。 --debugger-port： 表示指定的调试服务端口，取值需要和训练脚本中设置的调试服务端口值保持一致。 数据在开发环境中的存储路径",{"type":18,"tag":26,"props":67,"children":68},{},[69],{"type":24,"value":70},"2.1、启动调试器",{"type":18,"tag":26,"props":72,"children":73},{},[74,76],{"type":24,"value":75},"启动MindInsight后点击页面中的调试器（Debugger）按钮等待训练接入... ",{"type":18,"tag":77,"props":78,"children":80},"img",{"alt":7,"src":79},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2022/09/26/06130870926f44d2a7a9f7acf8cd3535.png",[],{"type":18,"tag":26,"props":82,"children":83},{},[84],{"type":24,"value":85},"2.2 启动训练任务",{"type":18,"tag":26,"props":87,"children":88},{},[89,91],{"type":24,"value":90},"调试器开启后，在开发环境中将训练指定为调试模式，即对开发环境的环境变量进行设置或提前在脚本里写入，在本地IDE中具体操作如下所示： ",{"type":18,"tag":77,"props":92,"children":94},{"alt":7,"src":93},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2022/09/26/8b55cf71e97d47ca9d7d0a2ac0e277da.png",[],{"type":18,"tag":26,"props":96,"children":97},{},[98],{"type":24,"value":99},"或直接在脚本写入对环境变量的设置：",{"type":18,"tag":47,"props":101,"children":103},{"code":102},"import os\nos.environ[\"ENABLE_MS_DEBUGGER\"]=\"True\"\nos.environ[\"MS_DEBUGGER_HOST\"]=\"xxx.xxx.xxx..xxx\" #可选，云上开发环境中可以不设置此参数变量。\nos.environ[\"MS_DEBUGGER_PORT\"]=\"5413\" #这里的端口号5412需与MindInsight debugger-port一致。\n",[104],{"type":18,"tag":52,"props":105,"children":106},{"__ignoreMap":7},[107],{"type":24,"value":102},{"type":18,"tag":26,"props":109,"children":110},{},[111],{"type":24,"value":112},"3、 开始调试精度",{"type":18,"tag":26,"props":114,"children":115},{},[116,118],{"type":24,"value":117},"通过以上操作将开发环境训练过程与MindInsight链接后界面如以下所示： ",{"type":18,"tag":77,"props":119,"children":121},{"alt":7,"src":120},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2022/09/26/2b94221f979e40f7a439add8718fefa5.png",[],{"type":18,"tag":26,"props":123,"children":124},{},[125],{"type":24,"value":126},"4、调试完成后关闭MindInsight 在.ipynb文件框中输入命令，关闭 MindInsight。端口号应与启动MindInsight中设置一致。",{"type":18,"tag":47,"props":128,"children":130},{"code":129},"!mindinsight stop --port {port}\n",[131],{"type":18,"tag":52,"props":132,"children":133},{"__ignoreMap":7},[134],{"type":24,"value":129},{"title":7,"searchDepth":136,"depth":136,"links":137},4,[],"markdown","content:technology-blogs:zh:1824.md","content","technology-blogs/zh/1824.md","technology-blogs/zh/1824","md",1776506115908]