Git Product home page Git Product logo

jittor's Introduction

Jittor: a Just-in-time(JIT) deep learning framework

Jittor Logo

Quickstart | Install | Tutorial | 简体中文

Jittor is a high-performance deep learning framework based on JIT compiling and meta-operators. The whole framework and meta-operators are compiled just-in-time. A powerful op compiler and tuner are integrated into Jittor. It allowed us to generate high-performance code with specialized for your model. Jittor also contains a wealth of high-performance model libraries, including: image recognition, detection, segmentation, generation, differentiable rendering, geometric learning, reinforcement learning, etc. .

The front-end language is Python. Module Design and Dynamic Graph Execution is used in the front-end, which is the most popular design for deeplearning framework interface. The back-end is implemented by high performance language, such as CUDA,C++.

Related Links:

The following example shows how to model a two-layer neural network step by step and train from scratch In a few lines of Python code.

import jittor as jt
from jittor import Module
from jittor import nn
import numpy as np

class Model(Module):
    def __init__(self):
        self.layer1 = nn.Linear(1, 10)
        self.relu = nn.Relu() 
        self.layer2 = nn.Linear(10, 1)
    def execute (self,x) :
        x = self.layer1(x)
        x = self.relu(x)
        x = self.layer2(x)
        return x

def get_data(n): # generate random data for training test.
    for i in range(n):
        x = np.random.rand(batch_size, 1)
        y = x*x
        yield jt.float32(x), jt.float32(y)


learning_rate = 0.1
batch_size = 50
n = 1000

model = Model()
optim = nn.SGD(model.parameters(), learning_rate)

for i,(x,y) in enumerate(get_data(n)):
    pred_y = model(x)
    dy = pred_y - y
    loss = dy * dy
    loss_mean = loss.mean()
    optim.step(loss_mean)
    print(f"step {i}, loss = {loss_mean.data.sum()}")

Contents

Quickstart

We provide some jupyter notebooks to help you quick start with Jittor.

Install

Jittor environment requirements:

OS CPU Python Compiler (Optional) GPU platform
Linux
(Ubuntu, CentOS, Arch,
UOS, KylinOS, ...)
x86
x86_64
ARM
loongson
>= 3.7 g++ >=5.4 Nvidia CUDA >= 10.0, cuDNN
or AMD ROCm >= 4.0
or Hygon DCU DTK >= 22.04
macOS
(>= 10.14 Mojave)
intel
Apple Silicon
>= 3.7 clang >= 8.0 -
Windows 10 & 11 x86_64 >= 3.8 - Nvidia CUDA >= 10.2 cuDNN

Jittor offers three ways to install: pip, docker, or manual.

Pip install

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

macOS install

Please first install additional dependencies with homebrew.

brew install libomp

Then you can install jittor through pip and run the example.

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

Currently jittor only supports CPU on macOS.

Windows install

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

In Windows, jittor will automatically detect and install CUDA, please make sure your NVIDIA driver support CUDA 10.2 or above, or you can manually let jittor install CUDA for you:

python -m jittor_utils.install_cuda

Docker Install

We provide a Docker installation method to save you from configuring the environment. The Docker installation method is as follows:

# 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

manual install

We will show how to install Jittor in Ubuntu 16.04 step by step, Other Linux distributions may have similar commands.

Step 1: Choose your back-end compiler

# 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

Step 2: Install Python and python-dev

Jittor need python version >= 3.7.

sudo apt install python3.7 python3.7-dev

Step 3: Run Jittor

The whole framework is compiled Just-in-time. Let's install jittor via pip

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

if the test is passed, your Jittor is ready.

Optional Step 4: Enable CUDA

Using CUDA in Jittor is very simple, Just setup environment value 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 

if the test is passed, your can use Jittor with CUDA by setting use_cuda flag.

import jittor as jt
jt.flags.use_cuda = 1

Optional Step 5: Test Resnet18 training

To check the integrity of Jittor, you can run Resnet18 training test. Note: 6G GPU RAM is requires in this test.

python3.7 -m jittor.test.test_resnet

if those tests are failed, please report bugs for us, and feel free to contribute ^_^

Tutorial

In the tutorial section, we will briefly explain the basic concept of Jittor.

To train your model with Jittor, there are only three main concepts you need to know:

  • Var: basic data type of jittor
  • Operations: Jittor'op is simular with numpy

Var

First, let's get started with Var. Var is the basic data type of jittor. Computation process in Jittor is asynchronous for optimization. If you want to access the data, Var.data can be used for synchronous data accessing.

import jittor as jt
a = jt.float32([1,2,3])
print (a)
print (a.data)
# Output: float32[3,]
# Output: [ 1. 2. 3.]

And we can give the variable a name.

a.name('a')
print(a.name())
# Output: a

Operations

Jittor'op is simular with numpy. Let's try some operations. We create Var a and b via operation jt.float32, and add them. Printing those variables shows they have the same shape and dtype.

import jittor as jt
a = jt.float32([1,2,3])
b = jt.float32([4,5,6])
c = a*b
print(a,b,c)
print(type(a), type(b), type(c))
# Output: float32[3,] float32[3,] float32[3,]
# Output: <class 'jittor_core.Var'> <class 'jittor_core.Var'> <class 'jittor_core.Var'>

Beside that, All the operators we used jt.xxx(Var, ...) have alias Var.xxx(...). For example:

c.max() # alias of jt.max(c)
c.add(a) # alias of jt.add(c, a)
c.min(keepdims=True) # alias of jt.min(c, keepdims=True)

if you want to know all the operation which Jittor supports. try help(jt.ops). All the operation you found in jt.ops.xxx, can be used via alias jt.xxx.

help(jt.ops)
# Output:
#   abs(x: core.Var) -> core.Var
#   add(x: core.Var, y: core.Var) -> core.Var
#   array(data: array) -> core.Var
#   binary(x: core.Var, y: core.Var, op: str) -> core.Var
#   ......

More

If you want to know more about Jittor, please check out the notebooks below:

Those notebooks can be started in your own computer by python3.7 -m jittor.notebook

Contributing

Jittor is still young. It may contain bugs and issues. Please report them in our bug track system. Contributions are welcome. Besides, if you have any ideas about Jittor, please let us know.

You can help Jittor in the following ways:

  • Citing Jittor in your paper
  • recommend Jittor to your friends
  • Contributing code
  • Contributed tutorials and documentation
  • File an issue
  • Answer jittor related questions
  • Light up the stars
  • Keep an eye on jittor
  • ......

Contact Us

Website: http://cg.cs.tsinghua.edu.cn/jittor/

Email: [email protected]

File an issue: https://github.com/Jittor/jittor/issues

QQ Group: 761222083

The Team

Jittor is currently maintained by the Tsinghua CSCG Group. If you are also interested in Jittor and want to improve it, Please join us!

Citation

@article{hu2020jittor,
  title={Jittor: a novel deep learning framework with meta-operators and unified graph execution},
  author={Hu, Shi-Min and Liang, Dun and Yang, Guo-Ye and Yang, Guo-Wei and Zhou, Wen-Yang},
  journal={Science China Information Sciences},
  volume={63},
  number={222103},
  pages={1--21},
  year={2020}
}

License

Jittor is Apache 2.0 licensed, as found in the LICENSE.txt file.

jittor's People

Contributors

514flowey avatar bennyguo avatar boltomli avatar cjld avatar cxjyxxme avatar exusial avatar gword avatar jittor avatar jwzxgy2007 avatar kiwi511 avatar ldyang694 avatar letianlee avatar li-xl avatar liuruiyang98 avatar llehtahw avatar lzhengning avatar menghaoguo avatar peterh0323 avatar toddlt avatar tupig-7 avatar uyzhang avatar vc12345679 avatar wwhio avatar xingyuxie avatar xmyqsh avatar yaox12 avatar yuantailing avatar zhouwy19 avatar zhouwy2115 avatar zjp-shadow avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jittor's Issues

nn.Tanh 爆nan

nn.Tanh输入大数会爆nan(如下代码),似乎是由于nn.Tanh中的exp计算导致的

import jittor as jt
m=jt.nn.Tanh()
print(m(jt.array([1000])))

loss = nan

I run the example of Linear Regression,but the loss became nan since step2.

CUDA error code=702(cudaErrorLaunchTimeout)

CUDA error at /home/yss/miniconda3/envs/JT/lib/python3.7/site-packages/jittor/src/mem/allocator/cuda_dual_allocator.h:97 code=702(cudaErrorLaunchTimeout) "cudaLaunchHostFunc(0, &to_free_allocation, 0)"

install problem

@Jittor firstly, thx for your great work.

I am wondering if you install from source in python virtual environment. I found it can not find the correct Python.h path

可以增加一篇文章来介绍框架架构吗,谢谢

对框架本身比较感兴趣,比如c++代码如何跟python绑定的,动态编译是怎么实现的,整个框架架构是什么样子的。这个项目相对于pytorch tensorflow比较早期,非常适合学习,希望自己能和框架共同成长,增加一些工程上的介绍也有助于把项目推广出去,增加更多的contributor。
感谢作者们提供这么简洁强大的框架。

实现组卷积时不能在GPU上运行

通过元算子我实现了Group Convlution

