1.2.Pytorch安装

1.2.1.Conda安装Pythorch,换源

1 conda添加清华镜像源
查看源

conda config --show-sources

由于从官方的conda源中下载速度过于缓慢,我们需要配置清华镜像源:

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 --set show_channel_urls yes

为了保险起见,建议同时添加第三方conda源:

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/menpo/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --set show_channel_urls yes

2 创建并进入虚拟环境

conda create -n pytorchconda activate pytorch

1.2.2.pytorch官网

官网开始学习的地址:https://pytorch.org/get-started/locally/;点击相关的内容,可以看到如下的内容:

在图片的最下方可以看到Run this Command,这个就是要运行的命令。如上显示的内容(注意:如果下载的慢,就使用-i命令指定清华的源):

pip install torch===1.7.1 torchvision===0.8.2 torchaudio===0.7.2 -f https://download.pytorch.org/whl/torch_stable.html -i https://pypi.tuna.tsinghua.edu.cn/simple

选择另外的,可能会出现类似:

NOTE: Python 3.9 users will need to add '-c=conda-forge' for installation
conda install pytorch torchvision torchaudio cudatoolkit=10.1 -c pytorch (但是这里一定要注意,去掉-c pytorch,安装的时候才会默认从清华源下载相应的包,因此这里用命令行)
conda install pytorch torchvision torchaudio cudatoolkit=10.1

接着等待安装成功就好了。

1.2.3.验证

为了确保PyTorch被正确安装,我们可以运行样例PyTorch代码来验证安装。这里我们将构造一个随机初始化张量。

# -*- coding: UTF-8 -*-import torch
x = torch.rand(5,3)
print(x)print(torch.__version__)

结果应该是:

tensor([[0.2966, 0.2469, 0.2908],[0.1125, 0.0722, 0.1402],[0.4008, 0.0162, 0.7278],[0.3127, 0.6203, 0.2005],[0.2571, 0.6653, 0.8652]])
1.7.1+cpu

1.3.安装jupyter

参考博文:https://blog.csdn.net/yu1014745867/article/details/84191485

Jupyter Notebook(此前被称为IPython notebook)是一个交互式笔记本,支持运行40多种编程语言。

Jupyter Notebook的本质是一个为web应用程序,便于创建和共享程序文档,支持实时代码,数学方程,可视化和markdown

1.3.1.卸载、安装、启动jupyter

打开Anaconda PowerShell,然后输入:

pip install jupyter

执行效果如下:

(base) PS C:\Users\toto> pip install jupyter
Requirement already satisfied: jupyter in d:\installed\anaconda3\lib\site-packages (1.0.0)
Requirement already satisfied: notebook in d:\installed\anaconda3\lib\site-packages (from jupyter) (6.0.1)
Requirement already satisfied: jupyter-console in d:\installed\anaconda3\lib\site-packages (from jupyter) (6.0.0)
Requirement already satisfied: ipywidgets in d:\installed\anaconda3\lib\site-packages (from jupyter) (7.5.1)
Requirement already satisfied: nbconvert in d:\installed\anaconda3\lib\site-packages (from jupyter) (5.6.0)
Requirement already satisfied: qtconsole in d:\installed\anaconda3\lib\site-packages (from jupyter) (4.5.5)
Requirement already satisfied: ipykernel in d:\installed\anaconda3\lib\site-packages (from jupyter) (5.1.2)
Requirement already satisfied: nbformat in d:\installed\anaconda3\lib\site-packages (from notebook->jupyter) (4.4.0)
Requirement already satisfied: jupyter-client>=5.3.1 in d:\installed\anaconda3\lib\site-packages (from notebook->jupyter) (5.3.3)
Requirement already satisfied: prometheus-client in d:\installed\anaconda3\lib\site-packages (from notebook->jupyter) (0.7.1)
Requirement already satisfied: pyzmq>=17 in d:\installed\anaconda3\lib\site-packages (from notebook->jupyter) (18.1.0)
Requirement already satisfied: jupyter-core>=4.4.0 in d:\installed\anaconda3\lib\site-packages (from notebook->jupyter) (4.5.0)
Requirement already satisfied: terminado>=0.8.1 in d:\installed\anaconda3\lib\site-packages (from notebook->jupyter) (0.8.2)
Requirement already satisfied: tornado>=5.0 in d:\installed\anaconda3\lib\site-packages (from notebook->jupyter) (6.0.3)


