本文提供一个shell脚本,在Linux环境下通过执行此shell脚本可以一次自动安装python、keras、tensorflow、anaconda、pyenv、curl、git等等
解决的问题
在linux server环境下安装keras等软件时,人肉输入一个一个apt install命令安装每个软件的话,会很费时费精力。可以通过文中提供的shell脚本,执行一次脚本安装keras等所有软件,省时省力。
命令安装时软件是从网络下载安装的,有的软件包会下载的很慢(下载20分钟都有可能~),可以在windows环境中下载好,然后linux使用本地安装软件包会安装的比较快。可以把以下软件的安装,在shell脚本中写成执行本地软件包来安装,加快整体的安装速度。
下面是比较大的软件包:
1)Anaconda3-5.0.0-Linux-x86_64.sh
链接:https://pan.baidu.com/s/16wV2ON7bfCUUyKRclLEB6g 密码:qfvj
3)numpy-1.14.1-cp27.cp27mu-manylinux1_x86_64.whl
链接:https://pan.baidu.com/s/1HXkgUfcpCrk–gpX8SJPhQ 密码:w9g3
4)scipy-1.0.0-cp27-cp27mu-manylinux1_x86_64.whl
链接:https://pan.baidu.com/s/1PBh6W2n8ozI5afa8l-QZyA 密码:l8bj
5)scikit_learn-0.19.1-cp27-cp27mu-manylinux1_x86_64.whl
链接:https://pan.baidu.com/s/17Z83C12ITnz4f-BrKgdwTQ 密码:2s4l
6)scikit_image-0.13.1-cp27-cp27mu-manylinux1_x86_64.whl
链接:https://pan.baidu.com/s/1-SXyqZjy512KYmSZMm-dog 密码:aq40
7)matplotlib-2.2.0-cp27-cp27mu-manylinux1_x86_64.whl
链接:https://pan.baidu.com/s/11AYK9Ui8GvsWuAQh9APUlw 密码:fkwx
8)Pillow-5.0.0-cp27-cp27mu-manylinux1_x86_64.whl
链接:https://pan.baidu.com/s/1K9BowJCPo4bSSnegZX_WlA 密码:06bg
9)protobuf-3.5.2-cp27-cp27mu-manylinux1_x86_64.whl
链接:https://pan.baidu.com/s/1ooWQUbifKChnDAgh4Jzs-w 密码:htab
10)tensorboard-1.6.0-py2-none-any.whl
链接:https://pan.baidu.com/s/1yYz27ZOI8dF_ii-k8TRIFQ 密码:7zry
11)grpcio-1.10.0-cp27-cp27mu-manylinux1_x86_64.whl
链接:https://pan.baidu.com/s/14D6cxT74ZG8smMDgralTug 密码:c2u4
2)tensorflow-1.6.0-cp27-cp27mu-manylinux1_x86_64.whl
链接:https://pan.baidu.com/s/1vHcelVzDyTWGGE4jhynVkg 密码:9jxv
环境
ubuntu-16.04.4-server-amd64
shell脚本文件
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 1#!/bin/bash
2#author:http://blog.csdn.net/u012421852
3
4#如果执行此脚本出现错误提示:执行脚本时提示no such file or directory
5#那么用下面命令来解决
6#vim xx.sh
7#:set ff=unix
8#:wq
9
10#执行脚本文件前请修改权限
11#chmod +x filename
12
13#执行脚本,进行安装
14#./xx.sh
15
16
17yes | sudo apt-get update
18yes | sudo apt-get upgrade
19
20#安装python基础包
21yes | sudo apt install -y python-dev python-pip python-nose python-setuptools build-essential
22yes | sudo apt install -y vim g++ gcc git git-core gfortran
23#安装加速器
24yes | sudo apt install -y libopenblas-dev liblapack-dev libatlas-base-dev
25#安装pip
26yes | sudo -H pip install -U --pre pip setuptools wheel #pip-9.0.1-py2.py3-none-any.whl
27
28#安装python第三方库等
29yes | sudo -H pip install -U --pre numpy #numpy-1.14.1-cp27.cp27mu-manylinux1_x86_64.whl
30yes | sudo -H pip install -U --pre scipy #scipy-1.0.0-cp27-cp27mu-manylinux1_x86_64.whl(46.7MB)
31yes | sudo -H pip install -U --pre matplotlib #matplotlib-2.2.0-cp27-cp27mu-manylinux1_x86_64.whl
32yes | sudo -H pip install -U --pre scikit-learn #scikit_learn-0.19.1-cp27-cp27mu-manylinux1_x86_64.whl
33yes | sudo -H pip install -U --pre scikit-image #scikit_image-0.13.1-cp27-cp27mu-manylinux1_x86_64.whl
34
35#安装tensorflow(注意选择自己安装的版本类型)
36#;sudo -H pip install -U --pre tensorflow-gpu; #tensorflow GPU版本,CPU加速可忽略
37yes | sudo -H pip install -U --pre tensorflow #tensorflow CPU版本,tensorflow-1.6.0-cp27-cp27mu-manylinux1_x86_64.whl
38
39#安装 keras
40yes | sudo -H pip install -U --pre keras #安装keras
41
42#==========install pyenv===========================
43#install curl and before pyenv's install
44yes | sudo -H apt-get install curl
45#install git-core before pyenv's install
46yes | sudo -H apt-get install git-core;#install curl and git-core for pyenv
47#install pyenv way1
48git clone git://github.com/yyuu/pyenv.git .pyenv
49echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
50echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
51echo 'eval "$(pyenv init -)"' >> ~/.bashrc
52exec $SHELL
53
54#install pyenv way2
55curl -L https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer | bash; #install pyenv
56echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile;
57echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile;
58yes | echo 'eval "$(pyenv init -)"' >> ~/.bash_profile;
59source ~/.bash_profile
60
61#check pyenv's version
62pyenv --version
63
64yes | sudo apt-get install libssl-dev
65yes | sudo apt-get install libbz2-dev libreadline-dev libsqlite3-dev
66
67#==========install anaconda===========================
68#way1:pyenv命令安装anaconda
69#pyenv install anaconda2-4.20
70
71#way2:执行本地anaconda.sh文件安装
72chmod 777 ./Anaconda3-5.0.0-Linux-x86_64.sh #链接:https://pan.baidu.com/s/192frTNDaizjTyUAiPN4YWg 密码:hzn1
73./Anaconda3-5.0.0-Linux-x86_64.sh
74
75conda update conda #更新版本
76conda update anaconda #更新anaconda版本
77conda install accelerate #安装额外的功能包
78conda install iopro
79#(end)
80
验证安装结果
python、tensorflow、keras等都安装ok
(end)