class DWConv(Module):
    def __init__(self, in_channels, out_channels, kernel_size, stride=1, padding=0, dilation=1, groups=1, bias=True):
        super(DWConv, self).__init__()
        assert in_channels % groups == 0 and out_channels % groups == 0
        self.groups = groups
        self.group_channel_in = in_channels // groups
        self.group_channel_out = out_channels // groups
        self.in_channels = in_channels
        self.out_channels = out_channels
        self.kernel_size = kernel_size if isinstance(kernel_size, tuple) else (kernel_size, kernel_size)
        self.stride = stride if isinstance(stride, tuple) else (stride, stride)
        self.padding = padding if isinstance(padding, tuple) else (padding, padding)
        self.dilation = dilation if isinstance(dilation, tuple) else (dilation, dilation)
        Kh, Kw = self.kernel_size
        self.weight = init.relu_invariant_gauss([groups, out_channels//groups, in_channels // groups, Kh, Kw], dtype="float",
                                                mode="fan_out")
        if bias:
            self.bias = init.uniform([out_channels], dtype="float", low=-1, high=1)
        else:
            self.bias = None

    def execute(self, x):
        N, C, H, W = x.shape
        Kh, Kw = self.kernel_size
        oh = (H + self.padding[0] * 2 - Kh * self.dilation[0] + self.dilation[0] - 1) // self.stride[0] + 1
        ow = (W + self.padding[1] * 2 - Kw * self.dilation[1] + self.dilation[1] - 1) // self.stride[1] + 1

        x = jt.reshape(x,[N,self.groups, self.group_channel_in, H, W])
        xx = x.reindex(
            [N, self.groups, self.group_channel_out, self.group_channel_in, oh, ow, Kh, Kw], [
                'i0',  # Nid
                'i1', # Group
                'i3',  # Cid
                f'i4*{self.stride[0]}-{self.padding[0]}+i6*{self.dilation[0]}',  # Hid+Khid
                f'i5*{self.stride[1]}-{self.padding[1]}+i7*{self.dilation[1]}',  # Wid+KWid
            ])
        ww = self.weight.broadcast(xx.shape, [0, 4, 5])
        yy = xx * ww
        y = yy.sum([3, 6, 7])  # Kc, Kh, Kw
        y = jt.reshape(y,[N, self.out_channels, oh, ow])
        if self.bias is not None:
            b = self.bias.broadcast(y.shape, [0, 2, 3])
            y = y + b
        return y

在使用CPU训练时可以运行,但是使用GPU时会出先以下bug:

image

AssertionError while running test example

Hi, I got an assertion error when trying to run the test example given in the manual.

> python3 -m jittor.test.test_example
[i 0321 14:59:04.413733 76 v1 __init__.py:102] Run cmd: which g++
[i 0321 14:59:04.429153 76 v1 __init__.py:102] Run cmd: /usr/bin/g++ --version
[i 0321 14:59:04.444102 76 __init__.py:183] Found g++(7.5.0) at /usr/bin/g++.
[i 0321 14:59:04.448991 76 v1 __init__.py:102] Run cmd: git branch
fatal: not a git repository (or any of the parent directories): .git
[i 0321 14:59:04.473556 76 v1 __init__.py:102] Run cmd: which /usr/local/cuda/bin/nvcc
[i 0321 14:59:04.491051 76 v1 compiler.py:733] /usr/local/cuda/bin/nvcc not found.
[i 0321 14:59:04.491664 76 v1 __init__.py:102] Run cmd: which gdb
[i 0321 14:59:04.510585 76 v1 compiler.py:733] gdb not found.
[i 0321 14:59:04.511085 76 v1 __init__.py:102] Run cmd: which addr2line
[i 0321 14:59:04.527993 76 v1 __init__.py:102] Run cmd: /usr/bin/addr2line --version
[i 0321 14:59:04.546289 76 __init__.py:183] Found addr2line(2.30) at /usr/bin/addr2line.
[i 0321 14:59:04.546897 76 v1 __init__.py:102] Run cmd: /usr/bin/python3 -m pybind11 --includes
[i 0321 14:59:04.618063 76 compiler.py:802] pybind_include: -I/usr/include/python3.7m -I/usr/local/include/python3.7 -I/root/.local/include/python3.7m
[i 0321 14:59:04.618778 76 v1 __init__.py:102] Run cmd: /usr/bin/python3-config --extension-suffix
[i 0321 14:59:04.696032 76 compiler.py:804] extension_suffix: .cpython-36m-x86_64-linux-gnu.so
[i 0321 14:59:04.696785 76 v1 __init__.py:102] Run cmd: /usr/bin/g++ /usr/local/lib/python3.7/dist-packages/jittor/src/utils/cache_compile.cc /usr/local/lib/python3.7/dist-packages/jittor/src/utils/log.cc /usr/local/lib/python3.7/dist-packages/jittor/src/utils/tracer.cc /usr/local/lib/python3.7/dist-packages/jittor/src/utils/jit_utils.cc   -Wall -Werror -Wno-unknown-pragmas -std=c++14 -fPIC -march=native -I/usr/include/python3.7m -I/usr/local/include/python3.7 -I/root/.local/include/python3.7m -I/usr/local/lib/python3.7/dist-packages/jittor/src   -O2    -lstdc++ -ldl -shared  -o /root/.cache/jittor/default/g++/jit_utils_core.cpython-36m-x86_64-linux-gnu.so
Traceback (most recent call last):
  File "/usr/lib/python3.7/runpy.py", line 183, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/usr/lib/python3.7/runpy.py", line 109, in _get_module_details
    __import__(pkg_name)
  File "/usr/local/lib/python3.7/dist-packages/jittor/__init__.py", line 10, in <module>
    from . import compiler
  File "/usr/local/lib/python3.7/dist-packages/jittor/compiler.py", line 814, in <module>
    check_cache_compile()
  File "/usr/local/lib/python3.7/dist-packages/jittor/compiler.py", line 720, in check_cache_compile
    assert jit_utils.cc
AssertionError

I'm using:

  • Ubuntu 18.04.4 (Windows WSL)
  • Python 3.7.5
  • GCC 7.5.0

Any help on how to fix this problem? Many thanks : )

Run test failed under centos7-python3.7-g++5.4.0-cuda10.0

