Package: jittor
Jittor: a Just-in-time(JIT) deep learning frameworkQuickstart|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:Jittor WebsiteJittor TutorialsJittor ModelsJittor DocumentsGithub,GitLink,GiteeJittor ForumAwesome Jittor ListIM: QQ Group(761222083)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.importjittorasjtfromjittorimportModulefromjittorimportnnimportnumpyasnpclassModel(Module):def__init__(self):self.layer1=nn.Linear(1,10)self.relu=nn.Relu()self.layer2=nn.Linear(10,1)defexecute(self,x):x=self.layer1(x)x=self.relu(x)x=self.layer2(x)returnxdefget_data(n):# generate random data for training test.foriinrange(n):x=np.random.rand(batch_size,1)y=x*xyieldjt.float32(x),jt.float32(y)learning_rate=0.1batch_size=50n=1000model=Model()optim=nn.SGD(model.parameters(),learning_rate)fori,(x,y)inenumerate(get_data(n)):pred_y=model(x)dy=pred_y-yloss=dy*dyloss_mean=loss.mean()optim.step(loss_mean)print(f"step{i}, loss ={loss_mean.data.sum()}")ContentsQuickstartInstallTutorialContributingThe TeamLicenseQuickstartWe provide some jupyter notebooks to help you quick start with Jittor.Example: Model definition and trainingBasics: Op, VarMeta-operator: Implement your own convolution with Meta-operatorInstallJittor environment requirements:OSCPUPythonCompiler(Optional) GPU platformLinux(Ubuntu, CentOS, Arch,UOS, KylinOS, ...)x86x86_64ARMloongson>= 3.7g++ >=5.4Nvidia CUDA >= 10.0,cuDNNorAMD ROCm>= 4.0orHygon DCU DTK>= 22.04macOS(>= 10.14 Mojave)intelApple Silicon>= 3.7clang >= 8.0-Windows 10 & 11x86_64>= 3.8-Nvidia CUDA >= 10.2cuDNNJittor offers three ways to install: pip, docker, or manual.Pip installsudoaptinstallpython3.7-devlibomp-dev
python3.7-mpipinstalljittor# or install from github(latest version)# python3.7 -m pip install git+https://github.com/Jittor/jittor.gitpython3.7-mjittor.test.test_examplemacOS installPlease first install additional dependencies withhomebrew.brewinstalllibompThen you can install jittor through pip and run the example.python3.7-mpipinstalljittor
python3.7-mjittor.test.test_exampleCurrently jittor only supports CPU on macOS.Windows install# check your python version(>=3.8)python--version
python-mpipinstalljittor# if conda is usedcondainstallpywin32In 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-mjittor_utils.install_cudaDocker InstallWe 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/jittormanual installWe 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++sudoaptinstallg++build-essentiallibomp-dev# OR clang++-8wget-O-https://raw.githubusercontent.com/Jittor/jittor/master/script/install_llvm.sh>/tmp/llvm.sh
bash/tmp/llvm.sh8Step 2: Install Python and python-devJittor need python version >= 3.7.sudoaptinstallpython3.7python3.7-devStep 3: Run JittorThe whole framework is compiled Just-in-time. Let's install jittor via pipgitclonehttps://github.com/Jittor/jittor.git
sudopip3.7install./jittorexportcc_path="clang++-8"# if other compiler is used, change cc_path# export cc_path="g++"# export cc_path="icc"# run a simple testpython3.7-mjittor.test.test_exampleif the test is passed, your Jittor is ready.Optional Step 4: Enable CUDAUsing CUDA in Jittor is very simple, Just setup environment valuenvcc_path# replace this var with your nvcc locationexportnvcc_path="/usr/local/cuda/bin/nvcc"# run a simple cuda testpython3.7-mjittor.test.test_cudaif the test is passed, your can use Jittor with CUDA by settinguse_cudaflag.importjittorasjtjt.flags.use_cuda=1Optional Step 5: Test Resnet18 trainingTo check the integrity of Jittor, you can run Resnet18 training test. Note: 6G GPU RAM is requires in this test.python3.7-mjittor.test.test_resnetif those tests are failed, please report bugs for us, and feel free to contribute ^_^TutorialIn 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 jittorOperations: Jittor'op is simular with numpyVarFirst, 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.datacan be used for synchronous data accessing.importjittorasjta=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: aOperationsJittor'op is simular with numpy. Let's try some operations. We create Varaandbvia operationjt.float32, and add them. Printing those variables shows they have the same shape and dtype.importjittorasjta=jt.float32([1,2,3])b=jt.float32([4,5,6])c=a*bprint(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 usedjt.xxx(Var, ...)have aliasVar.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. tryhelp(jt.ops). All the operation you found injt.ops.xxx, can be used via aliasjt.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#   ......MoreIf you want to know more about Jittor, please check out the notebooks below:QuickstartExample: Model definition and trainingBasics: Op, VarMeta-operator: Implement your own convolution with Meta-operatorAdvancedCustom Op: write your operator with C++ and CUDA and JIT compile itProfiler: Profiling your modelJtune: Tool for performance tuningThose notebooks can be started in your own computer bypython3.7 -m jittor.notebookContributingJittor 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 paperrecommend Jittor to your friendsContributing codeContributed tutorials and documentationFile an issueAnswer jittor related questionsLight up the starsKeep an eye on jittor......Contact UsWebsite:http://cg.cs.tsinghua.edu.cn/jittor/Email:jittor@qq.comFile an issue:https://github.com/Jittor/jittor/issuesQQ Group: 761222083The TeamJittor is currently maintained by theTsinghua 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}
}LicenseJittor is Apache 2.0 licensed, as found in the LICENSE.txt file.