安裝pytorch時,由於我自己在Ubuntu中安裝的cuda,而且也習慣使用pip安裝庫。遇到pip下載速度太慢。
- 解決方法:臨時給pip更換源
- 命令格式:
sudo pip install 包名 -i 鏡像源url
- 例如:
pip install torch torchvision -i https://pypi.douban.com/simple/
下面是幾個常用的源:
阿里雲 http://mirrors.aliyun.com/pypi/simple/
中國科技大學 https://pypi.mirrors.ustc.edu.cn/simple/
豆瓣(douban) http://pypi.douban.com/simple/
清華大學 https://pypi.tuna.tsinghua.edu.cn/simple/
中國科學技術大學 http://pypi.mirrors.ustc.edu.cn/simple/
-----------------------------------------------------------------------------
conda更新慢,同樣可以換源,一般我採用清華鏡像所提供的源
地址:清華Anaconda鏡像
代碼:
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
此外,可以使用conda檢索可按照的庫,例如我要安裝tensorflow-gpu,首先可以執行
conda search tensorflow-gpu
查看conda中所支持安裝tensorflow的哪些版本。
其次選擇自己需要的版本安裝,
conda install tensorflow-gpu==1.13.1
pip也可以指定版本
pip install tensorflow-gpu==1.13.1