@TOC
conda 系列:
1. conda指令教程
2. 利用Conda創建虛擬環境,安裝Pytorch各版本教程(Ubuntu)
1. 利用Conda創建虛擬環境
nolo@nolo:~/sun/SplaTAM$ conda create -n splatam python==3.10
查看結果:
(splatam) nolo@nolo:~/sun/SplaTAM$ conda info -e
詳細見 【python】Conda強大的包/環境管理工具
2. 利用Conda創建虛擬環境中Pytorch各版本安裝教程
nvida-smi 查看cuda兼容版本號,最高
安裝Pytorch
激活環境之后,就可以在環境中安裝pytorch框架。 進入Pytorch官網點擊install進行選擇。
如上圖,如果需要安裝的是pytorch_1.7版本,可以直接選擇系統、安裝方式和CUDA版本,復制下方紅色框中的命令到終端即可安裝。 需要其他版本pytorch可以點擊圖中綠色框內的選項,查看pytorch的早期版本。
例如pytorch1.4,復制相應的命令到終端即可安裝。
conda install pytorch==1.4.0 torchvision==0.5.0 cudatoolkit=9.2 -c pytorch
conda install pytorch==1.4.0 torchvision==0.5.0 cudatoolkit=10.1 -c pytorch
3. PackagesNotFoundError: The following packages are not available from current channels 解決方案
解決方法一:將conda-forge添加到搜索路徑上
首先,當出現這種報錯時,應該首先嘗試使用以下命令將conda-forge channel添加到你的channel列表中:
conda config --append channels conda-forge
它告訴conda在搜索軟件包時也要在conda-forge channel上查看。
然后你就可以嘗試利用如下命令再次安裝
conda install 包名
原因在于:channel可以看成是托管python包的服務器,當無法通過標準channel獲得python包時,社區驅動的conda-forge通常是一個很好的地點。大部分問題都可以利用這條語句解決。
方法二:利用報錯提示,進入annaconda網站利用命令解決
當添加上述語句仍然出現錯誤,安裝某個python包時(并不特別對于某個特定包,各種包有時都會出現這種情況 。會出現當前channel不可用,并報錯:
PackagesNotFoundError: The following packages are not available from current channels:
報錯的完整顯示:
上面這個報錯的即可覺方案:見鏈接
Collecting package metadata (current_repodata.json): ...working... done
Solving environment: ...working... failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): ...working... done
Solving environment: ...working... failed with initial frozen solve. Retrying with flexible solve.PackagesNotFoundError: The following packages are not available from current channels:- igraphCurrent channels:- https://repo.anaconda.com/pkgs/main/win-64- https://repo.anaconda.com/pkgs/main/noarch- https://repo.anaconda.com/pkgs/r/win-64- https://repo.anaconda.com/pkgs/r/noarch- https://repo.anaconda.com/pkgs/msys2/win-64- https://repo.anaconda.com/pkgs/msys2/noarchTo search for alternate channels that may provide the conda package you're
looking for, navigate tohttps://anaconda.organd use the search bar at the top of the page.
解決辦法報錯中有:
To search for alternate channels that may provide the conda package you're
looking for, navigate tohttps://anaconda.organd use the search bar at the top of the page.
你需要去 https://anaconda.org 這個網址,在上方的搜索條上搜索你要安裝這個包的其他channel,下邊展示一下如何找igraph的其他channel
進入上述網址,你可以在上方看到搜索條:
4. PackagesNotFoundError: The following packages are not available from current channels 解決辦法
解決方法一:
添加 Anaconda Python 免費倉庫:
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes
檢查Anaconda的config:查看channel個數以及格式,顯然覺得有一個是有問題的:
conda config --show
參照 conda config 說明,移除某些channel :
conda config --remove channels 'https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/'
或者可以使用 下面命令換回默認源:
conda config --remove-key channels
不過還有簡單粗暴地方法:
直接修改conda的配置,一般在當前用戶路徑下,比如C:\Users\Administrator.condarc.condarc具體內容如下:show_channel_urls: truechannels:
https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/defaults
現在清華鏡像不能使用了,刪除這個鏡像,可以試一下下面的鏡像:
http://pypi.douban.com/simple/ 豆瓣鏡像
http://mirrors.aliyun.com/pypi/simple/ 阿里鏡像
解決方法二:
anaconda search -t conda X
X為要安裝的包
conda install -c https://conda.anaconda.org/X-path X
conda config --add channels https://anaconda.org