0%

Broadband 宽带

天文学中,术语”宽带“是指进行给定观测的频谱的宽度,用于区分连续体和光谱线观测(参见后者的窄带条目)。观测的带宽越宽,灵敏度越高,因此对于任何波长的连续观测或光度测量,都可以使用宽带(宽带)滤波器。

射电天文学中,宽带观测通常是指约100 MHz的频率宽度。

参考:COSMOS (swin.edu.au)

HPC 相关

FLOPS is floating point operations per second. This is used as a measurement because historically floating point operations has been very expensive operations compared to other operations. 每秒浮点运算次数,亦称每秒峰值速度,(英语:Floating-point operations per second;缩写:FLOPS),即每秒所运行的浮点运算次数。浮点(floating-point)指的是带有小数的数值,浮点运算即是小数的四则运算,常用来测量电脑运算速度或被用来估算电脑性能,尤其是在使用到大量浮点运算的科学计算领域中。因为FLOPS后缀的那个S代表,而不是复数,所以不能够省略。在多数情况下,测算FLOPS比测算每秒指令数(IPS)要准确。

浮点运算实际上包括了所有涉及浮点数的运算,在某类应用软件中常常出现,比较整数运算更用时间。现今大部分的处理器中都有浮点运算器。因此每秒浮点运算次数所量测的实际上就是浮点运算器的运行速度。而最常用来测量每秒浮点运算次数的基准程序(benchmark)之一,是Linpack

FLOPS在高性能计算机集群(超算)上可以使用这一公式得出:
${\displaystyle {\text{FLOPS}}={\text{racks}}\times {\frac {\text{nodes}}{\text{rack}}}\times {\frac {\text{sockets}}{\text{node}}}\times {\frac {\text{cores}}{\text{socket}}}\times {\frac {\text{cycles}}{\text{second}}}\times {\frac {\text{FLOPs}}{\text{cycle}}}}$

简化到计算机只拥有一块CPU的情况时,可以使用以下公式:

${\displaystyle {\text{FLOPS}}={\text{cores}}\times {\frac {\text{cycles}}{\text{second}}}\times {\frac {\text{FLOPs}}{\text{cycle}}}}$

Environment Modules

Environment Modules 给用户提供了一个通过modulefiles动态的修改环境变量的方法。

什么是 Environment Modules?

通常,用户在登录时通过为会话期间要引用的每个应用程序设置环境信息来初始化其环境。Environment Modules包是一个简化shell初始化的工具,它允许用户在使用modulefile进行会话期间轻松地修改环境。

每个modulefile包含为应用程序配置shell所需的信息。初始化Modules包后,可以使用modulefiles的module命令在每个模块的基础上修改环境。通常,modulefiles 可以使用module命令更改或设置shell环境变量,如PATH、MANPATH等。modulefile可以由系统上的许多用户共享,用户可以有自己的集合来补充或替换共享的modulefile。

模块可以使用 loadedunloaded 动态操作。支持所有主流的shell,比如 bash, ksh, zsh, sh, csh, tcsh, fish, 还有一些其他的脚本语言,如 perl, ruby, tcl, python, cmakeR.

模块在管理不同版本的应用程序时非常有用。模块也可以绑定到元模块中,元模块将加载一整套不同的应用程序。

快速示例

Here is an example of loading a module on a Linux machine under bash.

1
2
3
$ module load gcc/8.3
$ which gcc
/usr/local/gcc/8.3/linux-x86_64/bin/gcc

Now we’ll switch to a different version of the module

1
2
3
$ module switch gcc gcc/9.2
$ which gcc
/usr/local/gcc/9.2/linux-x86_64/bin/gcc

And now we’ll unload the module altogether

1
2
3
$ module unload gcc
$ which gcc
gcc not found

Now we’ll log into a different machine, using a different shell (tcsh).

1
2
3
% module load gcc/9.2
% which gcc
/usr/local/gcc/9.2/linux-aarch64/bin/gcc

Note that the command line is exactly the same, but the path has automatically configured to the correct architecture.

开始使用 Modules

Download latest version of Modules. Learn how to install it on Unix or how to install it on Windows. You may alternatively automatically retrieve and install Modules with your preferred package manager as Environment Modules is widely available. If you are upgrading from an older version of Modules, read the MIGRATING guide to learn all new features recently introduced.

