资讯 小学 初中 高中 语言 会计职称 学历提升 法考 计算机考试 医护考试 建工考试 教育百科
栏目分类:
子分类:
返回
空麓网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
空麓网 > 计算机考试 > 软件开发 > 后端开发 > Python

conda基本命令

Python 更新时间: 发布时间: 计算机考试归档 最新发布

conda基本命令

ubuntu20.04支持的的anaconda安装包

# 清华anaconda镜像站 https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/?C=M&O=Dwget https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-2023.03-1-Linux-x86_64.sh# 安装(一路enter和yes就行)bash 包名.sh

设置环境变量

# 添加环境变量vim ~/.bashrc# 输入i修改文件添加如下内容export PATH=/home/l/anaconda3/bin:$PATH# 启动环境变量source ~/.bashrc# 查看conda是否安装成功conda -V

conda切换清华源

# 往这个文件里写入下面的channelsvim  ~/.condarc# 粘贴channels:  - defaultsshow_channel_urls: truedefault_channels:  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2custom_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  pytorch-lts: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud  simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud# 清除索引缓存,保证用的是镜像站提供的索引conda clean -i # 切换回默认源(其实这个命令就是删除上述通道)conda config --remove-key channels

conda创建虚拟环境

conda create --name xxx python=3.8

创建不成的话用下图中的方法

pytorch常用版本安装命令

# pip版torch1.12.1 cuda11.3pip install torch==1.12.1+cu113 torchvision==0.13.1+cu113 torchaudio==0.12.1 --extra-index-url https://download.pytorch.org/whl/cu113# conda版torch1.12.1 cuda11.3conda install pytorch==1.12.1 torchvision==0.13.1 torchaudio==0.12.1 cudatoolkit=11.3 -c pytorch# pip版torch2.0 cuda11.8pip install torch==2.0.0+cu118 torchvision==0.15.1+cu117 torchaudio==2.0.1 --index-url https://download.pytorch.org/whl/cu118# conda版torch2.0 cuda11.8conda install pytorch==2.0.0 torchvision==0.15.0 torchaudio==2.0.0 pytorch-cuda=11.8 -c pytorch -c nvidia

安装不成的话用下图中的方法

测下gpu是否可用

pythonimport torchtorch.cuda.is_available()

虚拟环境改名(只能通过克隆一个新的环境,然后删掉老的环境来解决这个问题)

conda create --name python32(新名字) --clone python321(老名字)conda remove --name old_name --all

查询当前anaconda中有哪些虚拟环境

conda env list
转载请注明:文章转载自 http://www.konglu.com/
本文地址:http://www.konglu.com/it/1094737.html
免责声明:

我们致力于保护作者版权,注重分享,被刊用文章【conda基本命令】因无法核实真实出处,未能及时与作者取得联系,或有版权异议的,请联系管理员,我们会立即处理,本文部分文字与图片资源来自于网络,转载此文是出于传递更多信息之目的,若有来源标注错误或侵犯了您的合法权益,请立即通知我们,情况属实,我们会第一时间予以删除,并同时向您表示歉意,谢谢!

我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2023 成都空麓科技有限公司

ICP备案号:蜀ICP备2023000828号-2