Giter Club home page Giter Club logo

pointcloudlib'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.

pointcloudlib's People

Contributors

cjld avatar jittor avatar lzhengning avatar menghaoguo avatar mirage-c 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

pointcloudlib's Issues

[bug] ModuleNotFoundError: No module named 'cpp_wrappers.cpp_neighbors.radius_neighbors'

Traceback (most recent call last):
  File "train_cls.py", line 18, in <module>
    from data_utils.kpconv_loader import KPConvLoader
  File "/home/jiahui/Desktop/ComputerGraph/pointnet/PointCloudLib/data_utils/kpconv_loader.py", line 10, in <module>
    import cpp_wrappers.cpp_neighbors.radius_neighbors as cpp_neighbors
ModuleNotFoundError: No module named 'cpp_wrappers.cpp_neighbors.radius_neighbors'

I fixed this by changing the cpp_wrappers.cpp_neighbors.radius_neighbors to cpp_wrappers.cpp_neighbors.neighbors.
But I can't make sure I'm right. So, would you please check it out?

question about in LRScheduler in utils.py

Hi, all,

In train_partseg.py, lr_scheduler is applied. However, this argument is assigned with value around 14,000 (for ShapeNet Part dataset), which is passed to this line:
lr_decay = self.lr_decay ** int(step / self.decay_step),
And self.decay_step is initialized as 15,000, so lr_decay is always be self.lr_decay ** 0 ->1.
Therefore, self.optimizer.lr is always unchanged from this line.
self.optimizer.lr = lr_decay * self.basic_lr.

Is something wrong in LRScheduler in utils.py?

Please correct me if I misunderstand the code.

Thanks~

error when training pointconv model for part segmentation task

Hi, all,

I can train the pointnet and pointnet++ model for the part segmentation task successfully. Here is my command:
python train_partseg.py --model pointnet. However, when I train the pointconv model using the similar command:
python train_partseg.py --model pointconv. I got the following error inconsistent numbers of samples:

Traceback (most recent call last):
  File "train_partseg.py", line 271, in <module>
    train(model, args, dir_path)
  File "train_partseg.py", line 143, in train
    train_acc = metrics.accuracy_score(train_true_cls, train_pred_cls)
  File "/root/anaconda3/envs/pytorch1.4/lib/python3.7/site-packages/sklearn/utils/validation.py", line 63, in inner_f
    return f(*args, **kwargs)
  File "/root/anaconda3/envs/pytorch1.4/lib/python3.7/site-packages/sklearn/metrics/_classification.py", line 202, in accuracy_score
    y_type, y_true, y_pred = _check_targets(y_true, y_pred)
  File "/root/anaconda3/envs/pytorch1.4/lib/python3.7/site-packages/sklearn/metrics/_classification.py", line 83, in _check_targets
    check_consistent_length(y_true, y_pred)
  File "/root/anaconda3/envs/pytorch1.4/lib/python3.7/site-packages/sklearn/utils/validation.py", line 263, in check_consistent_length
    " samples: %r" % [int(l) for l in lengths])
ValueError: Found input variables with inconsistent numbers of samples: [28680192, 700200]

Could you give some hints to tackle this issue?

Thanks~

error in code

Hi, @MenghaoGuo , when I ran this code,
CUDA_VISIBLE_DEVICES=0 python train_cls.py --model pointconv
I got the following mistakes,
Traceback (most recent call last): File "train_cls.py", line 155, in <module> train(net, optimizer, epoch, train_dataloader, args) File "train_cls.py", line 67, in train output = net(pts) File "/userhome/evns/jittor/lib/python3.7/site-packages/jittor/__init__.py", line 730, in __call__ return self.execute(*args, **kw) File "/userhome/PointCloudLib/networks/cls/pointconv.py", line 29, in execute l3_xyz, l3_points = self.sa3(l2_xyz, l2_points) File "/userhome/evns/jittor/lib/python3.7/site-packages/jittor/__init__.py", line 730, in __call__ return self.execute(*args, **kw) File "/userhome/PointCloudLib/misc/pointconv_utils.py", line 380, in execute new_xyz, new_points, grouped_xyz_norm, grouped_density = sample_and_group_all(xyz, points, density_scale.reshape(B, N, 1)) NameError: name 'sample_and_group_all' is not defined
I check the code in PointCloudLib/misc/pointconv_utils.py. It seems that there is no such function as sample_and_group_all. Can you add this function in the code?

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.