conda關(guān)于虛擬環(huán)境的常用命令
conda創(chuàng)建虛擬環(huán)境
conda create -n 虛擬環(huán)境名字
conda創(chuàng)建指定python版本的虛擬環(huán)境
conda create -n 虛擬環(huán)境名字 python=3.11
conda激活虛擬環(huán)境
conda activate 虛擬環(huán)境名字
conda查看創(chuàng)建的所有虛擬環(huán)境
conda env list
conda查看當(dāng)前環(huán)境中安裝的第三方包
conda list
conda安裝第三方包
conda install 第三方包名
conda卸載第三方包
conda uninstall 第三方包名
conda升級第三方包
conda update 第三方包名
conda搜索第三方包
conda search 第三方包名
conda退出虛擬環(huán)境
conda deactivate
conda刪除虛擬環(huán)境
conda remove -n 虛擬環(huán)境名字 --all
conda鏡像
添加鏡像channel
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
刪除鏡像channel
conda config --remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
展示目前已有的鏡像channel
conda config --show channels
我們希望在下載的時候,conda告訴我們當(dāng)前下載是在用哪一個
conda config --set show_channel_urls yes
3090顯卡的服務(wù)器上,搭建TensorFlow和pytorch環(huán)境
創(chuàng)建虛擬環(huán)境(TensorFlow和pytorch兩種框架建議分開,避免版本沖突)
conda create -n deeplearning python=3.8
安裝TensorFlow
conda install tensorflow-gpu
tensorflow==2.4.1
numpy==1.19.2
matplotlib==3.4.3
seaborn==0.11.2
sklearn==1.2.1

安裝pytorch
pip install torch===1.7.1+cu110 torchvision===0.8.2+cu110 torchaudio===0.7.2 -f https://download.pytorch.org/whl/torch_stable.html

分別測試能否使用gpu
import tensorflow as tf
tf.config.list_physical_devices('GPU')
import torch
print(torch.cuda.is_available())
添加kernal
python -m ipykernel install --user --name deeplearning
面這條命令中有的不需要有--user,但是可能報錯Permission denied:’/usr/local/share/jupyter’,如果報錯,加上--user 即可解決
pip鏡像安裝keras
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple keras==2.4.3
本地瀏覽器遠(yuǎn)程連接服務(wù)器jupyter-notebook
1.確保已經(jīng)安裝jupyter 命令 conda install jupyter 或者 pip install jupyter
2.用jupyter notebook --generate-config生成配置文件,root用戶登錄的默認(rèn)文件在/root/.jupyter下

3.輸入jupyter notebook password,此處輸入的密碼用于本地瀏覽器登陸。密碼生成在/root/.jupyter/jupyter_notebook_config.json中

4.查看你的密文 cat /root/.jupyter/jupyter_notebook_config.json

5.復(fù)制密文 如
"argon2:$argon2id$v=19$m=10240,t=10,p=8$B54n/wfVDMnO0tiHqV3sFg$T9HYTtNNm3gp9KiLdmJVug"
6.修改配置文件 vim /root/.jupyter/jupyter_notebook_config.py,添加如下配置
c.NotebookApp.ip='*' #允許訪問的IP地址,設(shè)置為*代表允許任何客戶端訪問
c.NotebookApp.password = u"argon2:$argon2id$v=19$m=10240,t=10,p=8$0Xiz7dmis/etsoddouidieEwdd92oUh0I6uo6Z5Q" #剛才生成密碼時復(fù)制的密文'
c.NotebookApp.open_browser = False
c.NotebookApp.port =8888 #可自行指定一個端口, 訪問時使用該端口
c.NotebookApp.allow_remote_access = True
c.NotebookApp.allow_root = True #允許root用戶運(yùn)行jupyter notebook
7.啟動服務(wù)端 jupyter notebook

8.本地瀏覽器訪問,密碼是之前輸入的密碼
