Ubuntu 18.04 深度學習環境搭建

Butertfly發表於2018-05-17

開啟ssh

安裝openssh-server。

sudo apt-get install openssh-server



Ubuntu 映象源修改

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

sudo vim /etc/apt/sources.list

deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
#deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
#deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
#deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
#deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
#deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

sudo apt-get update
sudo apt-get upgrade


安裝python3

sudo apt install python3-pip

修改pip源

vim ~/.pip/pip.conf
#ali的pip.conf配置
[global]
index-url = http://mirrors.aliyun.com/pypi/simple
[install]
trusted-host = mirrors.aliyun.com

安裝jupyter

pip3 install jupyter

jupyter notebook --generate-config
jupyter notebook password

jupyter notebook --ip 0.0.0.0


安裝anaconda
wget https://repo.continuum.io/archive/Anaconda3-5.1.0-Linux-x86_64.sh
bash ~/anaconda3/Anaconda3-5.1.0-Linux-x86_64.sh


source /home/keras/.bashrc

conda修改國內源
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes


jupyter遠端登陸設定
jupyter notebook --generate-config
jupyter-notebook password


vim ~/.jupyter/jupyter_notebook_config.py 
c.NotebookApp.ip='*'


conda 建立環境

conda create -n dl python=3.6

source activate dl


安裝tensorflow
conda create --name tensorflow python=3.5 jupyter
source activate tensorflow
pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.6.0-cp35-cp35m-linux_x86_64.whl


驗證tensorflow
vim test.py
# Python
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))

python test.py


安裝keras
pip install keras

安裝pytorch-cpu

conda install pytorch -c soumith


相關文章