[root@PKUDELL15 mygittor]# python -m jittor.test.test_example
[i 0321 09:05:08.817482 52 v1 init.py:102] Run cmd: which g++
[i 0321 09:05:08.820777 52 v1 init.py:102] Run cmd: /usr/local/bin/g++ --version
[i 0321 09:05:08.826433 52 init.py:183] Found g++(5.4.0) at /usr/local/bin/g++.
[i 0321 09:05:08.832981 52 v1 init.py:102] Run cmd: git branch
fatal: Not a git repository (or any of the parent directories): .git
[i 0321 09:05:08.856586 72 init.py:183] Found /usr/local/cuda/bin/nvcc(10.0.130) at /usr/local/cuda/bin/nvcc.
which: no gdb in (/root/anaconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/opt/maven/bin:/usr/local/cuda/bin:/root/bin)
[i 0321 09:05:08.869479 72 init.py:183] Found addr2line(2.23.52) at /usr/bin/addr2line.
[i 0321 09:05:08.923038 72 compiler.py:802] pybind_include: -I/root/anaconda3/include/python3.7m -I/root/anaconda3/lib/python3.7/site-packages/pybind11-2.4.dev4-py3.7.egg/pybind11/include
[i 0321 09:05:08.950114 72 compiler.py:804] extension_suffix: .cpython-37m-x86_64-linux-gnu.so
/usr/bin/ld: /root/.cache/jittor/default/g++/ee002b49b2fd09c70af20f5067a1667dcd07ec05-g++-cuda.o: unrecognized relocation (0x2a) in section `.text'
/usr/bin/ld: final link failed: 错误的值
collect2: 错误:ld 返回 1
Traceback (most recent call last):
File "/root/anaconda3/lib/python3.7/runpy.py", line 183, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "/root/anaconda3/lib/python3.7/runpy.py", line 109, in _get_module_details
import(pkg_name)
File "/root/anaconda3/lib/python3.7/site-packages/jittor-1.0.0-py3.7.egg/jittor/init.py", line 10, in
from . import compiler
File "/root/anaconda3/lib/python3.7/site-packages/jittor-1.0.0-py3.7.egg/jittor/compiler.py", line 906, in
compile(cc_path, cc_flags+opt_flags, files, 'jittor_core'+extension_suffix)
File "/root/anaconda3/lib/python3.7/site-packages/jittor-1.0.0-py3.7.egg/jittor/compiler.py", line 81, in compile
return do_compile(cmd)
File "/root/anaconda3/lib/python3.7/site-packages/jittor-1.0.0-py3.7.egg/jittor/compiler.py", line 43, in do_compile
return jit_utils.cc.cache_compile(cmd, cache_path, jittor_path)
RuntimeError: [f 0321 09:05:09.531569 72 log.cc:288] Check failed ret(256) == 0(0) Something wrong ... Could you please report this issue?
Run cmd failed: cd /root/.cache/jittor/default/g++ && /usr/local/bin/g++ /root/.cache/jittor/default/g++/obj_files/op_register.cc.o /root/.cache/jittor/default/g++/obj_files/pyjt_core.cc.o /root/.cache/jittor/default/g++/obj_files/pyjt_fetcher.cc.o /root/.cache/jittor/default/g++/obj_files/pyjt_graph.cc.o /root/.cache/jittor/default/g++/obj_files/pyjt_init.cc.o /root/.cache/jittor/default/g++/obj_files/pyjt_op_compiler.cc.o /root/.cache/jittor/default/g++/obj_files/pyjt_allocator.cc.o /root/.cache/jittor/default/g++/obj_files/pyjt_hash.cc.o /root/.cache/jittor/default/g++/obj_files/pyjt_nano_string.cc.o /root/.cache/jittor/default/g++/obj_files/pyjt_nano_vector.cc.o /root/.cache/jittor/default/g++/obj_files/pyjt_profiler.cc.o /root/.cache/jittor/default/g++/obj_files/pyjt_jit_flags.cc.o /root/.cache/jittor/default/g++/obj_files/pyjt_jit_tests.cc.o /root/.cache/jittor/default/g++/obj_files/pyjt_jit_op_maker.cc.o /root/.cache/jittor/default/g++/obj_files/pyjt_all.cc.o /root/.cache/jittor/default/g++/obj_files/op_utils.cc.o /root/.cache/jittor/default/g++/obj_files/event_queue.cc.o /root/.cache/jittor/default/g++/obj_files/sfrl_allocator.cc.o /root/.cache/jittor/default/g++/obj_files/allocator.cc.o /root/.cache/jittor/default/g++/obj_files/fused_op.cc.o /root/.cache/jittor/default/g++/obj_files/fuser.cc.o /root/.cache/jittor/default/g++/obj_files/grad.cc.o /root/.cache/jittor/default/g++/obj_files/graph.cc.o /root/.cache/jittor/default/g++/obj_files/init.cc.o /root/.cache/jittor/default/g++/obj_files/jit_compiler.cc.o /root/.cache/jittor/default/g++/obj_files/jit_key.cc.o /root/.cache/jittor/default/g++/obj_files/op.cc.o /root/.cache/jittor/default/g++/obj_files/op_compiler.cc.o /root/.cache/jittor/default/g++/obj_files/var.cc.o /root/.cache/jittor/default/g++/obj_files/var_holder.cc.o /root/.cache/jittor/default/g++/obj_files/aligned_allocator.cc.o /root/.cache/jittor/default/g++/obj_files/cuda_device_allocator.cc.o /root/.cache/jittor/default/g++/obj_files/cuda_dual_allocator.cc.o /root/.cache/jittor/default/g++/obj_files/cuda_host_allocator.cc.o /root/.cache/jittor/default/g++/obj_files/cuda_managed_allocator.cc.o /root/.cache/jittor/default/g++/obj_files/nfef_allocator.cc.o /root/.cache/jittor/default/g++/obj_files/stat_allocator.cc.o /root/.cache/jittor/default/g++/obj_files/cpu_atomic.cc.o /root/.cache/jittor/default/g++/obj_files/cuda_flags.cc.o /root/.cache/jittor/default/g++/obj_files/nano_string.cc.o /root/.cache/jittor/default/g++/obj_files/arg_reduce_op.cc.o /root/.cache/jittor/default/g++/obj_files/argsort_op.cc.o /root/.cache/jittor/default/g++/obj_files/array_op.cc.o /root/.cache/jittor/default/g++/obj_files/binary_op.cc.o /root/.cache/jittor/default/g++/obj_files/broadcast_to_op.cc.o /root/.cache/jittor/default/g++/obj_files/candidate_op.cc.o /root/.cache/jittor/default/g++/obj_files/clone_op.cc.o /root/.cache/jittor/default/g++/obj_files/code_op.cc.o /root/.cache/jittor/default/g++/obj_files/concat_op.cc.o /root/.cache/jittor/default/g++/obj_files/index_op.cc.o /root/.cache/jittor/default/g++/obj_files/random_op.cc.o /root/.cache/jittor/default/g++/obj_files/reduce_op.cc.o /root/.cache/jittor/default/g++/obj_files/reindex_op.cc.o /root/.cache/jittor/default/g++/obj_files/reindex_reduce_op.cc.o /root/.cache/jittor/default/g++/obj_files/reshape_op.cc.o /root/.cache/jittor/default/g++/obj_files/ternary_op.cc.o /root/.cache/jittor/default/g++/obj_files/transpose_op.cc.o /root/.cache/jittor/default/g++/obj_files/unary_op.cc.o /root/.cache/jittor/default/g++/obj_files/where_op.cc.o /root/.cache/jittor/default/g++/obj_files/expr.cc.o /root/.cache/jittor/default/g++/obj_files/jit_searcher.cc.o /root/.cache/jittor/default/g++/obj_files/kernel_ir.cc.o /root/.cache/jittor/default/g++/obj_files/pass_manager.cc.o /root/.cache/jittor/default/g++/obj_files/tuner_manager.cc.o /root/.cache/jittor/default/g++/obj_files/var_relay.cc.o /root/.cache/jittor/default/g++/obj_files/assume_aligned_pass.cc.o /root/.cache/jittor/default/g++/obj_files/atomic_tuner_pass.cc.o /root/.cache/jittor/default/g++/obj_files/check_cache_pass.cc.o /root/.cache/jittor/default/g++/obj_files/compile_shapes_pass.cc.o /root/.cache/jittor/default/g++/obj_files/expand_empty_block_pass.cc.o /root/.cache/jittor/default/g++/obj_files/fake_main_pass.cc.o /root/.cache/jittor/default/g++/obj_files/float_atomic_fix_pass.cc.o /root/.cache/jittor/default/g++/obj_files/insert_profile_loop_pass.cc.o /root/.cache/jittor/default/g++/obj_files/loop_to_func_pass.cc.o /root/.cache/jittor/default/g++/obj_files/loop_var_analyze_pass.cc.o /root/.cache/jittor/default/g++/obj_files/mark_raw_pass.cc.o /root/.cache/jittor/default/g++/obj_files/merge_loop_pass.cc.o /root/.cache/jittor/default/g++/obj_files/parallel_pass.cc.o /root/.cache/jittor/default/g++/obj_files/pass.cc.o /root/.cache/jittor/default/g++/obj_files/remove_intermediate_pass.cc.o /root/.cache/jittor/default/g++/obj_files/remove_loop_pass.cc.o /root/.cache/jittor/default/g++/obj_files/rename_loop_index_pass.cc.o /root/.cache/jittor/default/g++/obj_files/reorder_loop_pass.cc.o /root/.cache/jittor/default/g++/obj_files/replace_for_num_pass.cc.o /root/.cache/jittor/default/g++/obj_files/restride_pass.cc.o /root/.cache/jittor/default/g++/obj_files/solve_conflict_define_pass.cc.o /root/.cache/jittor/default/g++/obj_files/split_loop_pass.cc.o /root/.cache/jittor/default/g++/obj_files/unroll_pass.cc.o /root/.cache/jittor/default/g++/obj_files/use_movnt_pass.cc.o /root/.cache/jittor/default/g++/obj_files/vectorize_pass.cc.o /root/.cache/jittor/default/g++/obj_files/broadcast_tuner.cc.o /root/.cache/jittor/default/g++/obj_files/conv_tuner.cc.o /root/.cache/jittor/default/g++/obj_files/matmul_tuner.cc.o /root/.cache/jittor/default/g++/obj_files/reduce_tuner.cc.o /root/.cache/jittor/default/g++/obj_files/reorder_tuner.cc.o /root/.cache/jittor/default/g++/obj_files/tuner.cc.o /root/.cache/jittor/default/g++/obj_files/cache_info.cc.o /root/.cache/jittor/default/g++/obj_files/memory_checker.cc.o /root/.cache/jittor/default/g++/obj_files/replacement.cc.o /root/.cache/jittor/default/g++/obj_files/vtop.cc.o /root/.cache/jittor/default/g++/obj_files/core.cc.o /root/.cache/jittor/default/g++/obj_files/py_var_tracer.cc.o /root/.cache/jittor/default/g++/obj_files/numpy.cc.o /root/.cache/jittor/default/g++/obj_files/test_expr.cc.o /root/.cache/jittor/default/g++/obj_files/test_fast_shared_ptr.cc.o /root/.cache/jittor/default/g++/obj_files/test_jit_key.cc.o /root/.cache/jittor/default/g++/obj_files/test_kernel_ir.cc.o /root/.cache/jittor/default/g++/obj_files/test_nano_vector.cc.o /root/.cache/jittor/default/g++/obj_files/test_op_compiler.cc.o /root/.cache/jittor/default/g++/obj_files/test_op_relay.cc.o /root/.cache/jittor/default/g++/obj_files/test_sfrl_allocator.cc.o /root/.cache/jittor/default/g++/obj_files/flags.cc.o /root/.cache/jittor/default/g++/obj_files/mwsr_list.cc.o /root/.cache/jittor/default/g++/obj_files/profiler.cc.o /root/.cache/jittor/default/g++/obj_files/executor.cc.o /root/.cache/jittor/default/g++/obj_files/fetcher.cc.o /root/.cache/jittor/default/g++/ee002b49b2fd09c70af20f5067a1667dcd07ec05-g++-cuda.o -Wall -Werror -Wno-unknown-pragmas -std=c++14 -fPIC -march=native -I/root/anaconda3/include/python3.7m -I/root/anaconda3/lib/python3.7/site-packages/pybind11-2.4.dev4-py3.7.egg/pybind11/include -I/root/anaconda3/lib/python3.7/site-packages/jittor-1.0.0-py3.7.egg/jittor/src -DHAS_CUDA -I'/usr/local/cuda/include' -I'/root/anaconda3/lib/python3.7/site-packages/jittor-1.0.0-py3.7.egg/jittor/extern/cuda/inc' -I/root/.cache/jittor/default/g++ -O2 -lstdc++ -ldl -shared -lcudart -L'/usr/local/cuda/lib64' -o /root/.cache/jittor/default/g++/jittor_core.cpython-37m-x86_64-linux-gnu.so

安装成功,使用时错误

你好请教一下:
(1)安装 python3.7-dev,
sudo apt install python3.7-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package python3.7-dev
E: Couldn't find any package by glob 'python3.7-dev'
E: Couldn't find any package by regex 'python3.7-dev'

(2)不管1, 直接能安装成功
python3.7 -m pip install git+https://github.com/Jittor/jittor.git成功后
import jittor或者python3.7 -m jittor.test.test_example都出现
[i 0402 21:49:51.393790 80 init.py:195] Found g++(5.4.0) at /usr/bin/g++.
py3_config_path /usr/bin/python33-config
Traceback (most recent call last):
File "", line 1, in
File "/opt/python3.7/lib/python3.7/site-packages/jittor/init.py", line 10, in
from . import compiler
File "/opt/python3.7/lib/python3.7/site-packages/jittor/compiler.py", line 782, in
assert os.path.isfile(py3_config_path)
AssertionError
import jittor,py3_config_path打印出来是 /usr/bin/python33-config,
python3.7 -m jittor.test.test_example,py3_config_path打印出来是/usr/bin/python3.73-config
/usr/bin/里面没有python33-config,python3.73-config

CUDA Error

I'm using Jittor on Ubuntu 18.04 LTS and my GPU is Titan X. After I follow the installation guide, I got the error as follow:
[i 0323 16:51:41.418770 16 v1 init.py:102] Run cmd: which g++
[i 0323 16:51:41.420143 16 v1 init.py:102] Run cmd: /usr/bin/g++ --version
[i 0323 16:51:41.421803 16 init.py:183] Found g++(7.5.0) at /usr/bin/g++.
[i 0323 16:51:41.423934 16 v1 init.py:102] Run cmd: git branch
fatal: 不是一个 git 仓库(或者任何父目录):.git
[i 0323 16:51:41.472734 92 init.py:183] Found gdb(8.1.0) at /usr/bin/gdb.
[i 0323 16:51:41.475906 92 init.py:183] Found addr2line(2.30) at /usr/bin/addr2line.
[i 0323 16:51:41.564629 92 compiler.py:802] pybind_include: -I/usr/include/python3.7m -I/usr/local/include/python3.7 -I/home/deeprob000/.local/include/python3.7m
[i 0323 16:51:41.571561 92 compiler.py:804] extension_suffix: .cpython-37m-x86_64-linux-gnu.so
[i 0323 16:51:41.873686 92 cuda_flags.cc:19] CUDA disabled.
[i 0323 16:51:41.873736 92 jit_compiler.cc:20] Load cc_path: /usr/bin/g++
[i 0323 16:51:41.873740 92 jit_compiler.cc:23] Load nvcc_path: /usr/local/cuda/bin/nvcc
CUDA error at /usr/local/lib/python3.7/dist-packages/jittor/src/ops/array_op.cc:29 code=100(cudaErrorNoDevice) "cudaStreamCreateWithFlags(&stream, cudaStreamNonBlocking)"
terminate called after throwing an instance of 'std::runtime_error'
what(): CUDA error
已放弃 (核心已转储)
So how to fix this problem?

没有Windows支持别瞎出大作业

大家在家上网课已经很不容易了,这个jittor只支持Linux,不适宜作为大作业的一部分。隔壁自动化系已经翻车了,图形学这课可别给贵系丢人。

manjaro安装jittor成功,启用cuda失败

manjaro上安装jittor,由于不是ubuntu于是参考官方手动安装教程:
1.安装python3,python3-dev,pip,g++(我本来就装了,又装上llvm,clang,但后面会出几个错误,最后解决不掉放弃)
2.安装openmp,openmpi
sudo pacman -S openmp openmpi
3.git clone https://github.com/Jittor/jittor.git
修改./jittor/setup.py,注释掉第12行关于ubuntu的断言
sudo pip3 install ./jittor
export cc_path="g++"
4.python3 -m jittor.test.test_example
测试成功,至此可以尝下鲜了

5.export nvcc_path="/opt/cuda/bin/nvcc"
python3 -m jittor.test.test_cuda
失败,报如下错误:
[i 0328 18:08:32.095712 56 init.py:186] Found gdb(9.1) at /usr/bin/gdb.
[i 0328 18:08:32.103046 56 init.py:186] Found addr2line(2.34) at /usr/bin/addr2line.
[i 0328 18:08:32.197722 56 compiler.py:803] pybind_include: -I/usr/include/python3.8 -I/home/lmzl/.local/include/python3.8
[i 0328 18:08:32.214142 56 compiler.py:805] extension_suffix: .cpython-38-x86_64-linux-gnu.so
[i 0328 18:08:32.415568 56 cuda_flags.cc:19] CUDA disabled.
[i 0328 18:08:32.415576 56 jit_compiler.cc:20] Load cc_path: g++
[i 0328 18:08:32.415579 56 jit_compiler.cc:23] Load nvcc_path: /opt/cuda/bin/nvcc
CUDA error at /usr/lib/python3.8/site-packages/jittor/src/ops/array_op.cc:29 code=35(cudaErrorInsufficientDriver) "cudaStreamCreateWithFlags(&stream, cudaStreamNonBlocking)"
terminate called after throwing an instance of 'std::runtime_error'
what(): CUDA error
[1] 10783 abort (core dumped) python3 -m jittor.test.test_cuda

$ nvidia-smi
Sat Mar 28 18:26:06 2020
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 430.64 Driver Version: 430.64 CUDA Version: 10.1 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+======================+======================|
| 0 GeForce GTX 106... Off | 00000000:01:00.0 On | N/A |
| 37% 34C P0 30W / 120W | 338MiB / 6076MiB | 0% Default |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes: GPU Memory |
| GPU PID Type Process name Usage |
|=============================================================================|
| 0 678 G /usr/lib/Xorg 18MiB |
| 0 907 G /usr/lib/Xorg 120MiB |
| 0 957 G /usr/bin/gnome-shell 84MiB |
| 0 1400 G ...AAAAAAAAAAAAAAgAAAAAAAAA --shared-files 83MiB |
+-----------------------------------------------------------------------------+

希望能尽快支持其他发行版,加油!

Segfault, exit

Train Epoch: 0 [0/766 (0%)]	Loss: 2.549237
Train Epoch: 0 [10/766 (1%)]	Loss: 2.571268
Train Epoch: 0 [20/766 (3%)]	Loss: 2.207814
Train Epoch: 0 [30/766 (4%)]	Loss: 2.274659
Train Epoch: 0 [40/766 (5%)]	Loss: 2.211828
Train Epoch: 0 [50/766 (7%)]	Loss: 2.293380
Train Epoch: 0 [60/766 (8%)]	Loss: 2.146942
Train Epoch: 0 [70/766 (9%)]	Loss: 2.183479
Train Epoch: 0 [80/766 (10%)]	Loss: 2.014589
Train Epoch: 0 [90/766 (12%)]	Loss: 2.112265
Train Epoch: 0 [100/766 (13%)]	Loss: 1.804279
Train Epoch: 0 [110/766 (14%)]	Loss: 2.146718
Train Epoch: 0 [120/766 (16%)]	Loss: 1.834919
Train Epoch: 0 [130/766 (17%)]	Loss: 1.726209
Train Epoch: 0 [140/766 (18%)]	Loss: 1.888488
Train Epoch: 0 [150/766 (20%)]	Loss: 1.838179
Train Epoch: 0 [160/766 (21%)]	Loss: 1.839886
Train Epoch: 0 [170/766 (22%)]	Loss: 1.664787
Train Epoch: 0 [180/766 (23%)]	Loss: 1.865397
Train Epoch: 0 [190/766 (25%)]	Loss: 1.781140
Train Epoch: 0 [200/766 (26%)]	Loss: 1.898801
Train Epoch: 0 [210/766 (27%)]	Loss: 2.073373
Train Epoch: 0 [220/766 (29%)]	Loss: 1.683119
Train Epoch: 0 [230/766 (30%)]	Loss: 1.850946
Train Epoch: 0 [240/766 (31%)]	Loss: 1.532344
Train Epoch: 0 [250/766 (33%)]	Loss: 1.873403
Train Epoch: 0 [260/766 (34%)]	Loss: 1.785834
Train Epoch: 0 [270/766 (35%)]	Loss: 2.242968
Train Epoch: 0 [280/766 (37%)]	Loss: 1.321845
Train Epoch: 0 [290/766 (38%)]	Loss: 1.664857
Train Epoch: 0 [300/766 (39%)]	Loss: 1.549777
Train Epoch: 0 [310/766 (40%)]	Loss: 1.533398
Train Epoch: 0 [320/766 (42%)]	Loss: 1.613966
Train Epoch: 0 [330/766 (43%)]	Loss: 1.576215
Train Epoch: 0 [340/766 (44%)]	Loss: 1.518085
Train Epoch: 0 [350/766 (46%)]	Loss: 1.476187
Train Epoch: 0 [360/766 (47%)]	Loss: 1.755865
Train Epoch: 0 [370/766 (48%)]	Loss: 1.718418
Train Epoch: 0 [380/766 (50%)]	Loss: 1.390453
Train Epoch: 0 [390/766 (51%)]	Loss: 1.609285
Train Epoch: 0 [400/766 (52%)]	Loss: 1.508573
Train Epoch: 0 [410/766 (54%)]	Loss: 1.486357
Train Epoch: 0 [420/766 (55%)]	Loss: 1.692045
Train Epoch: 0 [430/766 (56%)]	Loss: 1.495913
Train Epoch: 0 [440/766 (57%)]	Loss: 1.688043
Train Epoch: 0 [450/766 (59%)]	Loss: 1.500163
Train Epoch: 0 [460/766 (60%)]	Loss: 1.532048
Train Epoch: 0 [470/766 (61%)]	Loss: 1.780613
Train Epoch: 0 [480/766 (63%)]	Loss: 1.482994
Train Epoch: 0 [490/766 (64%)]	Loss: 1.345236
Train Epoch: 0 [500/766 (65%)]	Loss: 1.410739
Train Epoch: 0 [510/766 (67%)]	Loss: 1.459507
Train Epoch: 0 [520/766 (68%)]	Loss: 1.789894
Train Epoch: 0 [530/766 (69%)]	Loss: 1.479056
Train Epoch: 0 [540/766 (70%)]	Loss: 1.319969
Train Epoch: 0 [550/766 (72%)]	Loss: 1.776336
Train Epoch: 0 [560/766 (73%)]	Loss: 1.266944
Train Epoch: 0 [570/766 (74%)]	Loss: 1.530437
Train Epoch: 0 [580/766 (76%)]	Loss: 1.674438
Train Epoch: 0 [590/766 (77%)]	Loss: 1.614731
Train Epoch: 0 [600/766 (78%)]	Loss: 1.559749
Train Epoch: 0 [610/766 (80%)]	Loss: 1.461927
Train Epoch: 0 [620/766 (81%)]	Loss: 1.199259
Train Epoch: 0 [630/766 (82%)]	Loss: 1.775823
Train Epoch: 0 [640/766 (84%)]	Loss: 1.638302
Train Epoch: 0 [650/766 (85%)]	Loss: 1.037801
Train Epoch: 0 [660/766 (86%)]	Loss: 1.546026
Train Epoch: 0 [670/766 (87%)]	Loss: 1.183563
Train Epoch: 0 [680/766 (89%)]	Loss: 1.571771
Train Epoch: 0 [690/766 (90%)]	Loss: 1.238146
Train Epoch: 0 [700/766 (91%)]	Loss: 1.343132
Train Epoch: 0 [710/766 (93%)]	Loss: 1.268762
Train Epoch: 0 [720/766 (94%)]	Loss: 1.427858
Train Epoch: 0 [730/766 (95%)]	Loss: 1.425199
Train Epoch: 0 [740/766 (97%)]	Loss: 1.204324
Train Epoch: 0 [750/766 (98%)]	Loss: 1.215628
Train Epoch: 0 [760/766 (99%)]	Loss: 1.360539
Test Epoch: 0 [0/32 (0%)]	Acc: 0.062500
Test Epoch: 0 [1/32 (3%)]	Acc: 0.093750
Test Epoch: 0 [2/32 (6%)]	Acc: 0.156250
Test Epoch: 0 [3/32 (9%)]	Acc: 0.031250
Test Epoch: 0 [4/32 (12%)]	Acc: 0.187500
Test Epoch: 0 [5/32 (16%)]	Acc: 0.093750
Test Epoch: 0 [6/32 (19%)]	Acc: 0.125000
Test Epoch: 0 [7/32 (22%)]	Acc: 0.093750
Test Epoch: 0 [8/32 (25%)]	Acc: 0.062500
Test Epoch: 0 [9/32 (28%)]	Acc: 0.125000
Test Epoch: 0 [10/32 (31%)]	Acc: 0.093750
Test Epoch: 0 [11/32 (34%)]	Acc: 0.093750
Test Epoch: 0 [12/32 (38%)]	Acc: 0.093750
Test Epoch: 0 [13/32 (41%)]	Acc: 0.125000
Test Epoch: 0 [14/32 (44%)]	Acc: 0.156250
Test Epoch: 0 [15/32 (47%)]	Acc: 0.125000
Test Epoch: 0 [16/32 (50%)]	Acc: 0.000000
Test Epoch: 0 [17/32 (53%)]	Acc: 0.125000
Test Epoch: 0 [18/32 (56%)]	Acc: 0.156250
Test Epoch: 0 [19/32 (59%)]	Acc: 0.187500
Test Epoch: 0 [20/32 (62%)]	Acc: 0.062500
Test Epoch: 0 [21/32 (66%)]	Acc: 0.093750
Test Epoch: 0 [22/32 (69%)]	Acc: 0.062500
Test Epoch: 0 [23/32 (72%)]	Acc: 0.093750
Test Epoch: 0 [24/32 (75%)]	Acc: 0.218750
Test Epoch: 0 [25/32 (78%)]	Acc: 0.125000
Test Epoch: 0 [26/32 (81%)]	Acc: 0.156250
Test Epoch: 0 [27/32 (84%)]	Acc: 0.031250
Test Epoch: 0 [28/32 (88%)]	Acc: 0.187500
Test Epoch: 0 [29/32 (91%)]	Acc: 0.125000
Test Epoch: 0 [30/32 (94%)]	Acc: 0.156250
Test Epoch: 0 [31/32 (97%)]	Acc: 0.000000
Total test acc = 0.112
Train Epoch: 1 [0/766 (0%)]	Loss: 1.278104
Train Epoch: 1 [10/766 (1%)]	Loss: 1.445922
Train Epoch: 1 [20/766 (3%)]	Loss: 1.309801
Train Epoch: 1 [30/766 (4%)]	Loss: 1.511448
Train Epoch: 1 [40/766 (5%)]	Loss: 1.046027
Train Epoch: 1 [50/766 (7%)]	Loss: 1.019361
Train Epoch: 1 [60/766 (8%)]	Loss: 1.206879
Train Epoch: 1 [70/766 (9%)]	Loss: 1.339458
Train Epoch: 1 [80/766 (10%)]	Loss: 1.096838
Train Epoch: 1 [90/766 (12%)]	Loss: 1.282275
Train Epoch: 1 [100/766 (13%)]	Loss: 1.315636
Train Epoch: 1 [110/766 (14%)]	Loss: 1.093785
Train Epoch: 1 [120/766 (16%)]	Loss: 1.150581
Train Epoch: 1 [130/766 (17%)]	Loss: 1.378615
Train Epoch: 1 [140/766 (18%)]	Loss: 1.184623
Train Epoch: 1 [150/766 (20%)]	Loss: 1.092789
Train Epoch: 1 [160/766 (21%)]	Loss: 1.324679
Train Epoch: 1 [170/766 (22%)]	Loss: 1.350374
Train Epoch: 1 [180/766 (23%)]	Loss: 1.350134
Train Epoch: 1 [190/766 (25%)]	Loss: 1.318016
Train Epoch: 1 [200/766 (26%)]	Loss: 1.345922
Train Epoch: 1 [210/766 (27%)]	Loss: 1.395676
Train Epoch: 1 [220/766 (29%)]	Loss: 1.241677
Train Epoch: 1 [230/766 (30%)]	Loss: 1.053897
Train Epoch: 1 [240/766 (31%)]	Loss: 0.971859
Train Epoch: 1 [250/766 (33%)]	Loss: 1.124782
Train Epoch: 1 [260/766 (34%)]	Loss: 1.260339
Train Epoch: 1 [270/766 (35%)]	Loss: 1.219548
Train Epoch: 1 [280/766 (37%)]	Loss: 1.299369
Train Epoch: 1 [290/766 (38%)]	Loss: 1.213223
Train Epoch: 1 [300/766 (39%)]	Loss: 1.223816
Train Epoch: 1 [310/766 (40%)]	Loss: 1.175861
Train Epoch: 1 [320/766 (42%)]	Loss: 0.927709
Train Epoch: 1 [330/766 (43%)]	Loss: 1.400868
Train Epoch: 1 [340/766 (44%)]	Loss: 1.187871
Train Epoch: 1 [350/766 (46%)]	Loss: 1.214141
Train Epoch: 1 [360/766 (47%)]	Loss: 1.217095
Train Epoch: 1 [370/766 (48%)]	Loss: 0.985206
Train Epoch: 1 [380/766 (50%)]	Loss: 1.132003
Train Epoch: 1 [390/766 (51%)]	Loss: 1.066329
Train Epoch: 1 [400/766 (52%)]	Loss: 1.305349
Train Epoch: 1 [410/766 (54%)]	Loss: 1.225419
Train Epoch: 1 [420/766 (55%)]	Loss: 1.303159
Train Epoch: 1 [430/766 (56%)]	Loss: 0.998916
Train Epoch: 1 [440/766 (57%)]	Loss: 1.346875
Train Epoch: 1 [450/766 (59%)]	Loss: 1.254465
Train Epoch: 1 [460/766 (60%)]	Loss: 0.976315
Train Epoch: 1 [470/766 (61%)]	Loss: 1.451340
Train Epoch: 1 [480/766 (63%)]	Loss: 1.112767
Train Epoch: 1 [490/766 (64%)]	Loss: 1.305727
Train Epoch: 1 [500/766 (65%)]	Loss: 1.235950
Train Epoch: 1 [510/766 (67%)]	Loss: 1.148782
Train Epoch: 1 [520/766 (68%)]	Loss: 1.172709
Train Epoch: 1 [530/766 (69%)]	Loss: 1.142372
Train Epoch: 1 [540/766 (70%)]	Loss: 1.151231
Train Epoch: 1 [550/766 (72%)]	Loss: 0.951001
Train Epoch: 1 [560/766 (73%)]	Loss: 1.036463
Train Epoch: 1 [570/766 (74%)]	Loss: 1.361221
Train Epoch: 1 [580/766 (76%)]	Loss: 1.224620
Train Epoch: 1 [590/766 (77%)]	Loss: 1.237411
Train Epoch: 1 [600/766 (78%)]	Loss: 0.933225
Train Epoch: 1 [610/766 (80%)]	Loss: 0.970147
Train Epoch: 1 [620/766 (81%)]	Loss: 1.113803
Train Epoch: 1 [630/766 (82%)]	Loss: 1.140202
Train Epoch: 1 [640/766 (84%)]	Loss: 1.160761
Train Epoch: 1 [650/766 (85%)]	Loss: 1.263138
Train Epoch: 1 [660/766 (86%)]	Loss: 1.176221
Train Epoch: 1 [670/766 (87%)]	Loss: 1.306003
Train Epoch: 1 [680/766 (89%)]	Loss: 1.221295
Train Epoch: 1 [690/766 (90%)]	Loss: 1.152263
Train Epoch: 1 [700/766 (91%)]	Loss: 1.039294
Train Epoch: 1 [710/766 (93%)]	Loss: 1.129845
Train Epoch: 1 [720/766 (94%)]	Loss: 1.092619
Train Epoch: 1 [730/766 (95%)]	Loss: 1.249819
Train Epoch: 1 [740/766 (97%)]	Loss: 1.146910
Train Epoch: 1 [750/766 (98%)]	Loss: 1.193693
Train Epoch: 1 [760/766 (99%)]	Loss: 1.219156
Test Epoch: 1 [0/32 (0%)]	Acc: 0.218750
Test Epoch: 1 [1/32 (3%)]	Acc: 0.343750
Test Epoch: 1 [2/32 (6%)]	Acc: 0.375000
Test Epoch: 1 [3/32 (9%)]	Acc: 0.187500
Test Epoch: 1 [4/32 (12%)]	Acc: 0.343750
Test Epoch: 1 [5/32 (16%)]	Acc: 0.375000
Test Epoch: 1 [6/32 (19%)]	Acc: 0.281250
Test Epoch: 1 [7/32 (22%)]	Acc: 0.250000
Test Epoch: 1 [8/32 (25%)]	Acc: 0.312500
Test Epoch: 1 [9/32 (28%)]	Acc: 0.375000
Test Epoch: 1 [10/32 (31%)]	Acc: 0.343750
Test Epoch: 1 [11/32 (34%)]	Acc: 0.281250
Test Epoch: 1 [12/32 (38%)]	Acc: 0.281250
Test Epoch: 1 [13/32 (41%)]	Acc: 0.406250
Test Epoch: 1 [14/32 (44%)]	Acc: 0.218750
Test Epoch: 1 [15/32 (47%)]	Acc: 0.281250
Test Epoch: 1 [16/32 (50%)]	Acc: 0.343750
Test Epoch: 1 [17/32 (53%)]	Acc: 0.156250
Test Epoch: 1 [18/32 (56%)]	Acc: 0.187500
Test Epoch: 1 [19/32 (59%)]	Acc: 0.312500
Test Epoch: 1 [20/32 (62%)]	Acc: 0.156250
Test Epoch: 1 [21/32 (66%)]	Acc: 0.156250
Test Epoch: 1 [22/32 (69%)]	Acc: 0.156250
Test Epoch: 1 [23/32 (72%)]	Acc: 0.312500
Test Epoch: 1 [24/32 (75%)]	Acc: 0.312500
Test Epoch: 1 [25/32 (78%)]	Acc: 0.281250
Test Epoch: 1 [26/32 (81%)]	Acc: 0.343750
Test Epoch: 1 [27/32 (84%)]	Acc: 0.125000
Test Epoch: 1 [28/32 (88%)]	Acc: 0.250000
Test Epoch: 1 [29/32 (91%)]	Acc: 0.250000
Test Epoch: 1 [30/32 (94%)]	Acc: 0.250000
Test Epoch: 1 [31/32 (97%)]	Acc: 0.375000
Total test acc = 0.274
Train Epoch: 2 [0/766 (0%)]	Loss: 0.916981
Train Epoch: 2 [10/766 (1%)]	Loss: 1.244192
Train Epoch: 2 [20/766 (3%)]	Loss: 1.136918
Train Epoch: 2 [30/766 (4%)]	Loss: 1.019136
Train Epoch: 2 [40/766 (5%)]	Loss: 1.452216
Train Epoch: 2 [50/766 (7%)]	Loss: 1.156905
Train Epoch: 2 [60/766 (8%)]	Loss: 1.207823
Train Epoch: 2 [70/766 (9%)]	Loss: 0.989111
Train Epoch: 2 [80/766 (10%)]	Loss: 0.888812
Train Epoch: 2 [90/766 (12%)]	Loss: 1.165309
Train Epoch: 2 [100/766 (13%)]	Loss: 1.022980
Train Epoch: 2 [110/766 (14%)]	Loss: 1.035037
Train Epoch: 2 [120/766 (16%)]	Loss: 0.995792
Train Epoch: 2 [130/766 (17%)]	Loss: 1.143890
Train Epoch: 2 [140/766 (18%)]	Loss: 0.911665
Train Epoch: 2 [150/766 (20%)]	Loss: 0.864427
Train Epoch: 2 [160/766 (21%)]	Loss: 1.143590
Train Epoch: 2 [170/766 (22%)]	Loss: 1.085069
Train Epoch: 2 [180/766 (23%)]	Loss: 1.176068
Train Epoch: 2 [190/766 (25%)]	Loss: 1.120552
Train Epoch: 2 [200/766 (26%)]	Loss: 1.087845
Train Epoch: 2 [210/766 (27%)]	Loss: 0.992598
Train Epoch: 2 [220/766 (29%)]	Loss: 0.756417
Caught segfault at address 0xb8f4f170, flush log...
stack trace for /usr/bin/python3.7 pid=77488
[New LWP 77530]
[New LWP 77638]
[New LWP 77652]
[New LWP 77653]
[New LWP 77654]
[New LWP 77655]
[New LWP 77656]
[New LWP 77657]
[New LWP 77658]
[New LWP 77659]
[New LWP 77660]
[New LWP 77661]
[New LWP 77662]
[New LWP 77663]
[New LWP 77664]
[New LWP 77665]
[New LWP 77666]
[New LWP 77667]
[New LWP 77668]
[New LWP 77669]
[New LWP 77670]
[New LWP 77671]
[New LWP 77672]
[New LWP 77673]
[New LWP 77674]
[New LWP 77675]
[New LWP 77676]
[New LWP 77677]
[New LWP 77678]
[New LWP 77679]
[New LWP 77680]
[New LWP 77681]
[New LWP 77682]
[New LWP 77683]
[New LWP 77684]
[New LWP 77685]
[New LWP 77686]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
0x00007f35e93926c2 in __GI___waitpid (pid=78009, stat_loc=0x0, options=0) at ../sysdeps/unix/sysv/linux/waitpid.c:30
30	../sysdeps/unix/sysv/linux/waitpid.c: No such file or directory.
[Current thread is 1 (Thread 0x7f35e98b7740 (LWP 77488))]
#0  0x00007f35e93926c2 in __GI___waitpid (pid=78009, stat_loc=0x0, options=0) at ../sysdeps/unix/sysv/linux/waitpid.c:30
#1  0x00007f35e47637c2 in jittor::print_trace() () from /root/.cache/jittor/default/g++/jit_utils_core.so
#2  0x00007f35e475cf45 in jittor::segfault_sigaction(int, siginfo_t*, void*) () from /root/.cache/jittor/default/g++/jit_utils_core.so
#3  <signal handler called>
#4  0x00007f35df3c9ec6 in jittor::CachingBlockPool::get_occupied(unsigned long) () from /root/.cache/jittor/default/g++/jittor_core.so
#5  0x00007f35df3cb4a7 in jittor::SFRLAllocator::free(void*, unsigned long, unsigned long const&) () from /root/.cache/jittor/default/g++/jittor_core.so
#6  0x00007f35df4190a3 in jittor::ArrayOp::ArrayOp(jittor::ArrayArgs&&) () from /root/.cache/jittor/default/g++/jittor_core.so
#7  0x00007f35df36aee0 in jittor::jit_op_maker::make_array_(jittor::ArrayArgs&&) () from /root/.cache/jittor/default/g++/jittor_core.so
#8  0x00007f35df36b114 in jittor::jit_op_maker::array_(jittor::ArrayArgs&&) () from /root/.cache/jittor/default/g++/jittor_core.so
#9  0x00007f35df3b83be in std::enable_if<std::is_same<jittor::VarHolder*, jittor::VarHolder*>::value, jittor::VarHolder*>::type jittor::from_py_object<jittor::VarHolder*>(_object*, std::unique_ptr<jittor::VarHolder, std::default_delete<jittor::VarHolder> >&) () from /root/.cache/jittor/default/g++/jittor_core.so
Segfault, exit

I met this Segment Fault when I run the Cifar10 datasets on CNN, the code of my modle is:

import jittor as jt
from jittor import nn, Module
import numpy as np
import sys, os
import random
import math
from jittor import init


class CIFAR10_FAST_MODEL(nn.Module):
    def __init__(self):
        super(CIFAR10_FAST_MODEL, self).__init__()
        self.conv1_1 = nn.Conv(3, 32, kernel_size=3, padding=1)
        self.conv1_2 = nn.Conv(32, 32, kernel_size=3, padding=1)
        self.pool1 = nn.Pool(kernel_size=2, stride=2, op='maximum')
        self.dropout1 = nn.Dropout(p=0.2)
        self.bn32 = nn.BatchNorm(32)
        self.conv2_1 = nn.Conv(32, 64, kernel_size=3, padding=1)
        self.conv2_2 = nn.Conv(64, 64, kernel_size=3, padding=1)
        self.pool2 = nn.Pool(kernel_size=2, stride=2, op='maximum')
        self.dropout2 = nn.Dropout(p=0.3)
        self.bn64 = nn.BatchNorm(64)
        self.conv3_1 = nn.Conv(64, 128, kernel_size=3, padding=1)
        self.conv3_2 = nn.Conv(128, 128, kernel_size=3, padding=1)
        self.pool3 = nn.Pool(kernel_size=2, stride=2, op='maximum')
        self.dropout3 = nn.Dropout(p=0.4)
        self.bn128 = nn.BatchNorm(128)
        self.relu = nn.Relu()
        self.fc1 = nn.Linear (2048, 10)


    def execute(self, image):
        out = nn.relu(self.conv1_1(image))
        out = self.bn32(out)
        out = nn.relu(self.conv1_2(out))
        out = self.bn32(out)
        out = self.pool1(out)
        out = self.dropout1(out)
        out = nn.relu(self.conv2_1(out))
        out = self.bn64(out)
        out = nn.relu(self.conv2_2(out))
        out = self.bn64(out)
        out = self.pool2(out)
        out = self.dropout2(out)
        out = nn.relu(self.conv3_1(out))
        out = self.bn128(out)
        out = nn.relu(self.conv3_2(out))
        out = self.bn128(out)
        out = self.pool3(out)
        out = self.dropout3(out)

        x = jt.reshape(out, [out.shape[0], -1])
        # print("x's shape: ", np.shape(x))
        x = self.fc1(x)
        return x

运行测试代码报错。 | Get some errors when running the test code.

image

[w 0321 11:27:39.879968 56 compile_extern.py:130] CUDA found but cudnn is not loaded:
Traceback (most recent call last):
  File "/data/py37/lib/python3.7/site-packages/jittor/compile_extern.py", line 126, in setup_cuda_extern
    setup_cuda_lib(lib_name)
  File "/data/py37/lib/python3.7/site-packages/jittor/compile_extern.py", line 143, in setup_cuda_lib
    cuda_include_name = search_file([cuda_include, "/usr/include"], lib_name+".h")
  File "/data/py37/lib/python3.7/site-packages/jittor/compile_extern.py", line 16, in search_file
    LOG.f(f"file {name} not found in {dirs}")
  File "/data/py37/lib/python3.7/site-packages/jittor_utils/__init__.py", line 55, in f
    def f(self, *msg): self._log('f', 0, *msg)
  File "/data/py37/lib/python3.7/site-packages/jittor_utils/__init__.py", line 40, in _log
    cc.log(fileline, level, verbose, msg)
RuntimeError: [f 0321 11:27:39.879776 56 compile_extern.py:16] file cudnn.h not found in ['/usr/local/cuda/include', '/usr/include']

Support python3.6

Guys, awesome job!
Is there any plan for supporting python3.6? Much thanks.

Some questions wanna disscuss

Hi,

Nice work! after went thru the code, some questions want to ask,

  • How to lower ops like batchnorm to meta ops, tf xla has tf2xla phase to lower big op into a group of meta ops, I don't see the related code in jittor for this, do I miss anything here?

  • How many ops is using meta ops, how many is supported by extern library? take restnet50 as example.

  • How to do auto schedule for ops like conv, gemm, could you elaborate with a specfic case?

Thanks!

与torch可能存在冲突

在如下代码:

import jittor as jt
import torch

中会报munmap_chunk(): invalid pointer错误
若是交换import顺序则不会报错。

sample code can not run

The sample code in README.md can not run, it lacks of some lines, eg,

  • import numpy as np
  • batch_size = 10
  • n = 10

AttributeError: module 'os' has no attribute 'RTLD_DEEPBIND'

os: mac os
log:

import jittor
[i 0320 17:51:07.925814 12 v1 init.py:102] Run cmd: which g++
[i 0320 17:51:07.936802 12 v1 init.py:102] Run cmd: /usr/bin/g++ --version
[i 0320 17:51:08.182412 12 init.py:183] Found g++(17.7.0) at /usr/bin/g++.
[i 0320 17:51:08.193914 12 v1 init.py:102] Run cmd: git branch
fatal: 不是一个 git 仓库(或者任何父目录):.git
Traceback (most recent call last):
File "", line 1, in
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/jittor-1.0.0-py3.6.egg/jittor/init.py", line 10, in
from . import compiler
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/jittor-1.0.0-py3.6.egg/jittor/compiler.py", line 755, in
import_flags = os.RTLD_NOW | os.RTLD_GLOBAL | os.RTLD_DEEPBIND
AttributeError: module 'os' has no attribute 'RTLD_DEEPBIND'

question in meta op example

I visited this project web, and found the code:

shape = [N,H+Kh-1,W+Kw-1,Kh,Kw,C,Kc]
#  expansion of x.reindex
xx = np.zeros(shape, x.dtype)
for i0 in range(shape[0]):
    for i1 in range(shape[1]):
        for i2 in range(shape[2]):
            for i3 in range(shape[3]):
                for i4 in range(shape[4]):
                    for i5 in range(shape[5]):
                        for i6 in range(shape[6]):
                            if is_overflow(i0,i1,i2,i3,i4,i5,i6):
                                y[i0,i1,...,in] = 0
                            else:
                                y[i0,i1,i2,i3,i4,i5,i6] = x[i0,i1+i3,i2+i4,i5]

#  expansion of w.broadcast_var(xx)
ww = np.zeros(shape, x.dtype)
for i0 in range(shape[0]):
    for i1 in range(shape[1]):
        for i2 in range(shape[2]):
            for i3 in range(shape[3]):
                for i4 in range(shape[4]):
                    for i5 in range(shape[5]):
                        for i6 in range(shape[6]):
                            ww[i0,i1,i2,i3,i4,i5,i6] = w[i3,i4,i5,i6]
#  expansion of xx*ww
yy = np.zeros(shape, x.dtype)
for i0 in range(shape[0]):
    for i1 in range(shape[1]):
        for i2 in range(shape[2]):
            for i3 in range(shape[3]):
                for i4 in range(shape[4]):
                    for i5 in range(shape[5]):
                        for i6 in range(shape[6]):
                            yy[i0,i1,i2,i3,i4,i5,i6] = xx[i0,i1,i2,i3,i4,i5,i6] * ww[i0,i1,i2,i3,i4,i5,i6]
#  expansion of yy.sum([3,4,5])
shape2 = [N,H-Kh+1,W-Kw+1,Kc]
y = np.zeros(shape2, x.dtype)
for i0 in range(shape[0]):
    for i1 in range(shape[1]):
        for i2 in range(shape[2]):
            for i3 in range(shape[3]):
                for i4 in range(shape[4]):
                    for i5 in range(shape[5]):
                        for i6 in range(shape[6]):
                            y[i0,i1,i2,i6] += yy[i0,i1,i2,i3,i4,i5,i6]`

