2019/9/24

Dive to Deep Learning, -- install miniconda

follow instruction run
bash Miniconda3-latest-Linux-x86_64.sh
都回答 Yes後,他會download miniconda 到 local folder,...
Preparing transaction: done
Executing transaction: - WARNING conda.core.envs_manager:register_env(46): Unable to register environment. 
Path not writable or missing.
  environment location: /home/charles-chang/miniconda2
  registry file: /home/charles-chang/.conda/environments.txt
done
installation finished.
Do you wish the installer to initialize Miniconda2
by running conda init? [yes|no]
[no] >>> yes
no change     /home/charles/miniconda2/condabin/conda
no change     /home/charles/miniconda2/bin/conda
no change     /home/charles/miniconda2/bin/conda-env
no change     /home/charles/miniconda2/bin/activate
no change     /home/charles/miniconda2/bin/deactivate
no change     /home/charles/miniconda2/etc/profile.d/conda.sh
no change     /home/charles/miniconda2/etc/fish/conf.d/conda.fish
no change     /home/charles/miniconda2/shell/condabin/Conda.psm1
no change     /home/charles/miniconda2/shell/condabin/conda-hook.ps1
no change     /home/charles/miniconda2/lib/python2.7/site-packages/xontrib/conda.xsh
no change     /home/charles/miniconda2/etc/profile.d/conda.csh
modified      /home/charles/.bashrc

==> For changes to take effect, close and re-open your current shell. <==

If you'd prefer that conda's base environment not be activated on startup, 
   set the auto_activate_base parameter to false: 

conda config --set auto_activate_base false

Thank you for installing Miniconda2!
然後修改 .bashrc:

# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/home/charles/miniconda2/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/home/charles/miniconda2/etc/profile.d/conda.sh" ]; then
        . "/home/charles/miniconda2/etc/profile.d/conda.sh"
    else
        export PATH="/home/charles/miniconda2/bin:$PATH"
    fi
fi
unset __conda_setup

為了避免麻煩。把這個 section copy 出來.. setupminicondaenv.bash

d2l-zh 的 environment.yml:
name: gluon
dependencies:
- python=3.6
- pip:
  - mxnet-cu100==1.5.0
  - d2lzh==0.8.11
  - jupyter==1.0.0
  - matplotlib==2.2.2
  - pandas==0.23.4
!!python 3.6!!

在安裝dl2-zh需要的package 和環境之前,要修改一下,使用 GPU版本的MXNET。
依照說明,用 nvidia-smi 看一下自己的 cuda 版本 (10.0)
修改 dl2-zh/environment.yml,上面已經是改好的內容 (mxnet-cu100)
conda env create -f d2l-zh/environment.yml
之後,安裝需要的 package,然後..
#
# To activate this environment, use
#
#     $ conda activate gluon
#
# To deactivate an active environment, use
#
#     $ conda deactivate

依照說明,conda activate gluon 就可以完成 環境設定。

開啟 jupyter notebook..
因為不是在 local,所以要開啟 remote access/loging.,
ref: public server,先..
jupyter notebook --generate-config
這樣會在 ~/.jupyter 下create 一個 jupyter_notebook_config.py
修改這個檔:
c.NotebookApp.allow_password_change = True
c.NotebookApp.ip = '0.0.0.0'
c.NotebookApp.password_required = False
之後就可以啟動:
~$ jupyter notebook
...
...
    To access the notebook, open this file in a browser:
        file:///home/charles/.local/share/jupyter/runtime/nbserver-8678-open.html
    Or copy and paste one of these URLs:
        http://ey-wpc:8888/?token=77091332eb31bb666dc61e4d6d149460fe4e62757c44d157
..
在另一台電腦上開啟 browser 位址: http://ey-wpc:8888 (ey-wpc 是那台機器的 ip address)。
會出現要你輸入 token 或是 password 的畫面,把上面的77091332eb31bb666dc61e4d6d149460fe4e62757c44d157 copy 貼上就可以。

如果要設定 password 的話(這樣就不用 copy 那一堆key...)
$ jupyter notebook password
Enter password:  ****
Verify password: ****
[NotebookPasswordApp] Wrote hashed password to /Users/you/.jupyter/jupyter_notebook_config.json
就會產生 password hascode 檔。以後 jupyter 啟動就會用這個設定的 password (自己要記住)

jupyter 7 (之後?) 的版本,要...
jupyter server --generate-config
然後去修改 .jupyter/*config.py
先修改 ip='localhost' 到 ip='*'
這樣才能用 public ip access.
設定 password 要趕改成
jupyter server password

沒有留言:

張貼留言