【“AI Earth”人工智能创新挑战赛——AI助力精准气象和海洋预测】
1,环境安装
按照下面的步骤把gpu显卡驱动装好,docker环境装好。参考:https://blog.csdn.net/qq_34624315/article/details/113783088
2,然后制作docker文件
参考链接:
Docker安装教程推荐:
- windows安装:https://www.runoob.com/docker/windows-docker-install.html
- 关于家庭版安装的参考:https://yeasy.gitbook.io/docker_practice/install/windows
- Mac安装:https://www.runoob.com/docker/macos-docker-install.html
- ubuntu安装:https://www.runoob.com/docker/ubuntu-docker-install.html
Docker学习教程推荐:
- Docker练习场:https://tianchi.aliyun.com/competition/entrance/231759/introduction
- Docker–从入门到实践:https://yeasy.gitbook.io/docker_practice/
- Docker教程:https://www.runoob.com/docker/docker-tutorial.html
执行命令:xxx,yyy换成你自己的
docker build -t registry.cn-hangzhou.aliyuncs.com/xxx/yyy:v1.0 .
显示构建好了一个tag。
3,提交docker到阿里的hub上
push速度超级慢。
等待了20分钟终于push好:
等了许久是这个结果:
阿里天池组织的比赛提交docker确实较复杂,pull push docker都会传输较大文件,网络不好的基本无法参赛。
参考资料:
天池Docker练习场实践经验: https://blog.csdn.net/donaldsy/article/details/104415500
baseline代码:https://github.com/datawhalechina/team-learning-data-mining/tree/master/WeatherOceanForecasts
天池官网的【入门】Docker练习场:https://tianchi.aliyun.com/competition/entrance/231759/tab/174?spm=5176.12586973.0.0.47f853300qsOKz
比赛地址:https://tianchi.aliyun.com/competition/entrance/531871/introduction
天池竞赛Docker快速复现:https://www.bilibili.com/video/BV1jy4y1J7rp/
参考一下markdown:
天池竞赛docker快速复现
问题核心:制作image供比赛平台pull
需要三步:
- 获取镜像库公网网址
- 制作镜像并推送至镜像库
- 在提交页面提交镜像地址
一、获取镜像库公网网址
-
1)在 https://cr.console.aliyun.com/ 上新建镜像库(请参考文档,同时直接建public库即可),查找镜像库公网网址,如:
-
registry.cn-hangzhou.aliyuncs.com/coggle/coggle
-
2)如果嫌阿里云的麻烦,直接在 https://hub.docker.com/ 上注册账号新建repository即可,要方便很多(但是刚制作好的镜像push跟pull要慢一些),而且亲测可用,如:
-
xuxml/tianchi-nlp
二、制作镜像并推送至镜像库
以下步骤均在本机上使用root权限操作:su - root
1.login docker(请将tianchi替换成自己的账号)
docker login --username=tianchi registry.cn-hangzhou.aliyuncs.com
2.在文件需要copy至镜像内的目录下新建Dockerfile文件,如:
-
|--tianchi-nlp
-
|-- env_check.py
-
|-- run.sh
-
|-- result.zip
-
|-- Dockerfile
-
注:tianchi目录下可以添加自己需要的内容
中Dockerfile文件内容为:
-
# Base Images
-
## 从天池基础镜像构建
-
FROM registry.cn-shanghai.aliyuncs.com/tcc-public/keras:latest-cuda10.0-py3
-
## 把当前文件夹里的文件构建到镜像的根目录下
-
ADD . /
-
## 指定默认工作目录为根目录(需要把run.sh和生成的结果文件都放在该文件夹下,提交后才能运行)
-
WORKDIR /
-
## 安装keras-bert包
-
RUN pip install keras-bert -i https://mirrors.aliyun.com/pypi/simple/
-
## 镜像启动后统一执行 sh run.sh
-
CMD ["sh", "run.sh"]
run.sh 参考:
python env_check.py
env_check.py参考:【先只写导入包的代码,确保镜像环境没问题再加其他代码】
-
import pandas as pd
-
import numpy as np
-
from sklearn.model_selection import KFold
-
from keras_bert import load_trained_model_from_checkpoint, Tokenizer
-
from keras.metrics import top_k_categorical_accuracy
-
from keras.layers import *
-
from keras.callbacks import *
-
from keras.models import Model
-
import keras.backend as K
-
from keras.optimizers import Adam
-
from keras.utils import to_categorical
-
from sklearn.preprocessing import LabelEncoder
-
print('done......')
3.build image
-
docker build -t coggle:v1 .
-
注意最后的 . 号
-
如果成功会显示:Successfully built 76c643fb44ee,其中 76c643fb44ee 即为镜像id。
4.tag and push image
-
docker tag 76c643fb44ee registry.cn-hangzhou.aliyuncs.com/coggle/coggle:v1
-
docker push registry.cn-hangzhou.aliyuncs.com/coggle/coggle:v1
-
如果提交至dockerhub:
-
docker login --username=xuxml #xuxml需替换成自己的账号
-
docker tag 76c643fb44ee xuxml/tianchi-nlp:v1 #xuxml/tianchi-nlp需替换成自己的repository
-
docker push xuxml/tianchi-nlp:v1
-
注意:
-
1.将76c643fb44ee替换成自己的镜像ID
-
2.registry.cn-hangzhou.aliyuncs.com/coggle/coggle替换成自己在步骤一中的网址,其中冒号后的字符串(本例为V1)为版本号,可自行修改。
三、在提交页面提交镜像地址及版本号
-
1)在提交页面填入:registry.cn-hangzhou.aliyuncs.com/coggle/coggle:v1 即可。
-
2)如果是镜像push至dockerhub,填入:docker.io/xuxml/tianchi-nlp:v1 即可。(会慢一些,因为执行的时候要从dockerhub pull镜像,国内镜像源也还没同步)
【全球人工智能技术创新大赛【热身赛二】
1,打包成功:
baseline代码地址:https://github.com/finlay-liu/tianchi-multi-task-nlp
git clone https://github.com/finlay-liu/tianchi-multi-task-nlp.git .
push完毕: