深度学习笔记:5.PyTorch的安装

PyTorchicon-default.png?t=N7T8https://pytorch.org/

 复制最后一句

conda install pytorch torchvision torchaudio pytorch-cuda=12.1 -c pytorch -c nvidia

创建虚拟环境


(base) C:\Users\Administrator>conda create -n pytorch python=3.8
Channels:
 - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
 - defaults
Platform: win-64
Collecting package metadata (repodata.json): done
Solving environment: done

## Package Plan ##

  environment location: d:\anaconda3\envs\pytorch

  added / updated specs:
    - python=3.8


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    pip-24.0                   |   py38haa95532_0         2.8 MB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    python-3.8.19              |       h1aa4202_0        18.9 MB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    setuptools-69.5.1          |   py38haa95532_0        1003 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    wheel-0.43.0               |   py38haa95532_0         137 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    ------------------------------------------------------------
                                           Total:        22.9 MB

The following NEW packages will be INSTALLED:

  ca-certificates    anaconda/pkgs/main/win-64::ca-certificates-2024.3.11-haa95532_0
  libffi             anaconda/pkgs/main/win-64::libffi-3.4.4-hd77b12b_1
  openssl            anaconda/pkgs/main/win-64::openssl-3.0.13-h2bbff1b_2
  pip                anaconda/pkgs/main/win-64::pip-24.0-py38haa95532_0
  python             anaconda/pkgs/main/win-64::python-3.8.19-h1aa4202_0
  setuptools         anaconda/pkgs/main/win-64::setuptools-69.5.1-py38haa95532_0
  sqlite             anaconda/pkgs/main/win-64::sqlite-3.45.3-h2bbff1b_0
  vc                 anaconda/pkgs/main/win-64::vc-14.2-h2eaa2aa_1
  vs2015_runtime     anaconda/pkgs/main/win-64::vs2015_runtime-14.29.30133-h43f2093_3
  wheel              anaconda/pkgs/main/win-64::wheel-0.43.0-py38haa95532_0


Proceed ([y]/n)? y


Downloading and Extracting Packages:
python-3.8.19        | 18.9 MB   | ##########################################################################3  |  98%
pip-24.0             | 2.8 MB    | ############################################################################ | 100%
setuptools-69.5.1    | 1003 KB   | ############################################################################ | 100%

Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
#     $ conda activate pytorch
#
# To deactivate an active environment, use
#
#     $ conda deactivate


(base) C:\Users\Administrator>

 

(pytorch) C:\Users\Administrator>conda install pytorch torchvision torchaudio pytorch-cuda=12.1 -c pytorch -c nvidia

漫长的等待。

测试是否成功。

done

(pytorch) C:\Users\Administrator>python
Python 3.8.19 (default, Mar 20 2024, 19:55:45) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> torch.__version__
'2.3.0'
>>> x=torch.rand(5)
>>> print(x)
tensor([0.0358, 0.8986, 0.6291, 0.2144, 0.4557])
>>> torch.cuda.is_available()
True
>>>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

PyAIGCMaster

1毛钱也是爱

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值