Cuicheng's 博客

日啖荔枝三百颗 不辞长作岭南人

0%

机器学习

设置终端翻墙

script
1
2
3
4
set http_proxy=127.0.0.1:1080
set https_proxy=127.0.0.1:1080
# 测试
curl -v http://www.google.com

创建虚拟环境

1
conda create -n pytorch python=3.7

直接安装

script
1
2
conda install pytorch torchvision cudatoolkit=10.2 -c pytorch
# 使用国内源时,不需要后面的 -c pytorch

问题解决

script
1
2
3
4
5
6
7
8
9
10
11
12
打开终端,提示 “无法加载文件C:\XXX\WindowsPowerShell\profile.ps1,
因为在此系统上禁止运行脚本” 的错误

FIX

1. 以管理员身份运行PowerShell

2. 执行:get-ExecutionPolicy,回复Restricted,表示状态是禁止的

3.执行:set-ExecutionPolicy RemoteSigned即可 选择 Y

一定要以管理员的身份运行PowerShell,不是cmd窗口

国内源

修改位置为  ‪C:\Users\mklop\.condarc
script
1
2
3
4
5
6
7
8
9
ssl_verify: true
channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
- https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
- defaults
show_channel_urls: true

离线安装部分内容

注意需要在包的位置运行, 下载地址 报错信息中获取
script
1
conda install --use-local pytorch-1.6.0-py3.7_cuda102_cudnn7_0.tar.bz2