Jittor框架对环境要求如下:

Jittor 支持 Linux (e.g. Ubuntu/CentOS/Arch), macOS , Windows , 其中 Linux macOS 的依赖如下:

  • Python:版本 >= 3.7
  • C++编译器 (需要下列至少一个)
  • g++ (>=5.4.0 for linux)
  • clang (>=8.0 for mac)
  • GPU 编译器(可选):nvcc >=10.0
  • GPU 加速库(可选):cudnn-dev (cudnn开发版, 推荐使用tar安装方法, 参考链接 )
  • Jittor 目前还支持主流国产Linux操作系统,如统信、麒麟、普华、龙芯Loongnix,安装方式可参考 Linux pip安装方法,准备好python和g++即可。

    Windows 对环境的要求为:

  • Python:版本 >= 3.8(建议从Python官网安装: https://www.python.org/downloads/windows/ )
  • x86_64处理器
  • Windows 10及以上。
  • 如果您不希望手动配置环境,我们推荐使用 Docker 进行安装。 除此之外,您还可以使用 pip 安装和手动安装。

    注意1:macOS 用户需要安装额外依赖,请参考 macOS 安装

    Jittor 提供了三种安装方法:pip、docker和手动安装:

    Pip 安装

    下面将展示Ubuntu的安装命令,如果您在使用其他Linux操作系统(如CentOS), 请安装好依赖(Python>=3.7, g++>=5.4)或者使用 docker安装 , 如果您已经装好编译器和对应版本的Python,我们强烈推荐您使用这种方法 (如果无法访问github, 可以通过Jittor主页下载):

    sudo apt install python3.7-dev libomp-dev
    python3.7 -m pip install jittor
    # or install from github(latest version)
    # python3.7 -m pip install git+https://github.com/Jittor/jittor.git
    python3.7 -m jittor.test.test_example
    

    如果测试运行通过,恭喜你已经安装完成. jittor会自动在路径中寻找合适的编译器, 如果您希望手动指定编译器, 请使用环境变量 cc_pathnvcc_path(可选).

    macOS 安装

    macOS 请使用 homebrew 安装额外的依赖 (python>=3.7, onednn)。

    brew install python@3.7 onednn libomp
    

    之后您可以通过 pip 安装 jittor,并测试是否可以成功运行。

    python3.7 -m pip install jittor
    python3.7 -m jittor.test.test_example
    

    目前在macOS中,jittor 只支持 CPU 计算。

    Windows安装

    Windows 请准备好Python>=3.8,安装方法如下(conda安装需要额外命令):

    Windows user please prepare Python>=3.8, install instructions are list below(conda needs extra instructions):

    # check your python version(>=3.8)
    python --version
    python -m pip install jittor
    # if conda is used
    conda install pywin32
    

    Windows 下,jittor会自动检测显卡并安装对应的 CUDA, 请确保您的NVIDIA驱动支持CUDA 10.2 以上,您还可以使用如下命令手动为Jittor安装CUDA:

    python -m jittor_utils.install_cuda
    

    Docker 安装

    我们提供了Docker安装方式,免去您配置环境,Docker安装方法如下:

    # CPU only(Linux)
    docker run -it --network host jittor/jittor
    # CPU and CUDA(Linux)
    docker run -it --network host --gpus all jittor/jittor-cuda
    # CPU only(Mac and Windows)
    docker run -it -p 8888:8888 jittor/jittor
    

    关于Docker安装的详细教程,可以参考Windows/Mac/Linux通过Docker安装计图

    我们将逐步演示如何在Ubuntu 16.04中安装Jittor,其他Linux发行版可能可以使用类似的命令。

    步骤一:选择您的后端编译器

    # g++
    sudo apt install g++ build-essential libomp-dev
    # OR clang++-8
    wget -O - https://raw.githubusercontent.com/Jittor/jittor/master/script/install_llvm.sh > /tmp/llvm.sh
    bash /tmp/llvm.sh 8
    

    步骤二:安装Python和python-dev

    Jittor需要python的版本>=3.7。

    sudo apt install python3.7 python3.7-dev
    

    步骤三:运行Jittor

    整个框架是即时编译的。 让我们通过pip安装jittor

    git clone https://github.com/Jittor/jittor.git
    sudo pip3.7 install ./jittor
    export cc_path="clang++-8"
    # if other compiler is used, change cc_path
    # export cc_path="g++"
    # export cc_path="icc"
    # run a simple test
    python3.7 -m jittor.test.test_example
    

    如果通过了测试,那么您的Jittor已经准备就绪。

    可选步骤四:启用CUDA

    在Jittor中使用CUDA非常简单,只需设置环境值nvcc_path

    # replace this var with your nvcc location 
    export nvcc_path="/usr/local/cuda/bin/nvcc" 
    # run a simple cuda test
    python3.7 -m jittor.test.test_cuda 
    

    如果测试通过,则可以通过设置use_cuda标识符在Jittor中启用CUDA。

    import jittor as jt
    jt.flags.use_cuda = 1
    

    可选步骤五:测试训练Resnet18

    要检查Jittor的完整性,您可以运行Resnet18训练测试。需要注意的是,这个测试需要6G显存。

    python3.7 -m jittor.test.test_resnet
    

    如果这些测试失败,请为我们报告错误,我们十分欢迎您为Jittor做出贡献^ _ ^

    如果您碰到困难,欢迎随时联系我们, 联系方式如下:

    电子邮件:jittor@qq.com

    提出issue:https://github.com/Jittor/jittor/issues

    QQ 群:761222083