Reference manual page for the module(1) and ml(1) commands and for modulefile(4) script provide details on all supported options. If you have questions, comments or development suggestions for the Modules community, please read the CONTRIBUTING guide.

搜索路径问题

1
2
3
4
5
6
7
#这个是关于引用博主和我自己的使用情况的一些总结:
#查看MODULEPATH
echo $MODULEPATH

#修改路径
#在默认的/usr/share/module/init/bash中添加最后一行
export MODULEPATH=/YOUR/PATH/:$MODULEPATH

modulefiles文件的书写

  • 文件的开头一定是#%Module1.0开始
  • 有几个命令
    • prepend 要修改的环境变量 路径
    • setenv 修改环境变量的值
    • conflict modulefile 如果这个modulefile已经被加载,则当前的modulefile不能被加载

一个模板

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#%Module1.0
proc ModulesHelp { } {
global version prefix

puts stderr "\t Loads the environment for my installed home folder HOME/local"
}

module-whatis "Loads the environment for my installed home folder HOME/local"

set HOME /home/svu/a0081742

prepend-path PATH $HOME/local/bin
prepend-path LIBRARY_PATH $HOME/local/lib
prepend-path LD_LIBRARY_PATH $HOME/local/lib
prepend-path LD_INCLUDE_PATH $HOME/local/include
prepend-path MANPATH $HOME/local/share/man

使用方法

  • module avail 显示可以使用的模块
  • module load 加载模块
  • module unload 卸载模块
  • module list 显示已经加载的模块

Ubuntu busybox 无法启动问题

屏幕错误提示

错误显示类似于:

