Welcome to mirror list, hosted at ThFree Co, Russian Federation.

install-deps - github.com/torch/distro.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b1d5a4d4466e3277432c02b649b02f6e73bfe1f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
#!/usr/bin/env bash
set -e

######################################################################
# This script installs required dependencies for Torch7
######################################################################
{

install_openblas() {
    # Get and build OpenBlas (Torch is much better with a decent Blas)
    # Optionally set environment variable PREFIX to control
    # the installation directory.


    local PATH=$PATH:/sbin ## improve chances of finding ldconfig
    # Only proceed installing OpenBLAS if either ldconfig is unavailable, or ldconfig
    # reports that OpenBLAS is not already installed.
    if ! type ldconfig >/dev/null || ! ldconfig -p | grep -q "lib\(open\)\?blas.so"; then
        local tempdir=$(mktemp -d)

        git clone https://github.com/xianyi/OpenBLAS.git "$tempdir"/OpenBLAS  || { echo "Error. Cannot clone OpenBLAS." >&2 ; exit 1 ; }
        cd "$tempdir"/OpenBLAS || { echo "Error. Cannot create tempdir." >&2 ; exit 1 ; }
        if [ $(getconf _NPROCESSORS_CONF) == 1 ]; then
            make NO_AFFINITY=1 USE_OPENMP=0 USE_THREAD=0
        else
            make NO_AFFINITY=1 USE_OPENMP=1
        fi
        RET=$?;
        if [ $RET -ne 0 ]; then
            echo "Error. OpenBLAS could not be compiled";
            exit $RET;
        fi
        if [ ! -z "$PREFIX" ]; then
            sudo make install PREFIX="$PREFIX"
        else
            sudo make install
        fi
        RET=$?;
        if [ $RET -ne 0 ]; then
            echo "Error. OpenBLAS could not be installed";
            exit $RET;
        fi
        cd -
        rm -rf "$tempdir"
    else
        echo "Skipping install of OpenBLAS - it is already installed." >&2
    fi
}

install_openblas_AUR() {
    # build and install an OpenBLAS package for Archlinux
    cd /tmp && \
    curl https://aur.archlinux.org/cgit/aur.git/snapshot/openblas-lapack.tar.gz | tar zxf - && \
    cd openblas-lapack
    makepkg -csi --noconfirm
    RET=$?;
    if [ $RET -ne 0 ]; then
        echo "Error. OpenBLAS could not be installed";
        exit $RET;
    fi
}

checkupdates_archlinux() {
    # checks if archlinux is up to date
    if [[ -n $(checkupdates) ]]; then
        echo "It seems that your system is not up to date."
        echo "It is recommended to update your system before going any further."
        read -p "Continue installation ? [y/N] " yn
            case $yn in
                Y|y ) echo "Continuing...";;
                * ) echo "Installation aborted."
                    echo "Relaunch this script after updating your system with 'pacman -Syu'."
                    exit 0
            esac
    fi
}

# Based on Platform:
if [[ `uname` == 'Darwin' ]]; then
    # GCC?
    if [[ `which gcc` == '' ]]; then
        echo "MacOS doesn't come with GCC: please install XCode and the command line tools."
        exit 1
    fi

    # Install Homebrew (pkg manager):
    if [[ `which brew` == '' ]]; then
        ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    fi

    # Install dependencies:
    brew update
    brew install git readline cmake wget
    brew install libjpeg imagemagick zeromq graphicsmagick openssl
    brew link readline --force
    brew cask install xquartz
    brew list -1 | grep -q "^gnuplot\$" && brew remove gnuplot
    brew install gnuplot --with-wxmac --with-cairo --with-pdflib-lite --with-x11 --without-lua
    brew install qt || true

