爲 Ubuntu/Anaconda/pip 添加國內下載源

背景

正在看 tensorflow-lite 壓縮模型的部分,結果 tutorial 一上來就要卸舊版安裝 tf-nightly (新版?反正小白下就vans了)
然而好不容易纔編譯好源碼捨不得刪。又建了一個 env 下載新版,速度慢的一比,掛了一上午還超時斷了。
我尋思着好像以前同窗幫我配過國內的鏡像下載源,試了一下。html

「一鍵使用TUNA」服務

按照清華開源軟件鏡像站上面說的步驟,進行以下操做就能夠一鍵爲Anaconda/PyPi/Ubuntu Linux等添加清華鏡像:python

wget https://tuna.moe/oh-my-tuna/oh-my-tuna.py
# For yourself
python oh-my-tuna.py
# ...or for everyone!
sudo python oh-my-tuna.py --global
# Get some help
python oh-my-tuna.py -h

但實測時,僅發現 /etc/apt/sources.list 文件修改了,但 pip 下載時並無提速,暫未查明緣由url

手動修改 pip 下載源

Linux下,修改 ~/.pip/pip.conf (沒有就建立一個文件夾及文件。文件夾要加「.」,表示是隱藏文件夾),內容以下:code

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host=mirrors.aliyun.com

實測 pip 下載提速較爲明顯htm

手動修改 conda 下載源

運行如下命令:blog

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes

實測提速明顯ip

參考資料:get

  1. https://tuna.moe/oh-my-tuna/
  2. http://www.javashuo.com/article/p-hwvocbpb-hh.html
  3. https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/
相關文章
相關標籤/搜索