1.conda 换源(linux):
将以上配置文件写在~/.condarc中
终端命令 :sudo gedit ~/.condarc,将以下内容复制进去,并保存退出
channels:
- https://mirrors.ustc.edu.cn/anaconda/cloud/menpo/
- https://mirrors.ustc.edu.cn/anaconda/cloud/bioconda/
- https://mirrors.ustc.edu.cn/anaconda/cloud/msys2/
- https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
- https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
- https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
- conda-forge
- bioconda
- defaults
show_channel_urls: true
2.pip换源(linux):
在用户文件夹下新建.pip文件夹及pip.conf文件
cd ~/
mkdir .pip
cd .pip
sudo vim pip.conf
# 加入如下内容(其实就是指定tuna源)
[global]
index-url=https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host=pypi.tuna.tsinghua.edu.cn
disable-pip-version-check = true
timeout = 6000
#3.创建和激活新环境:
创建新环境(环境名字自己取,我这里取得是:pytorch1.2, 且python环境为python3.7):
conda create -n pytorch1.2 python=3.7
注意:Proceed ([y]/n)? y
激活新环境:
conda activate pytorch1.2
4.安装pytorch:
方法1(我尝试失败):conda在线安装
# CUDA 10.0
#conda安装 我安装了三次,最终都安装失败,网址的获取有问题
conda install pytorch==1.2.0 torchvision==0.4.0 cudatoolkit=10.0 -c pytorch
方法2(我尝试失败):pip在线安装
#pip安装 网址获取有问题,会自动下载cuda9.2版本
pip install torch==1.2.0 torchvision==0.4.0 -f https://download.pytorch.org/whl/torch_stable.html
方法3(成功):离线安装(可下载各个版本)
去链接: link 下载torch和torchvision(根据自己需要的版本下载):
cu100/torch-1.2.0-cp37-cp37m-manylinux1_x86_64.whl
cu100/torchvision-0.4.0-cp37-cp37m-manylinux1_x86_64.whl
#切换到下载文件所在文件夹进行安装:
cd /home/ubuntu/下载/
pip install torch-1.2.0-cp37-cp37m-manylinux1_x86_64.whl
pip install torchvision-0.4.0-cp37-cp37m-manylinux1_x86_64.whl
#测试是否安装成功
python
import torch
torch.__version__
torch.cuda.is_available
#可用GPU数量
torch.cuda.device_count()
#查看当前使用的GPU序号
torch.cuda.current_device()
import torchvision
torchvision.__version__
exit()
5.安装编辑器和package(根据自己代码需求安装,这里我示例下自己yolov3的package):
conda install spyder
pip install opencv-python
pip install tqdm
pip install numpy
pip install matplotlib
pip install tensorboard
pip install terminaltables
pip install pillow
pip install future
#pip install tensorflow==1.4.0
#torch1.0 torchvision0.2.0
#torch1.2 torchvision0.4.0
#flask
conda install flask
pip install gevent-websocket
出现的问题:
无法打开spyder
问题描述:This application failed to start because it could not find or load the Qt platform plugin “xcb” in “”.
Reinstalling the application may fix this problem.
已放弃 (核心已转储)
解决问题方法:
https://blog.csdn.net/electech6/article/details/89184414
https://blog.csdn.net/hazel_stick/article/details/101631605
很多最新版本package在国内源里是没有的。所以用国内源安装最新版本spyder的时候要注意。