当前位置:网站首页>Conda+pytorch environment tutorial
Conda+pytorch environment tutorial
2022-07-26 19:24:00 【Know what you know and slowly understand what you don't know】
conda+pytorch Environmental tutorials
Preface
conda Able to manage different Python Environmental Science , Different environments are isolated from each other , Not affecting each other . To avoid mistakes caused by the messy original environment .
That is, to the original environment copy, Is a copy of the original environment .
It can support multiple environments on one computer .
conda It is a configuration isolation python Tools for the environment
Because sometimes we need different versions python Or different versions of pip modular ( For example, you need to run two from github Up and down code , their tensorflow Version one requirement 1.0 One requirement 2.0)
conda It can be realized pip Different versions of modules coexist , It can also be realized python Different versions coexist
conda It's just a tool , It has two distributions , Namely Anaconda and Miniconda
anaconda It is a large and comprehensive set of tools , It includes many commonly used pip modular ( Such as numpy、pandas、scipy、matplotlib etc. ), It also has graphical management tools
miniconda It's a simple conda Tools , Only bring a few python Necessary bags , Clean and pure , You can build any environment according to your own needs
miniconda Than anaconda Very small , It can realize all daily needs , Just do it yourself
Default conda Would be base Environmental Science , Of course you can put any bag you need here , If you want to create multiple isolated virtual environments , You also need to master conda Creation and switching of environment .
One 、 newly build conda Environmental Science
newly build conda Environmental Science
conda create --name yolov5 python=3.9
name Is the name of the newly created virtual environment
python=3.9 yes python Version number of , Version can be specified .
View existing environment
conde info -e
The name of my new environment is yolov5
Two 、 Configure Tsinghua TUNA Mirror source
1. Generate .condarc file
stay Anaconda prompt Command window , Input in :
conda config --set show_channel_urls yes
After that, you can go to C:\Users\xxx see .condarc file
channels:
- defaults
show_channel_urls: true
default_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/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
You can add Anaconda Python Free warehouse .
stay Anaconda prompt Command window to run conda clean -i Clear index cache , Make sure you use the index provided by the mirror station
3、 ... and 、 install pytorch
After activating the environment , You can install pytorch. Get into pytorch Official website selection PyTorch Official website
Web page drop-down , You can see the following figure , The official website will automatically according to your computer , What is displayed is what you can install CUDA edition , And give the installation command 
Copy the commands provided by the web page
open Anaconda prompt Command window , Enter the environment you just created ( My environment name is yolov5)
conda activate yolov5
Copy the long string of commands copied from the official website 
The download process will take a lot of time , And the network speed is better
Four 、 test
open Anaconda prompt Command window , Activate the environment , Input python, Get into python In the development environment
Enter the following command
import torch
torch.cuda.is_available()
Results output True success !!
5、 ... and 、conda command
newly build conda Environmental Science
conda create --name yourEnv python=3.9
yourEnv Is the name of the newly created virtual environment , Created , It can hold anaconda Found in the directory envs/yourEnv Catalog
python=3.9: yes python Version number of . You can also specify 【python=3.6】, If not specified , The default is to install anaconda when python Version of
If you want to install... While creating the environment python Some of my bags :
conda create -n yourEnv python=3.6 numpy pandas
Activate conda Environmental Science
windows ==> activate yourEnv
linux/mac ==> source yourEnv
List all current environments
conda info -e
perhaps
conda env list
Check the package and version of the current environment
conda list
All packages for a specific environment
conda list -n env_name
install numpy sklearn package
conda install numpy scikit-learn
Delete your environment
conda env remove -n yourEnv --all
Quit current conda Environmental Science
conda deactivate
Environment switching
conda activate YourEnvs
Clone virtual environment
conda create -n newYourEnvs --clone oldYourEnvs
adopt export Command export environment configuration Will generate a .yml file
conda env export > environment.yml
open environment.yml You can see the environmental information , The following command can reinstall the same environment
conda env create -f environment.yml
Reference link
PyTorch The latest installation tutorial
About conda Configuration of the environment , Just read this one
边栏推荐
- JVM内存模型之Volatile关键字
- 密码一致,总显示如下图
- After the exam on June 25, see how the new exam outline reviews PMP
- 【C语言实现】----动态/文件/静态通讯录
- Reentrantlock learning --- basic method
- 高防服务器和高防IP的区别
- Machine learning notes - building a recommendation system (6) six automatic encoders for collaborative filtering
- Advanced template (runner's notes)
- How many pairs can an array of leetcode simple questions form
- Complete MySQL database commands
猜你喜欢

LeetCode简单题之数组能形成多少数对

高防服务器和高防IP的区别

用低代码搭建千人食品制造企业高效管理系统案例分析
![[server data recovery] data recovery case of server storage shared folder loss](/img/bf/3f86a4e8abd4e045b022fd7574636f.png)
[server data recovery] data recovery case of server storage shared folder loss

ReentrantLock学习之---释放锁过程

Detailed tutorial on installing redis on Linux

Introduction to Seata

C#上位机开发—— 修改窗口图标和exe文件图标

C#获取本地时间/系统时间

The first letter of leetcode simple question appears twice
随机推荐
【MySQL必知必会】 日志Log详解
EN 1504-6混凝土结构保护和修理用产品钢筋锚固—CE认证
C#获取本地时间/系统时间
配置服务器环境
机器学习笔记 - 构建推荐系统(6) 用于协同过滤的 6 种自动编码器
Advanced template (runner's notes)
Distributed transaction Seata
2022t elevator repair examination questions and online simulation examination
Detailed tutorial on installing redis on Linux
Detailed explanation of MySQL master-slave replication configuration
Vs2019 export import configuration
Tensorflow-GPU 1.15安装
节省50%成本 京东云发布新一代混合CDN产品
Unity 农场 2 —— 种植系统
"Weilai Cup" 2022 Niuke summer multi school training camp 1
香港高防IP优势及哪些行业适合使用
Machine learning notes - building a recommendation system (6) six automatic encoders for collaborative filtering
ReentrantLock学习之---释放锁过程
torch.unsqueeze() squeeze() expand() repeat()用法及比较
用低代码搭建千人食品制造企业高效管理系统案例分析