一、简述
年底了,身上也没有其他项目,恰好乘着这个机会学一下pytorch 和YOLOv8.
1、下载abaconda
https://repo.anaconda.com/archive/
2、安装
环境变量要✔
其他一直下一步
3、测试
(base) C:\Users\alber>conda -V
conda 23.1.0
(base) C:\Users\alber> conda info -e
# conda environments:
#
base * D:\Anaconda
(base) C:\Users\alber>python -V
Python 3.10.9
(base) C:\Users\alber>conda env list
# conda environments:
#
base * D:\Anaconda
// 安装python 3.10.9 并创建一个虚拟环境 名称为py3_10_9_torch
(base) C:\Users\alber>conda create -n py3_10_9_torch python=3.10.9
Collecting package metadata (current_repodata.json): done
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: done
==> WARNING: A newer version of conda exists. <==
current version: 23.1.0
latest version: 23.11.0
Please update conda by running
$ conda update -n base -c defaults conda
Or to minimize the number of packages updated during conda update use
conda install conda=23.11.0
## Package Plan ##
environment location: D:\Anaconda\envs\py3_10_9_torch
added / updated specs:
- python=3.10.9
The following packages will be downloaded:
package | build
---------------------------|-----------------
ca-certificates-2023.12.12 | haa95532_0 127 KB
libffi-3.4.4 | hd77b12b_0 113 KB
openssl-1.1.1w | h2bbff1b_0 5.5 MB
pip-23.3.1 | py310haa95532_0 2.9 MB
python-3.10.9 | h966fe2a_2 15.8 MB
setuptools-68.2.2 | py310haa95532_0 942 KB
sqlite-3.41.2 | h2bbff1b_0 894 KB
tzdata-2023d | h04d1e81_0 117 KB
wheel-0.41.2 | py310haa95532_0 127 KB
xz-5.4.5 | h8cc25b3_0 593 KB
------------------------------------------------------------
Total: 27.0 MB
The following NEW packages will be INSTALLED:
bzip2 pkgs/main/win-64::bzip2-1.0.8-he774522_0
ca-certificates pkgs/main/win-64::ca-certificates-2023.12.12-haa95532_0
libffi pkgs/main/win-64::libffi-3.4.4-hd77b12b_0
openssl pkgs/main/win-64::openssl-1.1.1w-h2bbff1b_0
pip pkgs/main/win-64::pip-23.3.1-py310haa95532_0
python pkgs/main/win-64::python-3.10.9-h966fe2a_2
setuptools pkgs/main/win-64::setuptools-68.2.2-py310haa95532_0
sqlite pkgs/main/win-64::sqlite-3.41.2-h2bbff1b_0
tk pkgs/main/win-64::tk-8.6.12-h2bbff1b_0
tzdata pkgs/main/noarch::tzdata-2023d-h04d1e81_0
vc pkgs/main/win-64::vc-14.2-h21ff451_1
vs2015_runtime pkgs/main/win-64::vs2015_runtime-14.27.29016-h5e58377_2
wheel pkgs/main/win-64::wheel-0.41.2-py310haa95532_0
xz pkgs/main/win-64::xz-5.4.5-h8cc25b3_0
zlib pkgs/main/win-64::zlib-1.2.13-h8cc25b3_0
Proceed ([y]/n)? y
Downloading and Extracting Packages
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
# $ conda activate py3_10_9_torch
#
# To deactivate an active environment, use
#
# $ conda deactivate
(base) C:\Users\alber>conda activate py3_10_9_torch
(py3_10_9_torch) C:\Users\alber>conda env list
# conda environments:
#
base D:\Anaconda
py3_10_9_torch * D:\Anaconda\envs\py3_10_9_torch
(py3_10_9_torch) C:\Users\alber>conda list
# packages in environment at D:\Anaconda\envs\py3_10_9_torch:
#
# Name Version Build Channel
bzip2 1.0.8 he774522_0
ca-certificates 2023.12.12 haa95532_0
libffi 3.4.4 hd77b12b_0
openssl 1.1.1w h2bbff1b_0
pip 23.3.1 py310haa95532_0
python 3.10.9 h966fe2a_2
setuptools 68.2.2 py310haa95532_0
sqlite 3.41.2 h2bbff1b_0
tk 8.6.12 h2bbff1b_0
tzdata 2023d h04d1e81_0
vc 14.2 h21ff451_1
vs2015_runtime 14.27.29016 h5e58377_2
wheel 0.41.2 py310haa95532_0
xz 5.4.5 h8cc25b3_0
zlib 1.2.13 h8cc25b3_0
(py3_10_9_torch) C:\Users\alber>pip list
Package Version
---------- -------
pip 23.3.1
setuptools 68.2.2
wheel 0.41.2
(py3_10_9_torch) C:\Users\alber>
二、 安装cuda
查看cuda 对应的版本
下载cuda
检查:nvcc -V
三、安装pytorch
清华 下载路径
https://download.pytorch.org/whl/torch_stable.html
安装
pip install "torch-2.1.1+cu121-cp310-cp310-win_amd64.whl" -i https://pypi.tuna.tsinghua.edu.cn/simple/
测试
检查pytorch 是否安装成功
import torch
检查GPU是否能用 以及pytorch 的版本
import torch
print(torch.__version__)#查看pytorch版本
print(torch,torch.cuda.is_available())#看GPU能不能用,能用返回Ture
四、torchvision
https://download.pytorch.org/whl/torch_stable.html
安装
(base) D:\toruchvision> pip install "torchvision-0.16.0+cu121-cp310-cp310-win_amd64.whl" -i https://pypi.tuna.tsinghua.edu.cn/simple/
测试
conda list
五、jupyter安装
直接用命令下载
conda install ipython
安装
conda install jupyter
测试:
jupyter notebook
六、pycharm 安装及其配置
这里最主要的就是找到环境并和pycharm 放到里面
测试
终端和anconda 的连接
要先记录anaconda Prompt 的路径
cmd.exe "/K" D:\Anaconda\Scripts\activate.bat D:\Anaconda
将这个放到pycharm 当中
安装使用的话还是在anaconda Prompt 库
镜像源:
阿里云 http://mirrors.aliyun.com/pypi/simple/
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
豆瓣 http://pypi.douban.com/simple/
中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/
清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
学习网站:05jupyter安装_哔哩哔哩_bilibili