新机迁移-hexo\vscode\便携git\miniconda\i卡环境配置

hexo配置过程

1.安装nvm

官网下载安装包即可,我的版本是1.1.11

2.安装node

我的版本是v22.13.0,使用命令nvm install v22.13.0

3.解决npm报错

输入nvm use npm install -g hexo-cli切换到node-v22.13.0版本,再输入npm -v会出现:

1
2
3
4
5
npm : 无法加载文件 C:\Program Files\nodejs\npm.ps1,因为在此系统上禁止运行脚本。有关详细信息,请参阅 https:/go.microsoft.com/fwlink/?LinkID=135170 中的 about_Execution_Policies。
所在位置 行:1 字符: 1
+ npm -v
+ CategoryInfo : SecurityError: (:) [],PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess

因为在此系统上禁止运行脚本,也就是说没有权限,输入命令get-ExecutionPolicy得到:

1
Restricted

受限制的,表示状态是禁止的,添加权限,输入命令Set-ExecutionPolicy -Scope CurrentUser,再输入参数RemoteSigned得到:

1
2
3
位于命令管道位置 1 的 cmdlet Set-ExecutionPolicy
请为以下参数提供值:
ExecutionPolicy: RemoteSigned

验证,输入get-ExecutionPolicynpm -v得到RemoteSigned和10.9.2:

4.安装hexo

输入npm install -g hexo-cli

5.验证

输入hexo s,博客正常生成和显示

附git便携版配置过程

1.将PortableGit/cmd放入环境变量Path

2.配置全局变量

1
2
git config –global user.name “FrwalkerCn”
git config –global user.email “frwalker.cn@gmail.com”

2.运行git bash输入ssh-keygen -t rsa -C frwalker.cn@gmail.com生成公钥和私钥

3.将公钥配置在github账号的SSH and GPG keys里

4.在/c/Users/luowei/.ssh/config加入:

1
2
3
4
5
Host github.com
HostName ssh.github.com
Port 443
User git
IdentityFile C:/Users/luowei/.ssh/id_rsa

5.测试git是否正常使用,输入 ssh -T git@github.com得到:Hi FrWalkerCn! You’ve successfully authenticated, but GitHub does not provide shell access.

将git配置进vscode

在vscode的setting.json添加Git Bash路径:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
"terminal.integrated.profiles.windows": {
"PowerShell": {
"source": "PowerShell",
"icon": "terminal-powershell"
},
"Command Prompt": {
"path": [
"${env:windir}\\Sysnative\\cmd.exe",
"${env:windir}\\System32\\cmd.exe"
],
"args": [],
"icon": "terminal-cmd"
},
"Git Bash": {
"source": "Git Bash",
"path":"d:/FreeInstallSoftware/PortableGit/bin/bash.exe",
}
},

注意,只有bin/bash.exe是控制台应用程序,可以重定向stdin/stdout/stderr,可用作集成shell;git-bash.exe则是windows应用程序会弹窗而无法集成,以WinMain作为条目。

miniconda

下载地址:https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe

注意安装时不要勾选add path,安装完成后手动将C:\Users\luowei\miniconda3\Scripts加入环境变量,在任意shell里conda init后即可正常使用。

使用方式同conda,见windows10 深度学习环境配置torch、cuda,这里仅记录i卡和n卡的配置区别,因为新电脑是i卡。

i卡配置

1.安装驱动

官网搜索后安装即可,我的是英特尔显卡a770,对应驱动网址:https://www.intel.com/content/www/us/en/download/785597/intel-arc-iris-xe-graphics-windows.html
安装前最好使用DDU软件在安全模式下卸载干净之前的驱动

2.配置torch环境

1
2
conda create -n A770Pytorch python pip
pip install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/xpu

(如果想要删除,使用conda remove A770Pytorch --all)

3.验证

conda activate A770Pytorch激活环境在python控制台验证可以得到:

1
2
3
4
(A770Pytorch) PS C:\Users\luowei> python
>>> import torch
>>> torch.xpu.is_available()
True

使用https://gitee.com/Pauntech/Pytorch-2.5的示例进行训练:

1
2
3
4
5
6
7
8
9
10
11
(A770Pytorch) PS C:\Users\luowei\Desktop\Pytorch-2.5-master> python .\train_on_arc.py
100.0%
Initiating training
C:\Users\luowei\Desktop\Pytorch-2.5-master\train_on_arc.py:41: UserWarning: Converting a tensor with requires_grad=True to a scalar may lead to unexpected behavior.
Consider using tensor.detach() first. (Triggered internally at C:\actions-runner\_work\pytorch\pytorch\pytorch\aten\src\ATen\native\Scalar.cpp:23.)
iteration_loss = loss.item()
Iteration [10/3125], Loss: 3.6445
Iteration [20/3125], Loss: 2.6565
Iteration [30/3125], Loss: 2.6902
Iteration [40/3125], Loss: 2.3816
Iteration [50/3125], Loss: 2.5507

验证成功