1. 程式人生 > 其它 >anaconda服務區環境配置

anaconda服務區環境配置

一、顯示卡驅動升級

cuda 版本升級可需要注意以下三點,避免踩坑
1、顯示卡驅動問題 linux 與ubuntu 是一樣的
2、cudann 版本問題 7.6.* 不要用8.*
3、新增環境變數 export LD_LIBRARY_PATH=/usr/local/cuda-10.1/lib64/


二、jupyter 配置與啟動

1、修改config檔案 埠 禁止密碼修改 啟動路徑
/usr/local/anaconda/bin/jupyter notebook --generate-config
c.NotebookApp.port = xxxx
c.NotebookApp.notebook_dir = '/home/xxx/'
c.NotebookApp.allow_password_change = False

2、jupyter 密碼修改
/usr/local/anaconda/bin/jupyter notebook password
生成密碼後將json檔案中的加密密碼新增到config檔案
c.NotebookApp.password = u'sha1:xxxxxxxxxxxxxxxxx'

3、jupyter服務啟動與停止
切換至ailab賬戶後執行 nohup /usr/local/anaconda/bin/jupyter-notebook --no-browser --port xxxx --ip=* --allow-root > jupyter.out 2>&1 &
ps -ef | grep 'jupyter' 檢視已經啟動jupyter的pid, kill -9 pid 殺掉程序即可關閉jupyter服務

4、nbextension外掛安裝(需用root賬戶)

/usr/local/anaconda/bin/pip install jupyter_contrib_nbextensions -i https://mirrors.aliyun.com/pypi/simple
/usr/local/anaconda/bin/pip install jupyter_nbextensions_configurator -i https://mirrors.aliyun.com/pypi/simple
/usr/local/anaconda/bin/jupyter contrib nbextension install
/usr/local/anaconda/bin/jupyter nbextensions_configurator enable

三、python三方包的安裝


1、pip 源
阿里雲 https://mirrors.aliyun.com/pypi/simple/
中國科技大學 https://pypi.mirrors.ustc.edu.cn/simple/
豆瓣 https://pypi.douban.com/simple
中國科學院 https://pypi.mirrors.opencas.cn/simple/
清華大學 https://pypi.tuna.tsinghua.edu.cn/simple/

2、tensorflow與pytorch的安裝

tensorflow 2.3.1 安裝(使用清華映象源)
/usr/local/anaconda/pip install -U --ignore-installed wrapt enum34 simplejson netaddr
/usr/local/anaconda/bin/pip install tensorflow==2.3.1 -i https://mirrors.aliyun.com/pypi/simple
pytorch安裝
/usr/local/anaconda/bin/pip install torch==1.7.1+cu101 torchvision==0.8.2+cu101 torchaudio==0.7.2 -f https://download.pytorch.org/whl/torch_stable.htm

pip批量安裝
/usr/local/anaconda/bin/pip install -r pkg.txt -i https://mirrors.aliyun.com/pypi/simple --ignore-installed PyYAML

3、GPU可用測試
import tensorflow as tf
print(tf.test.is_gpu_available())
print(tf.test.is_built_with_cuda())

四、伺服器環境與使用者許可權

1、免密ssh,scp 設定,A機器下a賬戶連線B機器b賬戶為例
如果home/a/.ssh下面沒有公私鑰,在A機器/home/a/ 下面執行ssh-keygen -t rsa 一路回車
將/home/a/.ssh 下面的id_rsa.pub內容追加到B機器上的b賬戶下的.ssh/authorized_keys即可