美文网首页Unity探路营
Unity OTC参赛全纪录 | 3.Evaluation环境搭

Unity OTC参赛全纪录 | 3.Evaluation环境搭

作者: 洪智 | 来源:发表于2019-03-04 10:00 被阅读1次

    你好,我是郑洪智,你的技术探路者。

    洪流学堂公众号回复OTC,关注比赛全纪录。

    好吧,又是搭建环境,感情当了几天配置管理员。

    不过这个测试环境也很重要(强行找借口),在提交成绩之前需要在本地大概跑一下,看看成绩如何,因为提交到aicrowd上评估的次数是有限制的。

    配置流程的官方文档:https://github.com/Unity-Technologies/obstacle-tower-challenge#testing-challenge-evaluation

    下面是大智的脱坑指南:

    1. 下载docker

    https://docs.docker.com/install/

    我下载的是windows版本。

    安装时候第一步,有个选项不要选,为什么?因为Unity文档上写了后面要使用linux的版本做评估。

    安装到最后一步还需要注销一下Windows才能完成安装,哎,一会又得打开这七八十个程序。点完按钮会注销当前用户,小新!啊,呸,小心!

    小新:“叫我干啥?”
    大智:“你听错了。。。”

    被动注销后重新登入,继续。

    docker的图标这个小鲸鱼还是挺可爱的。

    2. 构建Docker image

    这个image该怎么翻译脑子现在短路,一下子想不起来了。好心人可以提醒我一下。

    第一天的时候,如果你按照引导一步一步来,应该已经在python中装上了这个库aicrowd-repo2docker,如果还没有,运行下面的指令:

    pip install aicrowd-repo2docker
    # 或者到 obstacle-tower-challenge 目录
    pip install -r requirements.txt
    

    下一步构建就有点坑了,给了一个sh的脚本。
    我的电脑上装了git的bash,所以可以执行sh文件,开心。如果你那没有,可以直接在cmd使用下面的命令:

    aicrowd-repo2docker --no-run --image-name "obstacle_tower_challenge" --user-name aicrowd --debug .
    

    坑来了:

    ModuleNotFoundError: No module named 'pwd'
    

    试一下:

    pip install pwd
    Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
    Collecting pwd
      Could not find a version that satisfies the requirement pwd (from versions: )
    No matching distribution found for pwd
    

    竟然没有pwd这个包!在网上搜到pwd这个包是只能在unix下面用,用来访问Unix系统下用户和密码的数据库。https://docs.python.org/3/library/pwd.html

    那没办法了,只能先去网上找这个aicrowd-repo2docker的git库,发现这个库竟然是直接用了https://github.com/jupyter/repo2docker发布在pypi上面的,在这个地址里面找到了一个issues,是关于没有pwd的这个问题的。

    Windows平台还处于试验阶段,里面给了两种解决方案:

    • 换一个操作系统
    • 按文档的提示,试试WSL

    文档在这:http://repo2docker.readthedocs.io/en/latest/install.html#note-about-windows-support

    打开文档,文档中又套了个文档,关于Windows和WSL的:https://nickjanetakis.com/blog/setting-up-docker-for-windows-and-wsl-to-work-flawlessly

    再打开这个文档,麻鸭密密麻麻的字有点崩溃。

    需要花点时间思考下人生该何去何从了。

    • 搞个Linux虚拟机呢?
    • 继续硬着头皮搞这个WSL?

    喝了口水(小新:谁的口水?),上了个WC,决定了,硬着头皮搞这个WSL。为什么呢?因为搞个虚拟机太容易了,之前搞过,没意思。

    配置WSL

    WSL是个什么东西呢?Windows Subsystem for Linux,也叫Bash for Windows。

    废话不多少,按照文档开始安装。

    1.安装WSL

    先得安装WSL,文档在这:
    https://nickjanetakis.com/blog/using-wsl-and-mobaxterm-to-create-a-linux-dev-environment-on-windows

    1)开启WSL功能

    从旧文档里:打开Windows功能,找到WSL。

    我找了半天,并没有找到。。。只能再搜索,发现如今Windows 10已经不在Windows功能中显示这个选项了,需要从命令行开启。

    还是微软的这个文档靠谱https://docs.microsoft.com/en-us/windows/wsl/install-win10

    以管理员身份打开PowerShell(CMD不行),输入:

    Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
    

    回车后,又让重启。。。

    好吧,好吧,又有喝口水(小新:谁的口水?)的时间了。

    2)安装Linux镜像

    怎么感觉有种被坑了的感觉,这不还是要安装Linux嘛。

    https://www.microsoft.com/store/p/ubuntu/9nblggh4msv6

    文档中推荐安装Ubuntu,那就直接装Ubuntu吧,不过这个不是完整镜像,只是可以运行ubuntu的终端工具。趁着下载的时间,又可以去喝口水(小新:谁的口水?)了,顺便教训一下小新!!!

    下载完成后点击打开,自动开始安装:

    3)创建用户

    大概过了1,2,3,4,5分钟,终于安装完成了。

    输入一个用户名和密码,我们就进来啦!:

    到这WSL就算是初步搞定了。

    2.配置Docker

    选中如下选项。

    还需要在Ubuntu中安装Docker

    大概命令如下:

    # Update the apt package list.
    sudo apt-get update -y
    
    # Install Docker's package dependencies.
    sudo apt-get install -y \
        apt-transport-https \
        ca-certificates \
        curl \
        software-properties-common
    
    # Download and add Docker's official public PGP key.
    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
    
    # Verify the fingerprint.
    sudo apt-key fingerprint 0EBFCD88
    
    # Add the `stable` channel's Docker upstream repository.
    #
    # If you want to live on the edge, you can change "stable" below to "test" or
    # "nightly". I highly recommend sticking with stable!
    sudo add-apt-repository \
       "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
       $(lsb_release -cs) \
       stable"
    
    # Update the apt package list (for the new apt repo).
    sudo apt-get update -y
    
    # Install the latest version of Docker CE.
    sudo apt-get install -y docker-ce
    
    # Allow your user to access the Docker CLI without needing root access.
    sudo usermod -aG docker $USER
    

    我直接复制到Ubuntu里面安装了,又可以去喝口水(小新:谁...的...口...水...)了,顺便去看看还没凉透的小新。

    还没喝上水呢,发现太慢了,默认的源是ubuntu官方的,得改成国内的:

    #备份
    sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
    
    # 在/etc/apt/sources.list文件前面添加如下条目
    sudo nano /etc/apt/sources.list
    
    #添加阿里源
    deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
    

    然后继续安装,喝口水。。。

    着实有点慢,网速不给力,今天就到这吧,各位看官明天见。

    总结

    虽然选这个更有意思,但是我可能选了一条非常麻烦的路,还不如装个虚拟机。等明天全部搞完再下结论。

    洪流学堂公众号回复OTC,关注比赛全纪录。

    相关文章

      网友评论

        本文标题:Unity OTC参赛全纪录 | 3.Evaluation环境搭

        本文链接:https://www.haomeiwen.com/subject/igwduqtx.html