|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227 |
- {
- "cells": [
- {
- "cell_type": "code",
- "execution_count": 1,
- "id": "7d112f9b-84ba-420d-a52b-9eb7ba307068",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "Looking in indexes: http://pip.modelarts.private.com:8888/repository/pypi/simple\n",
- "Requirement already satisfied: openi-test==0.7.1 in /home/ma-user/anaconda3/envs/python-3.7.10/lib/python3.7/site-packages (0.7.1)\n",
- "Requirement already satisfied: requests in /home/ma-user/modelarts-dev/modelarts-sdk (from openi-test==0.7.1) (2.28.2)\n",
- "Requirement already satisfied: tqdm in /home/ma-user/modelarts-dev/modelarts-sdk (from openi-test==0.7.1) (4.64.0)\n",
- "Requirement already satisfied: charset-normalizer<4,>=2 in /home/ma-user/modelarts-dev/modelarts-sdk (from requests->openi-test==0.7.1) (3.3.2)\n",
- "Requirement already satisfied: urllib3<1.27,>=1.21.1 in /home/ma-user/anaconda3/envs/python-3.7.10/lib/python3.7/site-packages (from requests->openi-test==0.7.1) (1.26.12)\n",
- "Requirement already satisfied: idna<4,>=2.5 in /home/ma-user/modelarts-dev/modelarts-sdk (from requests->openi-test==0.7.1) (3.4)\n",
- "Requirement already satisfied: certifi>=2017.4.17 in /home/ma-user/anaconda3/envs/python-3.7.10/lib/python3.7/site-packages (from requests->openi-test==0.7.1) (2022.6.15)\n",
- "Note: you may need to restart the kernel to use updated packages.\n"
- ]
- }
- ],
- "source": [
- "pip install openi-test==0.7.1"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 2,
- "id": "02ad2e02-6533-4da0-98c3-c5f238d4d8f7",
- "metadata": {},
- "outputs": [],
- "source": [
- "#导入包\n",
- "from openi.context import prepare, upload_openi"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 3,
- "id": "69880626-9320-46cd-ad29-8e5f7be09f32",
- "metadata": {},
- "outputs": [
- {
- "name": "stderr",
- "output_type": "stream",
- "text": [
- "INFO:root:Using MoXing-v2.1.0.5d9c87c8-5d9c87c8\n",
- "INFO:root:Using OBS-Python-SDK-3.20.9.1\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "🎉 Successfully Download s3:///urchincache/attachment/d/d/ddabdf57-a65a-496c-bef0-19d82b9043cd/MNISTData.zip to /home/ma-user/work/dataset/MNISTData.zip\n",
- "🎉 Successfully Extracted /home/ma-user/work/dataset/MNISTData.zip\n",
- "🎉 Successfully Deleted /home/ma-user/work/dataset/MNISTData.zip\n",
- "🎉 Successfully Download s3:///urchincache/attachment/2/c/2c59be66-64ec-41ca-b311-f51a486eabf8/checkpoint_lenet-1_1875.zip to /home/ma-user/work/dataset/checkpoint_lenet-1_1875.zip\n",
- "🎉 Successfully Extracted /home/ma-user/work/dataset/checkpoint_lenet-1_1875.zip\n",
- "🎉 Successfully Deleted /home/ma-user/work/dataset/checkpoint_lenet-1_1875.zip\n",
- "🎉 Successfully Download s3:///urchincache/aimodels/0/c/0cf4367b-5234-4967-a41f-f548d3f69fcf/ to /home/ma-user/work/pretrainmodel/MNIST_Example_model_zjdt\n",
- "please set the output location to /home/ma-user/work/output\n"
- ]
- }
- ],
- "source": [
- "\n",
- "#初始化导入数据集和预训练模型到容器内\n",
- "openi_context = prepare()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 15,
- "id": "c586f98f-bead-4dc9-a22f-173a672d456b",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "/home/ma-user/work/dataset\n"
- ]
- },
- {
- "data": {
- "text/plain": [
- "['checkpoint_lenet-1_1875', 'MNISTData']"
- ]
- },
- "execution_count": 15,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "#获取数据集路径,预训练模型路径,输出路径\n",
- "dataset_path = openi_context.dataset_path\n",
- "print(dataset_path)\n",
- "\n",
- "import os\n",
- "os.listdir(dataset_path)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 16,
- "id": "7d6617f0-7b86-4b1b-a201-ecdc58db53a5",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "/home/ma-user/work/pretrainmodel\n"
- ]
- },
- {
- "data": {
- "text/plain": [
- "['MNIST_Example_model_zjdt']"
- ]
- },
- "execution_count": 16,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "pretrain_model_path = openi_context.pretrain_model_path\n",
- "print(pretrain_model_path)\n",
- "os.listdir(pretrain_model_path)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 17,
- "id": "6bc51211-5555-452e-9d83-adcfee1c4f79",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "/home/ma-user/work/output\n"
- ]
- },
- {
- "data": {
- "text/plain": [
- "[]"
- ]
- },
- "execution_count": 17,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "output_path = openi_context.output_path\n",
- "print(output_path)\n",
- "os.listdir(output_path)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 9,
- "id": "48b5da5d-a55f-4781-9056-b886d41779c7",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "upload /home/ma-user/work/output to openi\n"
- ]
- },
- {
- "data": {
- "text/plain": [
- "'/home/ma-user/work/output'"
- ]
- },
- "execution_count": 9,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "#回传结果到openi,训练任务才能回传,调试任务回传后也是不支持下载\n",
- "upload_openi()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "75e7ce04-594e-4e8f-8292-15241709eb5e",
- "metadata": {},
- "outputs": [],
- "source": []
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "python-3.7.10",
- "language": "python",
- "name": "python-3.7.10"
- },
- "language_info": {
- "codemirror_mode": {
- "name": "ipython",
- "version": 3
- },
- "file_extension": ".py",
- "mimetype": "text/x-python",
- "name": "python",
- "nbconvert_exporter": "python",
- "pygments_lexer": "ipython3",
- "version": "3.7.10"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
- }
|