1
2
3
4
5
6
7
8
9
10
11
12
mount: mounting /dev/disk/by-uuid/***************************** on /root
failed: Invalid argument
mount: mounting /sys on /root/sys failed: No such file or directory
mount: mounting /dev on /root/dev failed: No such file or directory
mount: mounting /sys on /root/sys failed: No such file or directory
mount: mounting /proc on /root/proc failed: No such file or directory
Target file system doesn't have /sbin/init
No init found. Try passing init= bootarg

Busybox v1.13.3 (Ubuntu 1:1.13.3-1ubuntu7) built-in shell (ash)
Enter 'help' for a list of built-in commands
(initramfs) _

解决方案

  1. 从Ubuntu10.04 live CD引导系统;
  2. 打开命令行;
  3. 运行sudo fdisk -l回车,目的是查看设备名称。输出类似于:
    1
    2
    3
    4
    5
    6
    7
    8
    Disk /dev/sda: 250.1 GB, 250059350016 bytes
    255 heads, 63 sectors/track, 30401 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Disk identifier: **********
    Device Boot Start End Blocks Id System
    /dev/sda1 * 1 30238 242886703+ 83 Linux
    /dev/sda2 30239 30401 1309297+ 5 Extended
    /dev/sda5 30239 30401 1309266 82 Linux swap / Solaris
    选择Linux所在分区: /dev/sda1。如果/boot单独分区了则选择/boot所在分区。(我个人认为)
  4. 运行sudo fsck /dev/sda1回车;
  5. 重启电脑,正常引导系统。

git reset

使用 git reset HEAD <file>... 来取消暂存。 所以,我们可以这样来取消暂存 CONTRIBUTING.md 文件:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
$ git reset HEAD CONTRIBUTING.md
Unstaged changes after reset:
M CONTRIBUTING.md
$ git status
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)

renamed: README.md -> README

Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)

modified: CONTRIBUTING.md

这个命令有点儿奇怪,但是起作用了。 CONTRIBUTING.md 文件已经是修改未暂存的状态了。

Note git reset 确实是个危险的命令,如果加上了 --hard 选项则更是如此。 然而在上述场景中,工作目录中的文件尚未修改,因此相对安全一些。

Python3 内置虚拟环境venv

.. _python-venv-python3:

在虚拟环境中安装(可选)

您还可以选择在虚拟环境(或应用程序虚拟环境)中安装各种软件,以保持环境清洁。

1
$ python3 -m venv packenv

创建后,通过从命令行运行来激活虚拟环境

1
2
3
4
# Windows
$ call packenv\scripts\activate.bat
# Linux
$ source packenv/bin/activate

最后,安装所需的软件包,比如numpy

1
$ pip3 install numpy

同时也可以增加一个提示符,比如NAME

1
$ python3 -m venv --prompt NAME virtual_name 

构建Docker镜像时处理Configuring tzdata交互输入

在Dockerfile中安装deb软件包时,某些软件将tzdata作为依赖项安装。

tzdata会以交互方式提醒用户选择使用位置。

Configuring tzdata
------------------
Please select the geographic area in which you live. Subsequent configuration
questions will narrow this down by presenting a list of cities, representing
the time zones in which they are located.
 1. Africa      4. Australia  7. Atlantic  10. Pacific  13. Etc
 2. America     5. Arctic     8. Europe    11. SystemV
 3. Antarctica  6. Asia       9. Indian    12. US
Geographic area:

可能一直会卡在这个界面(我就遇到了)。

为了解决这个问题,我们需要将tzdata设置为非交互方式。

首选的方法是在Dockerfile的第一条RUN之前加入以下配置:

ENV DEBIAN_FRONTEND=noninteractive
第二个方法是,在DEBIAN_FRONTEND=noninteractive条件下使用命令apt install或apt-get install配置安装tzdata:

RUN DEBIAN_FRONTEND=noninteractive apt install -y tzdata
这将自动选择默认配置安装tzdata。

简介

casacore 是一系列射电天文数据处理的C++库

安装

Debian/Ubuntu

1
2
3
4
5
$ apt-get update
$ sudo apt-get install build-essential cmake gfortran g++ libncurses5-dev libreadline-dev flex bison libblas-dev liblapacke-dev libcfitsio-dev wcslib-dev
$ sudo apt-get install libhdf5-serial-dev libfftw3-dev python-numpy libboost-python-dev libpython3.4-dev libpython2.7-dev
$ apt-get search casacore
$ apt-get install casacore

CentOS

1
2
3
4
$ yum update
$ sudo yum install cmake cmake-gui gcc-gfortran gcc-c++ flex bison blas blas-devel lapack lapack-devel cfitsio cfitsio-devel wcslib wcslib-devel ncurses ncurses-devel readline readline-develpython-devel boost boost-devel fftw fftw-devel hdf5 hdf5-devel numpy boost-python
$ apt-get search casacore
$ apt-get install casacore

MacOSX

1
2
$ brew tap ska-sa/tap
$ brew install casacore

Docker

1
$ docker pull quay.io/casacore/casacore:master

测试数据集

ftp://ftp.astron.nl/outgoing/Measures/

代码参考 https://www.github.com/shaoguangleo/radio_astronomy

简介

python-casacore是casacore的python绑定。

在安装这个之前,需要先行安装casacore。

安装

二进制安装

1
$ pip install python-casacore

Debian/Ubuntu

1
$ sudo apt-get install python-casacore

Kern

此处为使用Ubuntu LTS系统的

1
2
3
4
$ sudo apt-get install software-properties-common
$ sudo add-apt-repository ppa:kernsuite/kern-5
$ sudo apt-get update
$ sudo apt-get install python-casacore

MacOSX

On Macs, you may need to create an /etc/sysctl.conf file
Put in it the following lines

重启后可以使用 sysctl kern.sysv来查看状态。

代码参考 https://www.github.com/shaoguangleo/radio_astronomy

slurm作业提交系统常用命令

查看有哪些分区 sinfo命令

1
2
3
4
5
$ sinfo
PARTITION AVAIL TIMELIMIT NODES STATE NODELIST
arm up infinite 9 idle taishan-arm-cpu[01-09]
gpu up infinite 8 idle sugon-gpu[01-08]
cpu up infinite 10 idle x86-cpu[01-10]

指定节点跑程序srun

比如这里我有一个test.py的文件,内容如下:

1
2
3
4
5
6
#!/usr/bin/env python

import time
for i in range(10):
time.sleep(1)
print(i)

执行如下命令:

1
srun -p cpu -w x86-cpu01 python ./test.py 

slurm最基本的命令是srun,比如上面一行的参数如下:

  • -p:指定分区PARTITION
  • -w:指定NODELIST

查看自己任务squeue

squeue -u +用户

1
2
3
~> squeue -u name
JOBID PARTITION NAME USER ST TIME NODES NODELIST(REASON)
32236 cpu test.py name R 2:08 1 x86-cpu01