elif [[ "$(uname)" == 'Linux' ]]; then

    if [[ -r /etc/os-release ]]; then
        # this will get the required information without dirtying any env state
        DIST_VERS="$( ( . /etc/os-release &>/dev/null
                        echo "$ID $VERSION_ID") )"
        DISTRO="${DIST_VERS%% *}" # get our distro name
        VERSION="${DIST_VERS##* }" # get our version number
    elif [[ -r /etc/redhat-release ]]; then
        DIST_VERS=( $( cat /etc/redhat-release ) ) # make the file an array
        DISTRO="${DIST_VERS[0],,}" # get the first element and get lcase
        VERSION="${DIST_VERS[2]}" # get the third element (version)
    elif [[ -r /etc/lsb-release ]]; then
        DIST_VERS="$( ( . /etc/lsb-release &>/dev/null
                        echo "${DISTRIB_ID,,} $DISTRIB_RELEASE") )"
        DISTRO="${DIST_VERS%% *}" # get our distro name
        VERSION="${DIST_VERS##* }" # get our version number
    else # well, I'm out of ideas for now
        echo '==> Failed to determine distro and version.'
        exit 1
    fi

    # Detect fedora
    if [[ "$DISTRO" = "fedora" ]]; then
        distribution="fedora"
        fedora_major_version="$VERSION"
    # Detect archlinux
    elif [[ "$DISTRO" = "arch" ]]; then
        distribution="archlinux"
    # Detect Ubuntu
    elif [[ "$DISTRO" = "ubuntu" ]]; then
        export DEBIAN_FRONTEND=noninteractive
        distribution="ubuntu"
        ubuntu_major_version="${VERSION%%.*}"
    elif [[ "$DISTRO" = "linuxmint" ]]; then
        export DEBIAN_FRONTEND=noninteractive
        distribution="ubuntu"
        ubuntu_major_version="16"
    # Detect elementary OS
    elif [[ "$DISTRO" = "elementary" ]]; then
        export DEBIAN_FRONTEND=noninteractive
        distribution="elementary"
        elementary_version="${VERSION%.*}"
    # Detect CentOS
    elif [[ "$DISTRO" = "centos" ]]; then
        distribution="centos"
        centos_major_version="$VERSION"
    # Detect AWS
    elif [[ "$DISTRO" = "amzn" ]]; then
        distribution="amzn"
        amzn_major_version="$VERSION"
    elif [[ "$DISTRO" == "raspbian" ]]; then
        distribution="raspbian"
        debian_major_version="$VERSION"
    elif [[ "$DISTRO" == "opensuse" ]]; then
	distribution="opensuse"
	opensuse_major_version="$VERSION"
    # Detect Debian
    elif [[ "$DISTRO" = "debian" ]]; then
	distribution="debian"
	debian_major_version="$VERSION"
    elif [[ "$DISTRO" = "neon" ]]; then
	distribution="ubuntu"
	ubuntu_major_version="${VERSION%%.*}"
    else
        echo '==> Only Ubuntu, elementary OS, Fedora, Archlinux, OpenSUSE, Debian, CentOS and KDE neon distributions are supported.'
        exit 1
    fi

    # Install dependencies for Torch:
    if [[ $distribution == 'ubuntu' ]]; then
        if sudo apt-get update ; then
            echo "Updated successfully."
        else
            echo "Some portion of the update is failed"
        fi
        # python-software-properties is required for apt-add-repository
        sudo apt-get install -y python-software-properties
        echo "==> Found Ubuntu version ${ubuntu_major_version}.xx"
        if [[ $ubuntu_major_version -lt '12' ]]; then
            echo '==> Ubuntu version not supported.'
            exit 1
        elif [[ $ubuntu_major_version -lt '14' ]]; then # 12.xx
            sudo -E add-apt-repository -y ppa:chris-lea/zeromq
        elif [[ $ubuntu_major_version -lt '15' ]]; then # 14.xx
	    sudo -E apt-get install -y software-properties-common
            sudo -E add-apt-repository -y ppa:jtaylor/ipython
        else
            sudo apt-get install -y software-properties-common \
                libgraphicsmagick1-dev libfftw3-dev sox libsox-dev \
                libsox-fmt-all
        fi

        if sudo apt-get update ; then
            echo "Updated successfully."
        else
            echo "Some portion of the update is failed"
        fi
        sudo apt-get install -y build-essential gcc g++ curl \
            cmake libreadline-dev git-core libqt4-dev libjpeg-dev \
            libpng-dev ncurses-dev imagemagick libzmq3-dev gfortran \
            unzip gnuplot gnuplot-x11 ipython

        gcc_major_version=$(gcc --version | grep ^gcc | awk '{print $4}' | \
                            cut -c 1)
        if [[ $gcc_major_version == '5' ]]; then
            echo '==> Found GCC 5, installing GCC 4.9.'
            sudo apt-get install -y gcc-4.9 libgfortran-4.9-dev g++-4.9
        fi

        if [[ $ubuntu_major_version -lt '15' ]]; then
            sudo apt-get install libqt4-core libqt4-gui
        fi

        install_openblas || true

    elif [[ $distribution == 'raspbian' ]]; then
        echo "==> Found Raspbian version ${debian_major_version}.xx"
        if sudo apt-get update ; then
            echo "Updated successfully."
        else
            echo "Some portion of the update is failed"
        fi
        sudo apt-get install -y build-essential gcc g++ curl \
            cmake libreadline-dev git-core libqt4-dev libjpeg-dev \
            libpng-dev ncurses-dev imagemagick libzmq3-dev gfortran \
            unzip gnuplot gnuplot-x11 ipython

        install_openblas || true

    elif [[ $distribution == 'opensuse' ]]; then
        if sudo zypper refresh ; then
            echo "Updated successfully."
        else
            echo "Some portion of the update failed"
        fi
        sudo zypper install -y -t pattern devel_basis
	if [[ $opensuse_major_version == '42.2' ]]; then
	    sudo zypper install -y gcc curl cmake readline-devel IPython git-core \
            	libqt4 libjpeg62-devel libpng16-compat-devel ImageMagick unzip \
            	gnuplot gcc-fortran libzmq5
	else
            sudo zypper install -y gcc curl cmake readline-devel IPython git-core \
            	libqt4 libjpeg8-devel libpng15-compat-devel imagemagick unzip \
            	gnuplot gcc-fortran libzmq3
	fi

    elif [[ $distribution == 'elementary' ]]; then
        declare -a target_pkgs
        target_pkgs=( build-essential gcc g++ curl \
                      cmake libreadline-dev git-core libqtcore4 libqtgui4 \
                      libqt4-dev libjpeg-dev libpng-dev ncurses-dev \
                      imagemagick libzmq3-dev gfortran unzip gnuplot \
                      gnuplot-x11 ipython )
        if sudo apt-get update ; then
            echo "Updated successfully."
        else
            echo "Some portion of the update is failed"
        fi
        # python-software-properties is required for apt-add-repository
        sudo apt-get install -y python-software-properties
        if [[ $elementary_version == '0.3' ]]; then
            echo '==> Found Ubuntu version 14.xx based elementary installation, installing dependencies'
            sudo apt-get install -y software-properties-common \
                libgraphicsmagick1-dev libfftw3-dev sox libsox-dev \
                libsox-fmt-all

            sudo -E add-apt-repository -y ppa:jtaylor/ipython
        else
            sudo -E add-apt-repository -y ppa:chris-lea/zeromq
        fi
        if sudo apt-get update ; then
            echo "Updated successfully."
        else
            echo "Some portion of the update is failed"
        fi
        sudo apt-get install -y "${target_pkgs[@]}"

        install_openblas || true

    elif [[ $distribution == 'archlinux' ]]; then
        echo "Archlinux installation"
        checkupdates_archlinux
        sudo pacman -S --quiet --noconfirm --needed \
            cmake curl readline ncurses git \
            gnuplot unzip libjpeg-turbo libpng libpng \
            imagemagick graphicsmagick fftw sox zeromq \
            ipython qt4 qt5-webkit || exit 1
        pacman -Sl multilib &>/dev/null
        if [[ $? -ne 0 ]]; then
            multilib=
        else
            multilib=-multilib
        fi
        sudo pacman -S --quiet --noconfirm --needed \
            gcc${multilib} gcc-fortran${multilib} || exit 1
        # if openblas is not installed yet
        pacman -Qs openblas &> /dev/null
        if [[ $? -ne 0 ]]; then
            install_openblas_AUR || true
        else
            echo "OpenBLAS is already installed"
        fi

    elif [[ $distribution == 'fedora' ]]; then
        if [[ $fedora_major_version == '20' ]]; then
            sudo yum install -y cmake curl readline-devel ncurses-devel \
                                gcc-c++ gcc-gfortran git gnuplot unzip \
                                libjpeg-turbo-devel libpng-devel \
                                ImageMagick GraphicsMagick-devel fftw-devel \
                                sox-devel sox zeromq3-devel \
                                qt-devel qtwebkit-devel sox-plugins-freeworld \
                                ipython
            install_openblas || true
        elif [[ $fedora_major_version -ge '22' ||  $fedora_major_version -le '26' ]]; then
            #using dnf - since yum has been deprecated
            #sox-plugins-freeworld is not yet available in repos for F22
            sudo dnf install -y make cmake curl readline-devel ncurses-devel \
                                gcc-c++ gcc-gfortran git gnuplot unzip \
                                libjpeg-turbo-devel libpng-devel \
                                ImageMagick GraphicsMagick-devel fftw-devel \
                                sox-devel sox qt-devel qtwebkit-devel \
                                python-ipython czmq czmq-devel
            install_openblas || true
        else
            echo "Only Fedora 20-25 are supported for now, aborting."
            exit 1
        fi
    elif [[ $distribution == 'centos' ]]; then
        if [[ $centos_major_version == '7' ]]; then
            sudo yum install -y epel-release # a lot of things live in EPEL
            sudo yum install -y make cmake curl readline-devel ncurses-devel \
                                gcc-c++ gcc-gfortran git gnuplot unzip \
                                libjpeg-turbo-devel libpng-devel \
                                ImageMagick GraphicsMagick-devel fftw-devel \
                                sox-devel sox zeromq3-devel \
                                qt-devel qtwebkit-devel sox-plugins-freeworld
            sudo yum install -y python-ipython
            install_openblas || true
        else
            echo "Only CentOS 7 is supported for now, aborting."
            exit 1
        fi
    elif [[ $distribution == 'amzn' ]]; then
        sudo yum install -y cmake curl readline-devel ncurses-devel \
                            gcc-c++ gcc-gfortran git gnuplot unzip \
                            libjpeg-turbo-devel libpng-devel \
                            ImageMagick GraphicsMagick-devel fftw-devel \
                            libgfortran python27-pip git openssl-devel

        #
        # These libraries are missing from amzn linux
        # sox-devel sox sox-plugins-freeworld qt-devel qtwebkit-devel
        #

        sudo yum --enablerepo=epel install -y zeromq3-devel
        sudo pip install ipython

        install_openblas || true
    elif [[ $distribution == 'debian' ]]; then
	if [[ $debian_major_version == '8' ]] || [[ $debian_major_version == '9' ]]; then
	    echo "==> Found Debian version ${debian_major_version}"
	    if sudo apt-get update ; then
	       echo "Updated successfully."
	    else
	       echo "Some portion of the update is failed"
	    fi
	    #Basic package required for Torch
	    sudo apt-get install -y build-essential curl \
		 cmake libreadline-dev git-core libqt4-dev libjpeg-dev \
		 libpng-dev ncurses-dev imagemagick libzmq3-dev gfortran \
		 unzip gnuplot gnuplot-x11 ipython

	    #require for common torch plug-ins
	    sudo apt-get install -y libgraphicsmagick1-dev libfftw3-dev sox libsox-dev

	    install_openblas || true
	else
	    echo "Only Jessie Debian 8 and 9 is supported for now, aborting."
	    exit 1
	fi
    fi
elif [[ "$(uname)" == 'FreeBSD' ]]; then
    pkg install ImageMagick cmake curl fftw3 git gnuplot libjpeg-turbo \
        libzmq3 ncurses openblas openssl png py27-ipython \
        py27-pip qt4-corelib qt4-gui readline unzip

else
    # Unsupported
    echo '==> platform not supported, aborting'
    exit 1
fi

ipython_exists=$(command -v ipython) || true
if [[ $ipython_exists ]]; then {
    ipython_version=$(ipython --version|cut -f1 -d'.')
    if [[ $ipython_version -lt 2 ]]; then {
        echo 'WARNING: Your ipython version is too old.  Type "ipython --version" to see this.  Should be at least version 2'
    } fi
} fi

# Done.
echo "==> Torch7's dependencies have been installed"

}