-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsearch.xml
More file actions
220 lines (105 loc) · 20 KB
/
search.xml
File metadata and controls
220 lines (105 loc) · 20 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
<?xml version="1.0" encoding="utf-8"?>
<search>
<entry>
<title>docker配置GPU</title>
<link href="/2024/08/01/docker%E9%85%8D%E7%BD%AEGPU/"/>
<url>/2024/08/01/docker%E9%85%8D%E7%BD%AEGPU/</url>
<content type="html"><![CDATA[<h2 id="docker-配置-GPU"><a href="#docker-配置-GPU" class="headerlink" title="docker 配置 GPU"></a>docker 配置 GPU</h2><h3 id="1-配置库"><a href="#1-配置库" class="headerlink" title="1. 配置库"></a>1. 配置库</h3><pre><code class="sh">curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \ && curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list | \ sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \ sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list</code></pre><h3 id="2-更新源"><a href="#2-更新源" class="headerlink" title="2. 更新源"></a>2. 更新源</h3><pre><code class="sh">sudo apt-get update</code></pre><h3 id="3-安装-NVIDIA-Container-Toolkit"><a href="#3-安装-NVIDIA-Container-Toolkit" class="headerlink" title="3. 安装 NVIDIA Container Toolkit"></a>3. 安装 NVIDIA Container Toolkit</h3><pre><code class="sh">sudo apt-get install -y nvidia-container-toolkit</code></pre>]]></content>
<categories>
<category> docker </category>
</categories>
<tags>
<tag> 实用工具 </tag>
</tags>
</entry>
<entry>
<title>docekr安装</title>
<link href="/2024/08/01/docekr%E5%AE%89%E8%A3%85/"/>
<url>/2024/08/01/docekr%E5%AE%89%E8%A3%85/</url>
<content type="html"><![CDATA[<h2 id="基于-Ubuntu20-04-安装-docker"><a href="#基于-Ubuntu20-04-安装-docker" class="headerlink" title="基于 Ubuntu20.04 安装 docker"></a>基于 Ubuntu20.04 安装 docker</h2><h3 id="1-卸载旧版本-docker"><a href="#1-卸载旧版本-docker" class="headerlink" title="1. 卸载旧版本 docker"></a>1. 卸载旧版本 docker</h3><pre><code class="sh"># 卸载旧版本sudo apt-get purge docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-ce-rootless-extras# 清除旧版 docker 占用的内存sudo apt-get remove --auto-remove docker# 删除无用的相关的配置文件dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P # 删除相关目录rm -rf /etc/systemd/system/docker.service.drm -rf /var/lib/docker # docker 数据存储地址# 更新系统源 sudo apt-get update</code></pre><h3 id="2-配置安装环境"><a href="#2-配置安装环境" class="headerlink" title="2. 配置安装环境"></a>2. 配置安装环境</h3><pre><code class="sh">sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common</code></pre><h3 id="3-添加阿里云的-docekr-GPG-密钥"><a href="#3-添加阿里云的-docekr-GPG-密钥" class="headerlink" title="3. 添加阿里云的 docekr GPG 密钥"></a>3. 添加阿里云的 docekr GPG 密钥</h3><pre><code class="sh">curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -</code></pre><h3 id="4-添加阿里镜像源"><a href="#4-添加阿里镜像源" class="headerlink" title="4. 添加阿里镜像源"></a>4. 添加阿里镜像源</h3><pre><code class="sh">sudo add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable" </code></pre><h3 id="5-查看-docker-版本"><a href="#5-查看-docker-版本" class="headerlink" title="5. 查看 docker 版本"></a>5. 查看 docker 版本</h3><pre><code class="sh">apt-cache madison docker-ceapt-cache madison docker-ce-cli</code></pre><h3 id="6-安装最新版-指定版本-docker"><a href="#6-安装最新版-指定版本-docker" class="headerlink" title="6. 安装最新版 / 指定版本 docker"></a>6. 安装最新版 / 指定版本 docker</h3><pre><code class="sh">#安装最新版 sudo apt-get install -y docker-ce docker-ce-cli#安装5:20.10.21~3-0~ubuntu-kinetic版 sudo apt-get install -y docker-ce=5:27.1.0-1~ubuntu.20.04~focal docker-ce-cli=5:27.1.0-1~ubuntu.20.04~focal</code></pre><h3 id="7-重启-docker"><a href="#7-重启-docker" class="headerlink" title="7. 重启 docker"></a>7. 重启 docker</h3><pre><code class="sh">sudo systemctl restart docker</code></pre><h3 id="8-运行-hello-world-验证-docker-是否安装成功"><a href="#8-运行-hello-world-验证-docker-是否安装成功" class="headerlink" title="8. 运行 hello-world 验证 docker 是否安装成功"></a>8. 运行 hello-world 验证 docker 是否安装成功</h3><pre><code class="sh">docker run hello-world</code></pre>]]></content>
<categories>
<category> docker </category>
</categories>
<tags>
<tag> 实用工具 </tag>
</tags>
</entry>
<entry>
<title>docker常用命令</title>
<link href="/2024/07/23/docker%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4/"/>
<url>/2024/07/23/docker%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4/</url>
<content type="html"><![CDATA[<h2 id="docker常用命令"><a href="#docker常用命令" class="headerlink" title="docker常用命令"></a>docker常用命令</h2><p>显示当前正在运行的<code>docker</code>容器</p><pre><code class="shell">docker ps # -a / --all: 显示所有容器</code></pre><p>显示本地主机上的镜像</p><pre><code class="shell">docker images</code></pre><p>开启指定容器的交互式终端</p><pre><code class="shell">docker exec -it 容器id /bin/bash</code></pre><p>获取容器长<code>ID</code></p><pre><code>docker inspect -f '{{.ID}}' 容器名</code></pre><p>拷贝主机文件到容器中</p><pre><code>docker cp 主机文件路径 容器长ID:docker容器路径</code></pre><p>拷贝容器文件到主机中</p><pre><code>docker cp 容器长ID:docker容器路径 主机文件路径 </code></pre><p>提交容器副本使之成为一个新镜像</p><pre><code class="shell">docker commit -m="提交的描述信息" -a="作者" 容器ID 要创建的目标镜像名:[tag]</code></pre><p>导出镜像</p><pre><code class="shell">docker save -o test.tar 镜像名:[tag]</code></pre><p>导入镜像</p><pre><code class="shell">docker load -i test.tar # 此时镜像名与标签不变</code></pre>]]></content>
<categories>
<category> docker </category>
</categories>
<tags>
<tag> 小技巧 </tag>
</tags>
</entry>
<entry>
<title>基于Dockerfile创建镜像</title>
<link href="/2024/07/23/%E5%9F%BA%E4%BA%8EDockerfile%E5%88%9B%E5%BB%BA%E9%95%9C%E5%83%8F/"/>
<url>/2024/07/23/%E5%9F%BA%E4%BA%8EDockerfile%E5%88%9B%E5%BB%BA%E9%95%9C%E5%83%8F/</url>
<content type="html"><![CDATA[<h2 id="基于Dockerfile创建镜像"><a href="#基于Dockerfile创建镜像" class="headerlink" title="基于Dockerfile创建镜像"></a>基于Dockerfile创建镜像</h2><h3 id="创建镜像"><a href="#创建镜像" class="headerlink" title="创建镜像"></a>创建镜像</h3><pre><code class="shell">docker build -t {镜像名:镜像标签} . # docker build -t test:v1 .</code></pre><p>上述命令会根据当前文件夹下的<code>Dockerfile</code>文件(文件内容如下)来创建镜像</p><pre><code class="shell">FROM ubuntu:22.04 # 指定新镜像所基于的镜像MAINTAINER By Abel # 说明新镜像的维护人信息# 在所基于的镜像上执行命令RUN cd ~ # 进入root根目录RUN apt-get update && apt-get install -y wget # 更新 Ubuntu 包索引并安装 wget</code></pre><p>系统镜像下载超时时可以进行<code>docker</code>换源</p><ul><li><strong>获取阿里镜像加速器地址(免费、面向个人开发者)</strong></li></ul><blockquote><p>登录<a href="https://cr.console.aliyun.com/">容器镜像服务控制台</a>,在左侧导航栏选择<strong>镜像工具</strong> > <strong>镜像加速器</strong>,在<strong>镜像加速器</strong>界面获取<strong>加速器地址</strong></p><p>例如: https://[系统分配前缀].mirror.aliyuncs.com</p></blockquote><ul><li><strong>配置镜像加速器</strong></li></ul><blockquote><p>针对<code>Docker</code>客户端版本大于1.10.0的用户,可以通过修改配置文件<code>/etc/docker/daemon.json</code>来使用</p><pre><code class="shell">sudo tee /etc/docker/daemon.json <<-'EOF'{ "registry-mirrors": ["https://[系统分配前缀].mirror.aliyuncs.com"]}EOFsudo systemctl daemon-reloadsudo systemctl restart docker</code></pre></blockquote><h3 id="启动容器"><a href="#启动容器" class="headerlink" title="启动容器"></a>启动容器</h3><pre><code class="bash">docker run -p HOST_PORT:CONTAINER_PORT # 将容器的端口映射到宿主机的端口 -it # 交互式运行并分配终端 -d # 以守护进程模式运行容器 --net=bridge # 指定网络连接, 默认为bridge --gpus all # 容器可以访问主机所有GPU设备 -e NVIDIA_DRIVER_CAPABILITIES=compute,utility # 容器可以使用GPU执行计算任务 -e NVIDIA_VISIBLE_DEVICES=all # GPU对所有程序可见 test_img:v1 # 镜像名:镜像标签(不带默认lastest标签) /bin/sh # 交互式运行并启动终端</code></pre>]]></content>
<categories>
<category> docker </category>
</categories>
<tags>
<tag> 实用工具 </tag>
</tags>
</entry>
<entry>
<title>参数解析器</title>
<link href="/2024/07/22/%E5%8F%82%E6%95%B0%E8%A7%A3%E6%9E%90%E5%99%A8/"/>
<url>/2024/07/22/%E5%8F%82%E6%95%B0%E8%A7%A3%E6%9E%90%E5%99%A8/</url>
<content type="html"><![CDATA[<h2 id="参数解析器"><a href="#参数解析器" class="headerlink" title="参数解析器"></a>参数解析器</h2><p>在运行python程序的时候,往往需要在命令之后传入参数</p><h4 id="依赖导入"><a href="#依赖导入" class="headerlink" title="依赖导入"></a>依赖导入</h4><pre><code class="python">import argparse</code></pre><h4 id="实例化参数解析器"><a href="#实例化参数解析器" class="headerlink" title="实例化参数解析器"></a>实例化参数解析器</h4><pre><code class="python">parser = argparse.ArgumentParser()</code></pre><p>常用参数</p><ul><li><code>description</code>:帮助文档描述(头部)</li><li><code>epilog</code>:帮助文档描述(尾部)</li><li><code>add_help</code>:添加<code>-h / --help</code>选项来显示帮助文档,默认值为<code>True</code></li></ul><h4 id="添加参数设置"><a href="#添加参数设置" class="headerlink" title="添加参数设置"></a>添加参数设置</h4><p>添加一个<code>-v</code>或<code>--version</code>来传入参数</p><pre><code class="python">parser.add_argument('-v', '--version')</code></pre><p>常用参数</p><ul><li><p><code>type</code>:命令行参数被转换成的类型,如<code>str</code>、<code>int</code>、<code>float</code>等</p></li><li><p><code>default</code>:默认值设置</p></li><li><p><code>help</code>:对于此参数的描述会被打印至帮助文档中</p></li><li><p><code>action</code>:指定该参数的动作</p><ul><li><pre><code class="python"># 携带 -v 时该值设置为True, 默认为Falseparser.add_argument('-v', action='store_true')# 与上述相反parser.add_argument('-v', action='store_false')</code></pre></li></ul></li><li><p><code>required</code>:表示参数是否必须传入,默认值为<code>False</code></p></li></ul><h4 id="解析获取的参数"><a href="#解析获取的参数" class="headerlink" title="解析获取的参数"></a>解析获取的参数</h4><pre><code class="python">args = parser.parse_args()</code></pre><hr><h4 id="示例"><a href="#示例" class="headerlink" title="示例"></a>示例</h4><pre><code class="python">import argparseparas = argparse.ArgumentParser(description='Test', epilog='By Abel')paras.add_argument('--input_path', default='./input', type=str, help='输入路径')paras.add_argument('--output_path', default='./output', type=str, help='输出路径')args = paras.parse_args()print('input path:', args.input_path)print('output path:', args.output_path)# 输出> python test.py -husage: test.py [-h] [--input_path INPUT_PATH] [--output_path OUTPUT_PATH]Testoptions: -h, --help show this help message and exit --input_path INPUT_PATH 输入路径 --output_path OUTPUT_PATH 输出路径By Abel> python test.pyinput path: ./inputoutput path: ./output</code></pre><hr>]]></content>
<categories>
<category> python </category>
</categories>
<tags>
<tag> 实用工具 </tag>
</tags>
</entry>
<entry>
<title>linux常用命令</title>
<link href="/2024/07/08/linux%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4/"/>
<url>/2024/07/08/linux%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4/</url>
<content type="html"><![CDATA[<h2 id="linux常用命令"><a href="#linux常用命令" class="headerlink" title="linux常用命令"></a>linux常用命令</h2><p>显示磁盘使用情况</p><pre><code class="shell">df -h # 显示磁盘空间使用情况du -h --max_depth=1 # 显示当前目录的磁盘使用情况</code></pre><p>查看指定端口的进程信息</p><pre><code class="sh">lsof -i :8888</code></pre><p>指定显卡用于后台执行程序</p><pre><code class="sh">CUDA_VISIBLE_DEVICES=0 nohup python demo.py > out.log 2>&1 &</code></pre><p>查看进程信息</p><pre><code class="sh">ps # 显示当前用户的所有进程(不包括进程调用的子进程)ps -aux # 显示所有用户的进程详细信息ps -aux | grep xxx # 查看指定进程信息(如 ps -aux | grep python )top # 实时显示系统中各个进程的资源占用情况(所有用户)、q 退出top -u xxx # 实时显示系统中各个进程的资源占用情况(指定用户)top -u xxx | grep yyy # 实时显示系统中指定进程的资源占用情况(指定用户)</code></pre><p>压缩包分包以及合并</p><pre><code class="shell">split -b 500m test.tar archive.part # 500MB为每个分包的大小, archive.part是分包的前缀cat archive.part.* > test.tar # 合包</code></pre>]]></content>
<categories>
<category> linux </category>
</categories>
<tags>
<tag> 小技巧 </tag>
</tags>
</entry>
<entry>
<title>shell批量下载文件</title>
<link href="/2024/07/07/shell%E6%89%B9%E9%87%8F%E4%B8%8B%E8%BD%BD%E6%96%87%E4%BB%B6/"/>
<url>/2024/07/07/shell%E6%89%B9%E9%87%8F%E4%B8%8B%E8%BD%BD%E6%96%87%E4%BB%B6/</url>
<content type="html"><![CDATA[<h2 id="shell-批量下载文件"><a href="#shell-批量下载文件" class="headerlink" title="shell 批量下载文件"></a>shell 批量下载文件</h2><p>使用 shell 脚本可以批量下载文件(以 wget 命令为例)</p><pre><code class="shell">#!/bin/bash# 文件数组files=("https://example.com/1.txt" "https://example.com/1.txt")# 下载目录download_dir="/download/"for url in "${files[@]}"do # 提取文件名 filename=$(basename "$url") # 下载文件 echo "正在下载文件: $filename" wget "$url" -o "$download_dir" --progress=bar:force # 检查是否下载成功 if [ $? -eq 0 ] then echo "$filename 下载成功" else echo "$filename 下载失败" fidone</code></pre>]]></content>
<categories>
<category> linux </category>
</categories>
<tags>
<tag> 小技巧 </tag>
</tags>
</entry>
<entry>
<title>Gitalk</title>
<link href="/2024/01/13/Gitalk/"/>
<url>/2024/01/13/Gitalk/</url>
<content type="html"><![CDATA[<h2 id="Gitalk"><a href="#Gitalk" class="headerlink" title="Gitalk"></a>Gitalk</h2><p>Gitalk 是一个基于 Github Issue 和 Preact 开发的评论插件。详情请访问官网 <a href="https://github.com/gitalk/gitalk">Gitalk</a></p><h3 id="安装"><a href="#安装" class="headerlink" title="安装"></a>安装</h3><hr><ul><li>npm 安装</li></ul><pre><code>npm i gitalk --save </code></pre><h3 id="使用"><a href="#使用" class="headerlink" title="使用"></a>使用</h3><hr><ol><li>需要选择一个公共 github 存储库用于存储评论;然后创建 <a href="https://github.com/settings/applications/new">Github Application</a>,并填写相关信息</li><li>应用到页面上</li></ol><pre><code class="vue"><template> <div id="gitalk-container"></div></template><script> import 'gitalk/dist/gitalk.css' import Gitalk from 'gitalk' var gitalk = new Gitalk({ clientID: 'GitHub Application Client ID', clientSecret: 'GitHub Application Client Secret', repo: 'GitHub repo', owner: 'GitHub repo owner', admin: ['GitHub repo owner and collaborators'], id: location.pathname, // Ensure uniqueness and length less than 50 distractionFreeMode: false // Facebook-like distraction free mode }) gitalk.render('gitalk-container')</script></code></pre>]]></content>
<categories>
<category> 开发小工具 </category>
</categories>
<tags>
<tag> 插件 </tag>
</tags>
</entry>
<entry>
<title>Hello World</title>
<link href="/2024/01/11/hello-world/"/>
<url>/2024/01/11/hello-world/</url>
<content type="html"><![CDATA[<p>Welcome to <a href="https://hexo.io/">Hexo</a>! This is your very first post. Check <a href="https://hexo.io/docs/">documentation</a> for more info. If you get any problems when using Hexo, you can find the answer in <a href="https://hexo.io/docs/troubleshooting.html">troubleshooting</a> or you can ask me on <a href="https://github.com/hexojs/hexo/issues">GitHub</a>.</p><h2 id="Quick-Start"><a href="#Quick-Start" class="headerlink" title="Quick Start"></a>Quick Start</h2><h3 id="Create-a-new-post"><a href="#Create-a-new-post" class="headerlink" title="Create a new post"></a>Create a new post</h3><pre><code class="bash">$ hexo new "My New Post"</code></pre><p>More info: <a href="https://hexo.io/docs/writing.html">Writing</a></p><h3 id="Run-server"><a href="#Run-server" class="headerlink" title="Run server"></a>Run server</h3><pre><code class="bash">$ hexo server</code></pre><p>More info: <a href="https://hexo.io/docs/server.html">Server</a></p><h3 id="Generate-static-files"><a href="#Generate-static-files" class="headerlink" title="Generate static files"></a>Generate static files</h3><pre><code class="bash">$ hexo generate</code></pre><p>More info: <a href="https://hexo.io/docs/generating.html">Generating</a></p><h3 id="Deploy-to-remote-sites"><a href="#Deploy-to-remote-sites" class="headerlink" title="Deploy to remote sites"></a>Deploy to remote sites</h3><pre><code class="bash">$ hexo deploy</code></pre><p>More info: <a href="https://hexo.io/docs/one-command-deployment.html">Deployment</a></p>]]></content>
</entry>
</search>