setup.sh 4.52 KB
Newer Older
1
2
3
4
5
#!/bin/bash

if [[ $OS_NAME == "macos" ]]; then
    if  [[ $COMPILER == "clang" ]]; then
        brew install libomp
6
        if [[ $AZURE == "true" ]]; then
7
            sudo xcode-select -s /Applications/Xcode_10.3.app/Contents/Developer || exit -1
8
        fi
Nikita Titov's avatar
Nikita Titov committed
9
    else  # gcc
10
11
12
13
14
15
16
        if [[ $TASK != "mpi" ]]; then
            brew install gcc
        fi
    fi
    if [[ $TASK == "mpi" ]]; then
        brew install open-mpi
    fi
17
18
    if [[ $TASK == "swig" ]]; then
        brew install swig
19
    fi
20
    brew install graphviz
21
    curl -sL -o conda.sh https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh
22
else  # Linux
23
24
25
26
27
28
    if [[ $IN_UBUNTU_LATEST_CONTAINER == "true" ]]; then
        # fixes error "unable to initialize frontend: Dialog"
        # https://github.com/moby/moby/issues/27988#issuecomment-462809153
        echo 'debconf debconf/frontend select Noninteractive' | sudo debconf-set-selections

        sudo apt-get update
29
        sudo apt-get install --no-install-recommends -y \
30
31
            software-properties-common

32
        sudo apt-get install --no-install-recommends -y \
33
34
35
            apt-utils \
            build-essential \
            ca-certificates \
36
            cmake \
37
38
39
40
41
42
43
44
            curl \
            git \
            iputils-ping \
            jq \
            libcurl4 \
            libicu66 \
            libssl1.1 \
            libunwind8 \
45
46
            libxau6 \
            libxext6 \
47
            libxrender1 \
48
49
50
51
            locales \
            netcat \
            unzip \
            zip
52
53
54
55
56
        if [[ $COMPILER == "clang" ]]; then
            sudo apt-get install --no-install-recommends -y \
                clang \
                libomp-dev
        fi
57
58
59
60
61
62

        export LANG="en_US.UTF-8"
        export LC_ALL="${LANG}"
        sudo locale-gen ${LANG}
        sudo update-locale
    fi
63
    if [[ $TASK == "mpi" ]]; then
64
        sudo apt-get update
65
66
67
        sudo apt-get install --no-install-recommends -y \
            libopenmpi-dev \
            openmpi-bin
68
69
    fi
    if [[ $TASK == "gpu" ]]; then
Nikita Titov's avatar
Nikita Titov committed
70
        sudo add-apt-repository ppa:mhier/libboost-latest -y
71
        sudo apt-get update
72
73
74
        sudo apt-get install --no-install-recommends -y \
            libboost1.74-dev \
            ocl-icd-opencl-dev
Nikita Titov's avatar
Nikita Titov committed
75
        cd $BUILD_DIRECTORY  # to avoid permission errors
76
77
        curl -sL -o AMD-APP-SDKInstaller.tar.bz2 https://github.com/microsoft/LightGBM/releases/download/v2.0.12/AMD-APP-SDKInstaller-v3.0.130.136-GA-linux64.tar.bz2
        tar -xjf AMD-APP-SDKInstaller.tar.bz2
78
79
80
81
82
83
        mkdir -p $OPENCL_VENDOR_PATH
        mkdir -p $AMDAPPSDK_PATH
        sh AMD-APP-SDK*.sh --tar -xf -C $AMDAPPSDK_PATH
        mv $AMDAPPSDK_PATH/lib/x86_64/sdk/* $AMDAPPSDK_PATH/lib/x86_64/
        echo libamdocl64.so > $OPENCL_VENDOR_PATH/amdocl64.icd
    fi
84
    ARCH=$(uname -m)
Nikita Titov's avatar
Nikita Titov committed
85
    if [[ $TASK == "cuda" ]]; then
86
        echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
Nikita Titov's avatar
Nikita Titov committed
87
        apt-get update
88
89
        apt-get install --no-install-recommends -y \
            curl \
90
            graphviz \
91
92
            libxau6 \
            libxext6 \
93
            libxrender1 \
94
            lsb-release \
95
            software-properties-common
96
97
98
99
100
        if [[ $COMPILER == "clang" ]]; then
            apt-get install --no-install-recommends -y \
                clang \
                libomp-dev
        fi
101
102
103
104
105
106
        curl \
            -s \
            -L \
            --insecure \
            https://apt.kitware.com/keys/kitware-archive-latest.asc \
        | apt-key add -
107
        apt-add-repository "deb https://apt.kitware.com/ubuntu/ $(lsb_release -cs) main" -y
108
109
        apt-get --allow-unauthenticated upgrade -y
        apt-get --allow-unauthenticated update -y
110
111
        apt-get install --no-install-recommends -y \
            cmake
112
113
114
115
116
117
118
119
120
121
    else
        if [[ $ARCH != "x86_64" ]]; then
            yum update -y
            yum install -y \
                graphviz
        else
            sudo apt-get update
            sudo apt-get install --no-install-recommends -y \
                graphviz
        fi
Nikita Titov's avatar
Nikita Titov committed
122
    fi
123
    if [[ $SETUP_CONDA != "false" ]]; then
124
125
126
127
128
        if [[ $ARCH == "x86_64" ]]; then
            curl -sL -o conda.sh https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
        else
            curl -sL -o conda.sh https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-${ARCH}.sh
        fi
129
130
131
    fi
fi

132
if [[ "${TASK}" != "r-package" ]]; then
133
    if [[ $SETUP_CONDA != "false" ]]; then
134
135
136
137
        sh conda.sh -b -p $CONDA
    fi
    conda config --set always_yes yes --set changeps1 no
    conda update -q -y conda
138
fi