启动jupyter

(base) PS C:\Users\toto> jupyter notebook

界面效果:

(base) PS C:\Users\toto> jupyter notebook
[I 12:28:21.470 NotebookApp] The port 8888 is already in use, trying another port.
[I 12:28:21.533 NotebookApp] JupyterLab extension loaded from D:\installed\Anaconda3\lib\site-packages\jupyterlab
[I 12:28:21.533 NotebookApp] JupyterLab application directory is D:\installed\Anaconda3\share\jupyter\lab
[I 12:28:21.536 NotebookApp] Serving notebooks from local directory: C:\Users\toto
[I 12:28:21.536 NotebookApp] The Jupyter Notebook is running at:
[I 12:28:21.537 NotebookApp] http://localhost:8889/?token=c5fadcb59ade1027bfa184f07ca753f4acb13185241fa6be
[I 12:28:21.537 NotebookApp]  or http://127.0.0.1:8889/?token=c5fadcb59ade1027bfa184f07ca753f4acb13185241fa6be
[I 12:28:21.537 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 12:28:21.760 NotebookApp]To access the notebook, open this file in a browser:file:///C:/Users/toto/AppData/Roaming/jupyter/runtime/nbserver-12424-open.htmlOr copy and paste one of these URLs:http://localhost:8889/?token=c5fadcb59ade1027bfa184f07ca753f4acb13185241fa6beor http://127.0.0.1:8889/?token=c5fadcb59ade1027bfa184f07ca753f4acb13185241fa6be
[I 12:31:25.070 NotebookApp] 302 GET /?token=c5fadcb59ade1027bfa184f07ca753f4acb13185241fa6be (127.0.0.1) 1.00ms
[I 12:31:32.990 NotebookApp] Creating new file in
[I 12:32:10.919 NotebookApp] Creating new notebook in
[I 12:32:13.228 NotebookApp] Kernel started: 082a09a5-e52a-40f2-904f-3870a737fdc6
[I 12:33:14.333 NotebookApp] Saving file at /Untitled1.ipynb

1.3.2.配置Jupyter notebook

1、命令行输入命令:

(base) PS C:\Users\toto> jupyter notebook --generate-config
Writing default config to: C:\Users\toto\.jupyter\jupyter_notebook_config.py
(base) PS C:\Users\toto>

2、打开”.jupyter”文件夹,可以看到里面有个配置文件

3、修改jupyter_notebook_config.py配置文件
找到”c.NotebookApp.notebook_dir=…”,把路径改成自己的工作目录。


4、配置完成后,重新jupyter notebook启动即可
5、启动方式:
6、Anaconda–>Anaconda Prompt -->命令行输入:

jupyter notebook
7、启动后默认的打开路径就是之前配置好的路径啦。

1.3.3.使用

1、运行jupyter notebook
2、需要新建python文件的话,点击New–>Python3

3、新建后,页面显示如下,菜单栏也出来了,就可以开始编写文件啦。

