gloun
CPU
- anaconda
wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/
- 安装
bash A
export PATH=~/anaconda3/bin:$PATH
- 下载包含本书全部代码的压缩包,解压后进入文件夹。运行如下命令。
mkdir gluon_tutorials_zh-1.0 && cd gluon_tutorials_zh-1.0
curl https://zh.gluon.ai/gluon_tutorials_zh-1.0.tar.gz -o tutorials.tar.gz
tar -xzvf tutorials.tar.gz && rm tutorials.tar.gz
- 使用 Conda 创建并激活环境。Conda 默认使用国外站点来下载软件,下面可选项配置使用国内镜像加速下载:
# 使用清华 conda 镜像。
conda config --prepend channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
# 或者选用科大 conda 镜像。
conda config --prepend channels http://mirrors.ustc.edu.cn/anaconda/pkgs/free/
- 接下来使用 conda 创建虚拟环境并安装本书需要的软件。这里environment.yml是放置在代码压缩包中的文件,其指定了执行本书代码所需要的软件。
conda env create -f environment.yml
- 激活之前创建的环境。
activate gluon
- 生成配置文件
jupyter notebook --generate-config
- 生成密码(后续写配置文件、登录Jupyter notebook需要)
ipython
In [1]: from IPython.lib import passwd
In [2]: passwd()
Enter password:
Verify password:
Out[2]: 'sha1:4b0443f9c7ac:525c0d6981b52f98e2ec1fc83daf6bb69c9d53a1'
- 修改默认配置文件
vi ~/.jupyter/jupyter_notebook_config.py
c.NotebookApp.ip='*'
c.NotebookApp.password = u'sha1:55e15135d8ac:af9e03edc3f96dedf66f3535dd238c19458c42cf'
c.NotebookApp.open_browser = False
c.NotebookApp.port =8888 #随便指定一个端口
c.IPKernelApp.pylab = 'inline'
- 启动Jupter notebook
jupyter notebook
- 此时应该可以直接从本地浏览器直接访问http://116.85.54.89:8888就可以看到jupyter的登陆界面。(特别注意:服务器上的Jupyter notebook不要关)address_of_remote 为公网ip地址!!!!
sudo ufw disable
GPU
- 卸载mxnet
pip uninstall mxnet
- 安装mxnet-gpu
pip install mxnet-cu90 --pre -i https://pypi.douban.com/simple
Tensorflow
- 创建文件夹并进入
mkdir tensorflow && cd tensorflow
conda create -n tensorflow python=3.6
- 清华源
pip install \
-i https://pypi.tuna.tsinghua.edu.cn/simple/ \
https://mirrors.tuna.tsinghua.edu.cn/tensorflow/linux/cpu/tensorflow-1.7.0-cp36-cp36m-linux_x86_64.whl
- 改地址,同上
- 装jupyter ipython
conda install ipython
conda install jupyter
删除环境
conda remove -n py36 --all
pytorch
mkdir pytorch && cd pytorch
conda create -n pytorch python=3.6
pip install http://download.pytorch.org/whl/cpu/torch-0.3.1-cp36-cp36m-linux_x86_64.whl
pip install torchvision
python -m pip install --user numpy scipy matplotlib ipython jupyter pandas sympy nose