0%

自用快速手册

不知道干啥时的快速便签

Git

保持与原仓库同步

把远端仓库加入upsterm
git remote add upstream https://github.com/performancecopilot/pcp.git

想要从原仓库将更新的commit更新到本地的场合

比如想将更新merge到master主分支上, 那么首先保证我们在主分支上:

看看我们在哪个分支上git branch

切回主分支git checkout master

接下来先将远端的代码先载到本地git fetch upstream(以我自己的pcp项目为例, 最后这个远程仓库名可通过git remote -v查看)

此时可能会出现需要手动merge代码的情况, 我用vsCode所以在source control里可以可视化地merge代码. merge完毕之后需要commit一下, 并在文件里描述这次merge.

好, 完成以上操作后可以进行merge了git merge up[][]stream/master 此时便将fetch的代码,以及我们手动merge的代码merge进当前的branch.

撤销commit

只是撤销commit而已哦git reset --soft HEAD~1

git clone包含外部链接库

一个项目的某些子模块是外部链接到别的项目上的,此时在git clone后执行

1
git submodule update --init --recursive

编译

动态库

动态库编译install后, 可能由于缓存没有更新导致程序还在使用旧的库. 此时ldconfig

GDB

自己编译的时候使用gcc -g xxx.c, -g会创建符号表/关闭优化(诶大丈夫?)程序将按照代码来执行.

对于需要args参数的程序调试示例gdb --args pmseries 'kernel.all.load[count:5]'

打开gdb后, 使用layout next来看代码.

使用break function_name来对某个函数设定断点

运行run开始运行程序

使用nextstep来使程序进入下一步, 区别在于next不会进入函数,而step在执行函数时会跳到那个函数内部.

使用print xx来打印想看的变量

有时会出现“Cannot find bounds of current function”提示, 这时候适当地使用ni [number] number大小实操来取吧, 好像这个是调libuv库的时候会发生的事情.

有时画面会一团糟, 使用refresh

set print pretty on/off(默认) 是否以换行缩进的方式打印结构体,或者类。

PCP

  • 有时pmlogger会自己消失, 为啥呢? 难道pmlogger有自己的生命期, 时间一到就kill自己? nathans回答了“就是有生命周期的噻24h”, 不过升级到5.x后好像就没了

  • 似乎只有在pmproxy, pmlogger同时运行时才能使用pmseries查询time series, 每个metric的采集时间不一样. 而且似乎并不是pmlogger一开启pmproxy就进行转发到redis. 因此启动后若使用pmseries没有反应请耐心等待个几分钟.

  • log文件储存在/var/log/pcp/下各文件夹中

  • 一些启动脚本在/etc/init.d/中

  • ./pmcd stop不了的时候试试./pcp stop

  • 使用redis-cli直接向redis查询, 根据series identifier来查询value的语句参考XRANGE pcp:values:series:7d0a5094fa4ffe7aecfa4287ca25855b0c34816f - + count 2

  • pmseries我的debug option pmseries -Dquery

  • 测试rescale, 现在发现的semantic为instant的有kernel.all.uptime, 样例:

    1
    2
    3
    pmseries 'rescale(kernel.all.uptime[count:2], "min")'
    pmseries 'rescale(kernel.all.uptime[count:2], "sec")'
    pmseries 'rescale(rescale(kernel.all.uptime[count:2], "min"), "hour")'
  • 一些时间换算..
    1 nanoseconds = 0.001 microseconds

1 microseconds = 0.001 milliseconds

Redis

  • redis-cli开始查询
  • 查询Desc HMGET pcp:desc:series:94835a09744d4cea95f06c7feb45c33ada91685a semantics
  • 使用redis-cli直接向redis查询, 根据series identifier来查询value的语句参考XRANGE pcp:values:series:7d0a5094fa4ffe7aecfa4287ca25855b0c34816f - + count 2

Notebook

  • 在remote host上启动notebook后, 本地使用ssh -N -f -L 127.0.0.1:25252:127.0.0.1:25252 username@ip_address来使本地与远端建立连接
  • Pytorch PermissionError: [Errno 13] Permission denied: ‘/.torch’时, 改变下载的路径export TORCH_HOME=./torch
  • 启用ipywidgets, jupyter nbextension enable --py widgetsnbextension --sys-prefix

Python相关

环境

  • 环境多python很烦恼, 可以先看看pyhton用的优先级 which -a python. 这是依照$PATH中的顺序的, 靠前的优先

pip

  • ERROR: Could not install packages due to an EnvironmentError: [Errno 28] No space left on device. 此时修改一下temp文件夹目录, 使用export TMPDIR=~/zys/temp/
  • 换源install使用pip install torchvision -i https://mirrors.nju.edu.cn/pypi/web/simple
  • sds 要使用sdsfree()来free

valgrind

  • 入门使用去看官网介绍valgrind pmseries ‘rate(kernel.all.load)[count:2]’
  • valgrind –leak-check=yes pmseries ‘rate(kernel.all.load)[count:1]’

DNS

  • 修改/etc/resolv.conf 内的nameserver 8.8.8.8以访问外网

CUDA/cuDNN

  • 使用tensorflow前, export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH. 因为系统默认的cnDNN版本不太对…

Virtual environemnt

Note: this folder is also a virtual environment folder

Since this server does not support conda…

To creat a vitual environment:

virtualenv project_name

to active a environment:

source project_name/bin/activate

now we are in a new python environment. We can see the python we using is within this environment:

which python/pip

pip list

all pip install package will by installed into this environment

To get out and return to the global environment, use deactivate

Cartoon Gan

偷偷摸摸使用自装conda: source /home/usertwo/.bashrc
conda activate cartoongan

命令行输出重定向

        ||    visible in terminal    ||    visible in file        ||    existing
Syntax    ||    Stdout    |    Stderr    ||    Stdout    |    Stderr    ||    file

===========================================================================
> || no | yes || yes | no || overwrite
>> || no | yes || yes | no || append
2> || yes | no || no | yes || overwrite
2>> || yes | no || no | yes || append
&> || no | no || yes | yes || overwrite
&>> || no | no || yes | yes || append
| tee || yes | yes || yes | no || overwrite
| tee -a || yes | yes || yes | no || append
|& tee || yes | yes || yes | yes || overwrite
|& tee -a || yes | yes || yes | yes || append

一些linux命令

file

file 文件名 查看文件类型

hexdump

hexdump file_name |head: 看字节流文件,16进制表示

CMAKE

link_directories和target_compile_definitions的区别

nm
c++filt
git cheerypick

return string(s1 + s2)

string temp = s1 + s2;
return temp

struct {
int8 ;
double;
}