conda虚拟环境创建与深度学习环境搭建

Conda创建虚拟环境

  • 创建虚拟环境:

    conda create -n lmz python==3.7.4
    
  • 删除虚拟环境

    conda env remove --name lmz
    
  • 列出所有虚拟环境

    conda env list
    
    conda info -e
    
  • 查看安装的包

    conda list
    
  • 关闭虚拟环境

    deactivate lmz
    
  • 检验是否安装及当前conda的版本

    conda -V
    
  • 检查更新conda

    conda update conda
    
  • 进入虚拟环境后使用如下指令可以只在当前环境中安装删除包

    conda install pkg_name  
    conda uninstall pkg_name 
    pip install pkg_name 
    pip uninstall pkg_name
    
  • 使用国内源加速

    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 –add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/ 
    
    conda config –set show_channel_urls yes
    
  • 安装第三方依赖包

    cd E:\python #例如
    
    pip install -r requirements.txt
    
  • 导出requirements.txt

    conda list -e > requirements.txt
    
  • 在jupyter中添加内核

    • 安装ipykernel

      pip install ipykernel
      
    • 添加虚拟环境kernel

      python -m ipykernel install --user --name envname
      
    • 查看当前可用的虚拟环境内核

      jupyter kernelspec list
      
    • 删除内核

      jupyter kernelspec remove envname
      

深度学习环境搭建(Pytorch)

  • 注意版本匹配问题:python,pytorch,cuda版本;python与numpy版本

  • 下载pytorch相关的库

    conda install pytorch==1.8.0 torchvision==0.9.0 torchaudio==0.8.0 cudatoolkit=11.1 -c pytorch -c conda-forge
    
    conda install pyg -c pyg -c conda-forge
    
  • 官方链接

    torch_geometric

    Pytorch

  • 查看pytorch版本

    先进入python交互界面

    import torch
    print(torch.__version__) #查看pytorch版本
    print(torch.cuda.is_available()) #查看cuda是否可用 输出为True 或者False
    
  • 10
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值