why the expanded code equals to the fellowing code? any writring mistakes?

shape2 = [N,H-Kh+1,W-Kw+1,Kc]
y = np.zeros(shape2, x.dtype)
for i0 in range(shape[0]):
    for i1 in range(shape[1]):
        for i2 in range(shape[2]):
            for i3 in range(shape[3]):
                for i4 in range(shape[4]):
                    for i5 in range(shape[5]):
                        for i6 in range(shape[6]):
                            if not is_overflow(i0,i1,i2,i3,i4,i5,i6):
                                y[i0,i1,i2,i6] += x[i0,i1+i3,i2+i4,i5]`

import jittor as jt 过程中运行git branch这个设定真是鸡肋

import jittor as jt 过程中运行git branch这个设定真是鸡肋,怎样去掉?如下是import jittor as jt 过程中的输出:
[i 0421 10:18:02.257445 28 v1 init.py:102] Run cmd: which g++
[i 0421 10:18:02.260915 28 v1 init.py:102] Run cmd: /usr/bin/g++ --version
[i 0421 10:18:02.265384 28 init.py:183] Found g++(9.3.0) at /usr/bin/g++.
[i 0421 10:18:02.267761 28 v1 init.py:102] Run cmd: git branch
fatal: 不是一个 git 仓库(或者直至挂载点 / 的任何父目录)
停止在文件系统边界(未设置 GIT_DISCOVERY_ACROSS_FILESYSTEM)。

CUDA配置问题

我用的是服务器,有GPU。由于没有管理员权限,有些东西配置不了,不过我可以正常安装使用Pytorch还有tensorflow的GPU操作等,希望进一步提升,安装的时候可以考虑到没有管理员权限情况。
image

怎么在windows上安装jittor?

你好,我今天尝试在windows10上安装jittor,但是多次尝试都失败了,请问一下如何在windows系统上正确安装jittor

原子加法有概率无法触发

256x256的输入,size=3;stride=padding=1的一层pool,把pool的结果求和作为loss,对x求导,对导数求和,应该为65536,但是结果不对,应该是因为atomicAdd没有触发导致的。

can not install llvm

I followed the install instruction to install llvm on Ubuntu 16.04 but failed with

Ign:27 http://ppa.launchpad.net/mc3man/trusty-media/ubuntu xenial/main i386 Packages
Ign:28 http://ppa.launchpad.net/mc3man/trusty-media/ubuntu xenial/main all Packages
Ign:29 http://ppa.launchpad.net/mc3man/trusty-media/ubuntu xenial/main Translation-en_US
Ign:30 http://ppa.launchpad.net/mc3man/trusty-media/ubuntu xenial/main Translation-en
Ign:31 http://ppa.launchpad.net/mc3man/trusty-media/ubuntu xenial/main amd64 DEP-11 Metadata
Ign:32 http://ppa.launchpad.net/mc3man/trusty-media/ubuntu xenial/main DEP-11 64x64 Icons
Ign:33 http://ppa.launchpad.net/jonathonf/python-3.6/ubuntu xenial/main amd64 Packages
Ign:34 http://ppa.launchpad.net/jonathonf/python-3.6/ubuntu xenial/main i386 Packages
Ign:21 http://ppa.launchpad.net/jonathonf/python-3.6/ubuntu xenial/main all Packages
Ign:22 http://ppa.launchpad.net/jonathonf/python-3.6/ubuntu xenial/main Translation-en_US
Ign:35 http://ppa.launchpad.net/jonathonf/python-3.6/ubuntu xenial/main Translation-en
Ign:24 http://ppa.launchpad.net/jonathonf/python-3.6/ubuntu xenial/main amd64 DEP-11 Metadata
Ign:25 http://ppa.launchpad.net/jonathonf/python-3.6/ubuntu xenial/main DEP-11 64x64 Icons
Err:26 http://ppa.launchpad.net/mc3man/trusty-media/ubuntu xenial/main amd64 Packages
  404  Not Found [IP: 2001:67c:1560:8008::15 80]
Ign:27 http://ppa.launchpad.net/mc3man/trusty-media/ubuntu xenial/main i386 Packages
Ign:28 http://ppa.launchpad.net/mc3man/trusty-media/ubuntu xenial/main all Packages
Ign:29 http://ppa.launchpad.net/mc3man/trusty-media/ubuntu xenial/main Translation-en_US
Ign:30 http://ppa.launchpad.net/mc3man/trusty-media/ubuntu xenial/main Translation-en
Ign:31 http://ppa.launchpad.net/mc3man/trusty-media/ubuntu xenial/main amd64 DEP-11 Metadata
Ign:32 http://ppa.launchpad.net/mc3man/trusty-media/ubuntu xenial/main DEP-11 64x64 Icons
Err:33 http://ppa.launchpad.net/jonathonf/python-3.6/ubuntu xenial/main amd64 Packages
  403  Forbidden [IP: 2001:67c:1560:8008::15 80]
Ign:34 http://ppa.launchpad.net/jonathonf/python-3.6/ubuntu xenial/main i386 Packages
Ign:35 http://ppa.launchpad.net/jonathonf/python-3.6/ubuntu xenial/main Translation-en
Reading package lists... Done
W: The repository 'http://ppa.launchpad.net/jonathonf/python-3.6/ubuntu xenial Release' does not have a Release file.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: The repository 'http://ppa.launchpad.net/mc3man/trusty-media/ubuntu xenial Release' does not have a Release file.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: Failed to fetch http://ppa.launchpad.net/mc3man/trusty-media/ubuntu/dists/xenial/main/binary-amd64/Packages  404  Not Found [IP: 2001:67c:1560:8008::15 80]
E: Failed to fetch http://ppa.launchpad.net/jonathonf/python-3.6/ubuntu/dists/xenial/main/binary-amd64/Packages  403  Forbidden [IP: 2001:67c:1560:8008::15 80]
E: Some index files failed to download. They have been ignored, or old ones used instead.

How to solve this problem?

AttributeError: module 'os' has no attribute 'RTLD_DEEPBIND'

os: mac os
log:

import jittor
[i 0320 17:51:07.925814 12 v1 init.py:102] Run cmd: which g++
[i 0320 17:51:07.936802 12 v1 init.py:102] Run cmd: /usr/bin/g++ --version
[i 0320 17:51:08.182412 12 init.py:183] Found g++(17.7.0) at /usr/bin/g++.
[i 0320 17:51:08.193914 12 v1 init.py:102] Run cmd: git branch
fatal: 不是一个 git 仓库(或者任何父目录):.git
Traceback (most recent call last):
File "", line 1, in
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/jittor-1.0.0-py3.6.egg/jittor/init.py", line 10, in
from . import compiler
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/jittor-1.0.0-py3.6.egg/jittor/compiler.py", line 755, in
import_flags = os.RTLD_NOW | os.RTLD_GLOBAL | os.RTLD_DEEPBIND
AttributeError: module 'os' has no attribute 'RTLD_DEEPBIND'

模型训练和预测时间不正常

1.模型(ResNet)代码:

import jittor as jt
from jittor import nn
from jittor import Module
from jittor import init
from jittor.contrib import concat, argmax_pool
import time

__all__ = ["ResNet", "ResNet18", "ResNet34", "ResNet50", "ResNet101", "ResNet152"]


class BasicBlock(Module):
    expansion = 1

    def __init__(self, inplanes, planes, stride=1, downsample=None):
        self.conv1 = nn.Conv(inplanes, planes, kernel_size=3, stride=stride, padding=1, bias=False)
        self.bn1 = nn.BatchNorm(planes)
        self.relu = nn.Relu()
        self.conv2 = nn.Conv(planes, planes, kernel_size=3, stride=1, padding=1, bias=False)
        self.bn2 = nn.BatchNorm(planes)
        self.downsample = downsample
        self.stride = stride
        self.planes = planes

    def execute(self, x):
        residual = x
        out = self.conv1(x)
        out = self.bn1(out)
        out = self.relu(out)
        out = self.conv2(out)
        out = self.bn2(out)

        if self.downsample is not None:
            residual = self.downsample(x)

        out += residual
        out = self.relu(out)
        return out


class Bottleneck(Module):
    expansion = 4

    def __init__(self, inplanes, planes, stride=1, downsample=None):
        self.conv1 = nn.Conv(inplanes, planes, kernel_size=1, bias=False)
        self.bn1 = nn.BatchNorm(planes)
        self.conv2 = nn.Conv(planes, planes, kernel_size=3, stride=stride, padding=1, bias=False)
        self.bn2 = nn.BatchNorm(planes)
        self.conv3 = nn.Conv(planes, planes * self.expansion, kernel_size=1, bias=False)
        self.bn3 = nn.BatchNorm(planes * self.expansion)
        self.relu = nn.Relu()
        self.downsample = downsample
        self.stride = stride

    def execute(self, x):
        residual = x

        out = self.conv1(x)
        out = self.bn1(out)
        out = self.relu(out)

        out = self.conv2(out)
        out = self.bn2(out)
        out = self.relu(out)

        out = self.conv3(out)
        out = self.bn3(out)

        if self.downsample is not None:
            residual = self.downsample(x)

        out += residual
        out = self.relu(out)
        return out


class ResNet(Module):
    def __init__(self, block, layers, num_classes=1000):
        self.inplanes = 64
        self.conv1 = nn.Conv(3, 64, kernel_size=7, stride=2, padding=3, bias=False)
        self.bn1 = nn.BatchNorm(64)
        self.relu = nn.Relu()
        self.maxpool = nn.Pool(kernel_size=3, stride=2, padding=1)
        self.layer1 = self._make_layer(block, 64, layers[0])
        self.layer2 = self._make_layer(block, 128, layers[1], stride=2)
        self.layer3 = self._make_layer(block, 256, layers[2], stride=2)
        self.layer4 = self._make_layer(block, 512, layers[3], stride=2)
        self.avgpool = nn.Pool(7, stride=1, op="mean")
        self.fc = nn.Linear(512 * block.expansion, num_classes)

    def _make_layer(self, block, planes, blocks, stride=1):
        downsample = None
        if stride != 1 or self.inplanes != planes * block.expansion:
            downsample = nn.Sequential(
                nn.Conv(self.inplanes, planes * block.expansion,
                        kernel_size=1, stride=stride, bias=False),
                nn.BatchNorm(planes * block.expansion),
            )

        layers = []
        layers.append(block(self.inplanes, planes, stride, downsample))
        self.inplanes = planes * block.expansion
        for i in range(1, blocks):
            layers.append(block(self.inplanes, planes))

        return nn.Sequential(*layers)

    def execute(self, x):
        x = self.conv1(x)
        x = self.bn1(x)
        x = self.relu(x)
        x = self.maxpool(x)
        x = self.layer1(x)
        x = self.layer2(x)
        x = self.layer3(x)
        x = self.layer4(x)

        x = self.avgpool(x)
        x = jt.reshape(x, [x.shape[0], -1])
        x = self.fc(x)

        return x


def ResNet18():
    model = ResNet(BasicBlock, [2, 2, 2, 2])
    return model


def ResNet34():
    model = ResNet(BasicBlock, [3, 4, 6, 3])
    return model


def ResNet50():
    model = ResNet(Bottleneck, [3, 4, 6, 3])
    return model


def ResNet101():
    model = ResNet(Bottleneck, [3, 4, 23, 3])
    return model


def ResNet152():
    model = ResNet(Bottleneck, [3, 8, 36, 3])
    return model

2.模型VGG代码

# ***************************************************************
# Copyright (c) 2020 Jittor. Authors:
#     Guoye Yang <[email protected]>
#     Dun Liang <[email protected]>.
# All Rights Reserved.
# This file is subject to the terms and conditions defined in
# file 'LICENSE.txt', which is part of this source code package.
# ***************************************************************
import jittor as jt
from jittor import nn


__all__ = ['VGG', 'VGG11', 'VGG11_bn', 'VGG13', 'VGG13_bn', 'VGG16', 'VGG16_bn',
    'VGG19_bn', 'VGG19']


class VGG(nn.Module):

    def __init__(self, features, num_classes=1000, init_weights=True):
        super(VGG, self).__init__()
        self.features = features
        self.classifier = nn.Sequential(
            nn.Linear(512 * 7 * 7, 4096),
            nn.ReLU(),
            nn.Dropout(),
            nn.Linear(4096, 4096),
            nn.ReLU(),
            nn.Dropout(),
            nn.Linear(4096, num_classes),
        )

    def execute(self, x):
        x = self.features(x)
        x = jt.reshape(x, [x.shape[0],-1])
        x = self.classifier(x)
        return x

def make_layers(cfg, batch_norm=False):
    layers = []
    in_channels = 3
    for v in cfg:
        if v == 'M':
            layers += [nn.Pool(kernel_size=2, stride=2, op="maximum")]
        else:
            conv2d = nn.Conv(in_channels, v, kernel_size=3, padding=1)
            if batch_norm:
                layers += [conv2d, nn.BatchNorm(v), nn.ReLU()]
            else:
                layers += [conv2d, nn.ReLU()]
            in_channels = v
    return nn.Sequential(*layers)


cfgs = {
    'A': [64, 'M', 128, 'M', 256, 256, 'M', 512, 512, 'M', 512, 512, 'M'],
    'B': [64, 64, 'M', 128, 128, 'M', 256, 256, 'M', 512, 512, 'M', 512, 512, 'M'],
    'D': [64, 64, 'M', 128, 128, 'M', 256, 256, 256, 'M', 512, 512, 512, 'M', 512, 512, 512, 'M'],
    'E': [64, 64, 'M', 128, 128, 'M', 256, 256, 256, 256, 'M', 512, 512, 512, 512, 'M', 512, 512, 512, 512, 'M'],
}


def _vgg(arch, cfg, batch_norm, **kwargs):
    model = VGG(make_layers(cfgs[cfg], batch_norm=batch_norm), **kwargs)
    return model


def VGG11(**kwargs):
    r"""VGG 11-layer model (configuration "A") from
    `"Very Deep Convolutional Networks For Large-Scale Image Recognition" <https://arxiv.org/pdf/1409.1556.pdf>`_
    """
    return _vgg('vgg11', 'A', False, **kwargs)


def VGG11_bn(**kwargs):
    r"""VGG 11-layer model (configuration "A") with batch normalization
    `"Very Deep Convolutional Networks For Large-Scale Image Recognition" <https://arxiv.org/pdf/1409.1556.pdf>`_
    """
    return _vgg('vgg11_bn', 'A', True, **kwargs)


def VGG13(**kwargs):
    r"""VGG 13-layer model (configuration "B")
    `"Very Deep Convolutional Networks For Large-Scale Image Recognition" <https://arxiv.org/pdf/1409.1556.pdf>`_
    """
    return _vgg('vgg13', 'B', False, **kwargs)


def VGG13_bn(**kwargs):
    r"""VGG 13-layer model (configuration "B") with batch normalization
    `"Very Deep Convolutional Networks For Large-Scale Image Recognition" <https://arxiv.org/pdf/1409.1556.pdf>`_
    """
    return _vgg('vgg13_bn', 'B', True, **kwargs)


def VGG16(**kwargs):
    r"""VGG 16-layer model (configuration "D")
    `"Very Deep Convolutional Networks For Large-Scale Image Recognition" <https://arxiv.org/pdf/1409.1556.pdf>`_
    """
    return _vgg('vgg16', 'D', False, **kwargs)


def VGG16_bn(**kwargs):
    r"""VGG 16-layer model (configuration "D") with batch normalization
    `"Very Deep Convolutional Networks For Large-Scale Image Recognition" <https://arxiv.org/pdf/1409.1556.pdf>`_
    """
    return _vgg('vgg16_bn', 'D', True, **kwargs)


def VGG19(**kwargs):
    r"""VGG 19-layer model (configuration "E")
    `"Very Deep Convolutional Networks For Large-Scale Image Recognition" <https://arxiv.org/pdf/1409.1556.pdf>`_
    """
    return _vgg('vgg19', 'E', False, **kwargs)


def VGG19_bn(**kwargs):
    r"""VGG 19-layer model (configuration 'E') with batch normalization
    `"Very Deep Convolutional Networks For Large-Scale Image Recognition" <https://arxiv.org/pdf/1409.1556.pdf>`_
    """
    return _vgg('vgg19_bn', 'E', True, **kwargs)

3.模型测速代码:

import argparse
import os
import re
import subprocess
import time
import models.resnet as res_models
import models.vgg as vgg_models
import numpy as np
from jittor import nn
import jittor as jt
jt.flags.use_cuda = 1


def parse_args():
    parser = argparse.ArgumentParser()
    parser.add_argument('-a', '--arch', default='ResNet18', type=str)

    parser.add_argument('--batch-size', type=int, default=64)  # 128
    parser.add_argument('--learning-rate', type=float, default=0.025)
    parser.add_argument('--momentum', type=float, default=0.9)
    parser.add_argument('--weight-decay', type=float, default=1e-4)

    parser.add_argument('--dynamic', action='store_true')
    parser.add_argument('--single', action='store_false')
    parser.add_argument('--compiled', action='store_true')
    parser.add_argument('--step', type=int, default=100)

    return parser.parse_args()


def main():
    args = parse_args()
    worker(args)

def worker(args):
    if 'ResNet' in args.arch:
        model = res_models.__dict__[args.arch]()
    elif 'VGG' in args.arch:
        model = vgg_models.__dict__[args.arch]()
    else:
        raise NotImplementedError

    def train_func():
        model.train()

        logits = model(image)
        loss = nn.cross_entropy_loss(logits, label, ignore_index=255)
        optimizer.step(loss)

    def eval_func():
        model.eval()
        logits = model(image)


    image = np.random.random([args.batch_size, 3, 224, 224]).astype(np.float32)
    label = np.random.randint(1000, size=[args.batch_size , 1])
    image = jt.float32(image)
    label = jt.int64(label)
    optimizer = nn.SGD(model.parameters(), args.learning_rate, args.momentum, args.weight_decay)


    for i in range(10):
        train_func()

    train_start_time = time.time()
    for i in range(args.step):
        train_func()

    train_time = (time.time() - train_start_time) / args.step

    eval_start_time = time.time()
    for i in range(args.step):
        eval_func()

    eval_time = (time.time() - eval_start_time) / args.step
    stdout = subprocess.getoutput('nvidia-smi')
    mem = re.findall(r'\|  (.*?)MiB /', stdout)[0].strip()

    print('Jittor, Model:{0},Dy:{1},#GPU:{2},batch_size:{3},mem:{4}M, avg_train_time:{5:.3f}ms, avg_eval_time:{6:.3f}ms'. \
        format(args.arch, args.dynamic, 1, args.batch_size, mem, train_time * 1000, eval_time * 1000))


if __name__ == "__main__":
    main()

模型测速

  • 测试设置:batch_size=64, GPU:1张1080ti, 测试迭代次数: 100;

    • 测试模型代码由jittor repo给出,
    • 训练和预测代码根据jittor exmaple写出。
  • 测试结果

Model avg training time/iter avg evaluate time/iter
ResNet-18 107.17ms 1.26ms
VGG-16 1.44ms 0.44ms
  • 从测试结果看,提出以下问题:
    1.ResNet和VGG都存在inference time非常短,其他深度学习框架约几十毫秒。请问是上述测试代码中,对于jittor的使用存在问题么?
    2.VGG-16的每个iter训练时间也非常短,极不正常。
    期望得到作者的解答,非常感谢。

实现WGAN时的问题

实现WGAN时无法创建卷积层。环境是wsl ubuntu,采用pip+git方式安装。

import jittor as jt
import numpy as np
from jittor import nn,Module,init
from jittor.dataset.mnist import MNIST
import jittor.transform as transform

batch_size = 50
DIM =64
LAMBDA = 10
ITERS = 200000
OUTPUT_DIM = 784
transform = transform.Compose([
    transform.Resize(size=(28,28)),
    transform.Gray(),
    transform.ImageNormalize(mean=[0.5],std=[0.5])
])
train_loader = MNIST(train=True,transform=transform).set_attrs(batch_size=batch_size,shuffle=True)

class Generator(Module):
    def __init__(self,h_dim):
        super(Generator,self).__init__()
        self.preprocess = nn.Sequential(
            nn.Linear(128, 4 * 4 * 4 * DIM),
            nn.ReLU(),
        )
        self.block1 = nn.Sequential(
            nn.ConvTranspose(4*DIM, 2*DIM, 5),
            nn.ReLU(),
        )
        self.block2 = nn.Sequential(
            nn.ConvTranspose(2*DIM, DIM, 5),
            nn.ReLU(),
        )
        self.deconv_out = nn.ConvTranspose(DIM, 1, 8, stride=2)
        self.sigmoid = nn.Sigmoid()

    def execute(self,x):
        output = self.preprocess(x)
        output = output.reshape((-1,4*DIM,4,4))
        output = self.block1(output)
        output = output[:,:,:7,:7]
        output = self.block2(output)
        output = self.deconv_out(output)
        output = self.sigmoid(output)
        return output.reshape((-1,OUTPUT_DIM))

class Discriminator(Module):
    def __init__(self,h_dim):
        super(Discriminator,self).__init__()
        self.main = nn.Sequential(
            nn.Conv(1, DIM, 5, stride=2, padding=2),
            nn.ReLU(),
            nn.Conv(DIM, 2*DIM, 5, stride=2, padding=2),
            nn.ReLU(),
            nn.Conv(2*DIM, 4*DIM, 5, stride=2, padding=2),
            nn.ReLU(),
        )
        self.linear = nn.Linear(4*4*4*DIM,1)


    def execute(self,x):
        x = x.reshape((-1,1,28,28))
        output = self.main(x)
        output = output.reshape((-1,4*4*4*DIM))
        output = self.linear(output)
        return output.reshape((-1,))

def grad_penalty(D,xr,xf):
    xf = xf.detach()
    xr = xr.detach()
    alpha = jt.random((batch_size,1))
    alpha = alpha.reindex(xr.shape,['i0','0'])
    interpolates = alpha*xr + (1-alpha) * xf
    disc_interpolates = D(interpolates)
    grad = jt.grad(disc_interpolates,interpolates)
    N,P = grad.shape
    gp_norm = jt.zeros((N),'float')
    one = jt.ones((OUTPUT_DIM),'float')
    for idx in range(0,N):
        gp_norm[idx] = jt.sqrt(((grad[idx]-one)**2).sum())
    gp = gp_norm.mean()*LAMBDA
    return gp

G = Generator(DIM)
D = Discriminator(DIM)
G_optim = nn.Adam(G.parameters(),lr=1e-4,betas=(0.5,0.9))
D_optim = nn.Adam(D.parameters(),lr=1e-4,betas=(0.5,0.9))

def train(epoch):
    for batch_idx,(x_,target) in enumerate(train_loader):
        for i in range(0,5):
            mini_batch = x_.shape[0]
            x_ = x_.reshape((batch_size,OUTPUT_DIM))
            D_result = D(x_)
            loss_t = -D_result.mean()
            z = init.gauss((mini_batch,128),'float')
            G_result = G(z).detach()
            D_G_result = D(G_result)
            loss_f = D_G_result.mean()
            loss_D = loss_t+loss_f+grad_penalty(D,x_,G_result)
            loss_D.sync()
            D_optim.step(loss_D)
        z = init.gauss((mini_batch,128),'float')
        G_result = G(z)
        D_G_result = D(G_result)
        loss_G = - D_G_result.mean()
        loss_G.sync()
        G_optim.step(loss_G)
    if epoch%5 == 0:
        print("train:epoch",epoch)

for iter in range(0,ITERS):
    train(iter)

安装报错

安装命令

git clone https://github.com/Jittor/jittor.git && with_clang=1 with_cuda=1 bash ./jittor/script/install.sh

报错信息

Reading package lists... Done
W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: https://nvidia.github.io/libnvidia-container/ubuntu18.04/amd64  InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 6ED91CA3AC1160CD
W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: https://nvidia.github.io/nvidia-container-runtime/ubuntu18.04/amd64  InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 6ED91CA3AC1160CD
W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: https://nvidia.github.io/nvidia-docker/ubuntu18.04/amd64  InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 6ED91CA3AC1160CD
E: Repository 'https://download.docker.com/linux/ubuntu bionic InRelease' changed its 'Label' value from 'Docker EE' to 'Docker CE'
N: This must be accepted explicitly before updates for this repository can be applied. See apt-secure(8) manpage for details.

Failed to build from source

Thanks for open-source this project.
I am following the readme in the main-page to build jittor from source(commit-id: 5f84bf1 )
However, I got this error message when I test the installation

export cc_path="/usr/bin/g++"
python -m jittor.test.test_example
....
  File "/usr/local/lib/python3.7/dist-packages/jittor/compiler.py", line 720, in check_cache_compile
    assert jit_utils.cc
AssertionError

With preliminary debug, I suspect I failed to import the jit_utils_core

import jit_utils_core as cc
if is_in_ipynb:
global redirector
redirector = cc.ostream_redirect(stdout=True, stderr=True)
redirector.__enter__()
except Exception as _:
pass

And I find jit_utils_core is defined in the jit_utils.cc with pybind.
Any thought to help debug this problem?

data device

import jittor as jt
jt.flags.use_cuda = 1
a = jt.float32([1,2,3]*10)
b = jt.float32([4,5,6]*10)
for i in range(1):
    c = a*b
    print(c)
    print(c.data)

currently I use your example. When use_cuda =1, the data is stored in gpu, this is correct. But is there any ways to store the data in cpu even though I specify the use_cuda flag to one. And also, I see there is no information about the device in printinfo. Is there any methods about how to specify the data device?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.