1.更新驱动

(1)查看驱动版本

 1 ubuntu-drivers devices 

ubuntu16.04安装Anaconda+Pycharm+Pytorch

 

(2)安装对应的驱动

ubuntu16.04安装Anaconda+Pycharm+Pytorch

 1 sudo apt install nvidia-430 已经安装过了,若未安装,会进行安装.

ubuntu16.04安装Anaconda+Pycharm+Pytorch

 参考:https://zhuanlan.zhihu.com/p/59618999

2.安装Anaconda 

https://www.anaconda.com/products/individual

ubuntu16.04安装Anaconda+Pycharm+Pytorch

(1) 1 sudo bash Anaconda3-2020.02-Linux-x86_64.sh 文件名根据自己下载的版本确定

(2)安装完成后配置环境变量

 1 sudo gedit ~/.bashrc 

ubuntu16.04安装Anaconda+Pycharm+Pytorch

 

把echo export PATH="~/anaconda3/bin:$PATH">> ~/.bashrc添加到最后一行

 

ubuntu16.04安装Anaconda+Pycharm+Pytorch

(3)终端输入python3出现下图即安装成功

ubuntu16.04安装Anaconda+Pycharm+Pytorch

(3)创建一个名为pytorch的虚拟环境

conda create -n pytorch python=3.7

注意:在创建环境的时候遇到了如下错误:

ubuntu16.04安装Anaconda+Pycharm+Pytorch

写入如下代码即可解决

 1 sudo chmod 777 -R ~/anaconda3/

2 sudo chmod 777 -R ~/.conda/ 

来源:https://blog.csdn.net/melxy1997/article/details/104420455?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-2.nonecase&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-2.nonecase

激活虚拟环境

 1 source activate pytorch 

ubuntu16.04安装Anaconda+Pycharm+Pytorch

3.安装pytorch

(1)ubuntu已更换过镜像源,在安装过程中仍然很慢。

配置源:

sudo gedit ~/.condarc

配置文件修改为:

 1 channels:
 2   - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
 3   - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/menpo/
 4   - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
 5   - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
 6   - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
 7   - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
 8   - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
 9   - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
10 show_channel_urls: true

(2)命令行安装pytorch(注意一定去掉-c):

ubuntu16.04安装Anaconda+Pycharm+Pytorch


 1 conda install pytorch torchvision cudatoolkit=10.1 

参考:1.配置源参考https://blog.csdn.net/watermelon1123/article/details/88122020

  2.若未更换镜像源可参考:https://blog.csdn.net/weixin_43876206/article/details/100924378

(3)测试pytorch是否安装成功

 1 source activate pytorch

pytorch是我建立的虚拟环境名,可根据自己的进行修改

2 python3

3 import torch

4 torch.cuda.is_available() 

ubuntu16.04安装Anaconda+Pycharm+Pytorch

 4.安装pycharm

具体安装可参考https://blog.csdn.net/qq_38451119/article/details/81023766

(1)下载Pycharm安装包,提取出来

提取完毕后在pycharm的bin文件夹下打开终端,输入

 1 ./pycharm.sh 进行安装即可.

(2)安装完毕,进行环境配置,

one:.打开pycharm, 依次点击 file - > Settings- >Project: xx - >Project Interpreter

two:点击右上角的小齿轮,点击弹出来的Add Python Interpreter:

three:选择anconda,选中穿件的anconda (pytorch)环境,保存即可

ubuntu16.04安装Anaconda+Pycharm+Pytorch

(3)测试:

ubuntu16.04安装Anaconda+Pycharm+Pytorch