From 59faac1fa5e791633f04286fda3aa3cd247d0d6d Mon Sep 17 00:00:00 2001 From: Dun Liang Date: Fri, 24 Apr 2020 12:12:50 +0800 Subject: [PATCH] fix#65 llvm cuda install, Thanks @hiyyg --- README.cn.md | 9 ++---- README.md | 11 +++----- README.src.md | 14 ++++------ script/install.sh | 2 +- script/install_llvm.sh | 62 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 74 insertions(+), 24 deletions(-) create mode 100644 script/install_llvm.sh diff --git a/README.cn.md b/README.cn.md index f78f15ac..091c552b 100644 --- a/README.cn.md +++ b/README.cn.md @@ -81,9 +81,8 @@ Jittor使用Python和C++编写。 它需要用于即时编译的编译器。当 * CPU 编译器 (需要下列至少一个) - g++ (>=5.4.0) - - clang (>=8.0)推荐 + - clang (>=8.0) * GPU 编译器(可选) - - nvcc(>=10.0) Jittor的环境要求如下: @@ -108,10 +107,6 @@ Jittor 一共提供三种方式安装: pip安装, 一键脚本安装 和 手动 ```bash sudo apt install python3.7-dev libomp-dev sudo python3.7 -m pip install git+https://github.com/Jittor/jittor.git -# if you cannot access github, please download code from our website: -# wget https://cg.cs.tsinghua.edu.cn/jittor/assets/build/jittor.tgz -# mkdir -p jittor && tar -xvf ./jittor.tgz -C jittor -# sudo pip install ./jittor python3.7 -m jittor.test.test_example ``` @@ -155,7 +150,7 @@ wget -O - https://raw.githubusercontent.com/Jittor/jittor/master/script/install. sudo apt install g++ build-essential libomp-dev # OR clang++-8 -wget -O - https://apt.llvm.org/llvm.sh > /tmp/llvm.sh +wget -O - https://raw.githubusercontent.com/Jittor/jittor/master/script/install_llvm.sh > /tmp/llvm.sh bash /tmp/llvm.sh 8 ``` diff --git a/README.md b/README.md index b117bef4..171011bb 100644 --- a/README.md +++ b/README.md @@ -81,9 +81,10 @@ Jittor is written in Python and C++. It requires a compiler for JIT compilation, * CPU compiler (require at least one of the following) * g++ (>=5.4.0) - * clang (>=8.0) recommend + * clang (>=8.0) * GPU compiler (optional) - * nvcc (>=10.0) + * nvcc (>=10.0 for g++ or >=10.2 for clang) + - nvcc (>=10.0 for g++ or >=10.2 for clang) @@ -106,10 +107,6 @@ Jittor offers three ways to install: pip, script or manual. ```bash sudo apt install python3.7-dev libomp-dev sudo python3.7 -m pip install git+https://github.com/Jittor/jittor.git -# if you cannot access github, please download code from our website: -# wget https://cg.cs.tsinghua.edu.cn/jittor/assets/build/jittor.tgz -# mkdir -p jittor && tar -xvf ./jittor.tgz -C jittor -# sudo pip install ./jittor python3.7 -m jittor.test.test_example ``` @@ -150,7 +147,7 @@ We will show how to install Jittor in Ubuntu 16.04 step by step, Other Linux dis sudo apt install g++ build-essential libomp-dev # OR clang++-8 -wget -O - https://apt.llvm.org/llvm.sh > /tmp/llvm.sh +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 diff --git a/README.src.md b/README.src.md index 991e07a0..ac5df469 100644 --- a/README.src.md +++ b/README.src.md @@ -100,14 +100,14 @@ Jittor使用Python和C++编写。 它需要用于即时编译的编译器。当 * CPU compiler (require at least one of the following) * g++ (>=5.4.0) - * clang (>=8.0) recommend + * clang (>=8.0) * CPU 编译器 (需要下列至少一个) - g++ (>=5.4.0) - - clang (>=8.0)推荐 + - clang (>=8.0) * GPU compiler (optional) - * nvcc (>=10.0) + * nvcc (>=10.0 for g++ or >=10.2 for clang) * GPU 编译器(可选) - - nvcc(>=10.0) + - nvcc (>=10.0 for g++ or >=10.2 for clang) Jittor的环境要求如下: @@ -139,10 +139,6 @@ Jittor 一共提供三种方式安装: pip安装, 一键脚本安装 和 手动 ```bash sudo apt install python3.7-dev libomp-dev sudo python3.7 -m pip install git+https://github.com/Jittor/jittor.git -# if you cannot access github, please download code from our website: -# wget https://cg.cs.tsinghua.edu.cn/jittor/assets/build/jittor.tgz -# mkdir -p jittor && tar -xvf ./jittor.tgz -C jittor -# sudo pip install ./jittor python3.7 -m jittor.test.test_example ``` @@ -193,7 +189,7 @@ We will show how to install Jittor in Ubuntu 16.04 step by step, Other Linux dis sudo apt install g++ build-essential libomp-dev # OR clang++-8 -wget -O - https://apt.llvm.org/llvm.sh > /tmp/llvm.sh +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 diff --git a/script/install.sh b/script/install.sh index ff3dfb70..d919e397 100755 --- a/script/install.sh +++ b/script/install.sh @@ -19,7 +19,7 @@ fi if [ "$with_clang" = "1" ]; then sudo apt install wget lsb-release software-properties-common -y -wget -O - https://apt.llvm.org/llvm.sh > /tmp/llvm.sh +wget -O - https://raw.githubusercontent.com/Jittor/jittor/master/script/install_llvm.sh > /tmp/llvm.sh sudo bash /tmp/llvm.sh 8 sudo apt-get install libc++-8-dev libc++abi-8-dev -y sudo apt-get install libomp-8-dev -y diff --git a/script/install_llvm.sh b/script/install_llvm.sh new file mode 100644 index 00000000..c367c893 --- /dev/null +++ b/script/install_llvm.sh @@ -0,0 +1,62 @@ +#!/bin/bash +################################################################################ +# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +# See https://llvm.org/LICENSE.txt for license information. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +################################################################################ +# +# This script will install the llvm toolchain on the different +# Debian and Ubuntu versions + +set -eux + +# read optional command line argument +LLVM_VERSION=8 +if [ "$#" -eq 1 ]; then + LLVM_VERSION=$1 +fi + +DISTRO=$(lsb_release -is) +VERSION=$(lsb_release -sr) +DIST_VERSION="${DISTRO}_${VERSION}" + +if [[ $EUID -ne 0 ]]; then + echo "This script must be run as root!" + exit 1 +fi + +declare -A LLVM_VERSION_PATTERNS +LLVM_VERSION_PATTERNS[8]="-8" +LLVM_VERSION_PATTERNS[9]="-9" +LLVM_VERSION_PATTERNS[10]="" + +if [ ! ${LLVM_VERSION_PATTERNS[$LLVM_VERSION]+_} ]; then + echo "This script does not support LLVM version $LLVM_VERSION" + exit 3 +fi + +LLVM_VERSION_STRING=${LLVM_VERSION_PATTERNS[$LLVM_VERSION]} + +# find the right repository name for the distro and version +case "$DIST_VERSION" in + Debian_9* ) REPO_NAME="deb http://apt.llvm.org/stretch/ llvm-toolchain-stretch$LLVM_VERSION_STRING main" ;; + Debian_10* ) REPO_NAME="deb http://apt.llvm.org/buster/ llvm-toolchain-buster$LLVM_VERSION_STRING main" ;; + Debian_unstable ) REPO_NAME="deb http://apt.llvm.org/unstable/ llvm-toolchain$LLVM_VERSION_STRING main" ;; + Debian_testing ) REPO_NAME="deb http://apt.llvm.org/unstable/ llvm-toolchain$LLVM_VERSION_STRING main" ;; + Ubuntu_16.04 ) REPO_NAME="deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial$LLVM_VERSION_STRING main" ;; + Ubuntu_18.04 ) REPO_NAME="deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic$LLVM_VERSION_STRING main" ;; + Ubuntu_18.10 ) REPO_NAME="deb http://apt.llvm.org/cosmic/ llvm-toolchain-cosmic$LLVM_VERSION_STRING main" ;; + Ubuntu_19.04 ) REPO_NAME="deb http://apt.llvm.org/disco/ llvm-toolchain-disco$LLVM_VERSION_STRING main" ;; + * ) + echo "Distribution '$DISTRO' in version '$VERSION' is not supported by this script (${DIST_VERSION})." + exit 2 +esac + + +cat /etc/apt/sources.list +# install everything +wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - +add-apt-repository "${REPO_NAME}" +cat /etc/apt/sources.list +apt-get update +apt-get install -y clang-$LLVM_VERSION lldb-$LLVM_VERSION lld-$LLVM_VERSION clangd-$LLVM_VERSION