02/03_Pytorch安装、Conda安装Pythorch,换源、pytorch官网、验证、安装jupyter、卸载、安装、启动jupyter、配置Jupyter notebook、使用相关推荐

  1. wheel安装+使用wheel安装第三方库+临时换源安装和永久换源安装

    上一篇文章:Python要点及其环境搭建+Pycharm简单使用教程 wheel安装+使用wheel安装第三方库+临时换源安装和永久换源安装 wheel安装 使用wheel安装第三方库 临时换源安装 ...

  2. kali2020 linux安装教程,附换源教程

    Kali2020 Linux安装教程,附换源教程 环境配置 安装步骤 环境配置 kali 2020.4 VMWare 16 安装步骤 首先打开VMWare主页点击创建新的虚拟机. 配置直接选典型,点击 ...

  3. Kali安装pip以及pip换源

    Kali安装pip以及pip换源 参考 参考一:linux更换pip源_绛洞花主敏明的博客-CSDN博客_linux pip换源 参考二:解决kali 2020 没有pip 问题_高木正雄的博客-CS ...

  4. Ubuntu系统 不使用snap安装firefox,使用firefox官网下载的安装包安装firefox

    Ubuntu系统 不使用snap安装firefox,使用firefox官网下载的安装包安装firefox 一.源起 二.寻找原因记录(之前卸载snap的原因!!,本节主要说snap的事,装firefo ...

  5. memcached的基本命令(安装、卸载、启动、配置相关)

    memcached的基本命令(安装.卸载.启动.配置相关): -p 监听的端口  -l 连接的IP地址, 默认是本机   -d start 启动memcached服务  -d restart 重起me ...

  6. centos的官网下载和vm16虚拟机安装centos8【保姆级教程图解】

    centos8的官网下载和vm16虚拟机安装centos8[保姆级图解] centos下载 vm虚拟机安装centos 可能出现的问题vcpu-0 centos下载 centos官网:https:// ...

  7. 小米机器人CC插件PHP源码官网+全新UI界面

    正文: 小米机器人CC插件PHP源码官网+全新UI界面,支持开通授权/代理商和授权商,这程序号称最牛CC插件,有兴趣自行去测试吧. 程序: lanzou.com/iSkZ404scioh 图片:

  8. 一劳永逸-当换源解决不了pyrit各种原因的安装失败

    在终端执行./fluxion.sh -i后,pyrit始终安装失败,查了网上的方法都是换源,但是换了几个还未解决,而且本人报错信息是关于pyrit所依赖的python版本等出现问题. 解决方案: 手动 ...

  9. whl文件安装库和pip换源

    作者介绍: ♥️作者:小刘在C站 ♥️每天分享课堂笔记,一起努力,共赴美好人生! ♥️夕阳下,是最美的绽放. 目录 一.whell介绍 二.whell实现方式 三.whell安装实现 方式一 方式二 ...

最新文章

  1. P6134 [JSOI2015]最小表示(拓扑排序递推 + bitset优化,可达性统计变种)
  2. 1098 Insertion or Heap Sort (25 分)【难度: 中 / 插入排序 堆排序 堆排序不会未完成】
  3. Nginx服务器的Web请求处理机制
  4. 来自未来,2022 年的前端人都在做什么?
  5. 如果看了此文你还不懂傅里叶变换,那就过来掐死我吧【完整版】(ZZ伯乐在线)...
  6. python基础学习笔记(九)
  7. EasyObjects.Net
  8. Java工程师必备资料,整合1G多jar包,网速慢也没关系,关注获取更多资源
  9. Linux学习笔记第二周第四次课(2月1日)
  10. php yar swoole 比较,Hprose 和 Yar 的性能比较
  11. 成倍提升ORM系统SQL性能的一个方法
  12. 计算机系统文件夹打不开,为什么打不开文件夹
  13. 用PXE方法从裸机批量推Oracle 11gR2 RAC环境
  14. 芝法酱躺平攻略(5)—— SpringBoot编写公主连结公会战报刀工具
  15. Sencha的Eclipse插件提示和技巧
  16. hotspot源码角度看OOP之类属性的底层实现(一)
  17. 2020ACM俱乐部后备营个人训练赛第七、八、九场
  18. c# 收取邮件 解析_c#收取邮件
  19. 正确安装AMD X2双核驱动及补丁的方法
  20. juniper防火墙端口映射

热门文章

  1. 广度优先搜索算法BFS讲解以及python 实现
  2. MATLAB机器学习系列-4函数篇
  3. VTK:参数化超椭球用法实战
  4. VTK:细胞定位器可视化用法实战
  5. boost::polygon模块实现多边形间隔相关的测试程序
  6. Boost.MultiIndex 使用 Boost.Interprocess 分配器的示例
  7. boost::mp11::mp_set_contains相关用法的测试程序
  8. boost::graph_property_iter_range用法的测试程序
  9. boost::function_types::is_function用法的测试程序
  10. GDCM:gdcm::IconImageGenerator的测试程序