VM下运行python
VM下Ubuntu中python运行环境搭建1.虚拟机装minicondaa.下载地址:https://docs.conda.io/en/latest/miniconda.html安装此版本,无需手动下载,使用命令:wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh推荐使用镜像源下载:wget htt
VM下Ubuntu中pytorch环境搭建
1.虚拟机装miniconda
a.下载
地址:https://docs.conda.io/en/latest/miniconda.html
安装此版本,无需手动下载,使用命令:
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
推荐使用镜像源下载:
wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/Miniconda3-py38_4.8.3-Linux-x86_64.sh --no-check-certificate
b.安装
bash Miniconda3-py38_4.8.3-Linux-x86_64.sh
安装过程中根据提示输入enter或yes
c.验证安装
重启终端(必须),运行下方命令,显示版本号则安装成功
conda -V
2.配置镜像源
a.在用户目录(/home/xxx)下新建.condarc文件
touch .condarc
b.vim打开.condarc文件,写入下方内容保存后退出
channels:
- defaults
show_channel_urls: true
channel_alias: https://mirrors.tuna.tsinghua.edu.cn/anaconda
default_channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
c.执行以下命令清除索引缓存,保证用的是镜像站提供的索引
conda clean -i
d.查看是否已经换源
conda config --show
3.使用特定的python版本
a.下载
conda install python=3.8
b.若将python安装到一个新的环境中
conda create -n <my_environment> python=3.8
4.环境管理
官方文档:Managing environments — conda 4.12.0.post41+897384a0 documentation
https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html
a.创建环境
conda create -n pytorch python=3.8
弹出提示,输入 y,即可安装
安装成功后,输入以下指令:
conda info --envs
b.激活环境
conda activate pytorch
c.安装pytorch
官网:https://pytorch.org/
conda install pytorch torchvision torchaudio cudatoolkit=10.2
去掉了官网给的 -c pytorch,否则可能下载失败
验证是否安装成功
在自己的环境中,输入python
import torch
print(torch.cuda.is_available())
5.安装pycharm并且使用anaconda虚拟环境
下载地址:https://www.jetbrains.com/pycharm/
选择自己系统对应版本,这里主要针对linux,下载community版本就够用了
下载成功之后,在浏览器查看下载的文件,然后打开压缩包,把文件移动到所需要的位置,打开pycharm->bin,在这个目录中右键打开终端输入
./pycharm.sh
更多推荐
所有评论(0)