ubuntu新建账户及权限设置
change source fastly in ubuntu
使用几行代码快速完成备份及更新软件源
阿里源
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak_`date "+%y_%m_%d"`
sudo sed -i 's/http:\/\/.*.ubuntu.com/https:\/\/mirrors.aliyun.com/g' /etc/apt/sources.list
sudo apt update
sudo apt upgrade
清华源
sudo sed -i 's/http:\/\/.*.ubuntu.com/https:\/\/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list
Reference from: https://www.cnblogs.com/fang-d/p/Ubuntu20_04-Change_repo.html
ssh login with keys
mount disk
直接挂载
使用
sudo fdisk -l
与lsblk -f
确定挂载目标盘情况,如果出现未格式化情况,可能需要使用sudo mkfs -t ext4 /dev/xxx
进行格式化在
/mnt/
内创建文件夹,用于挂载硬盘使用
sudo mount /dev/xxx /mnt/xxx
进行挂载使用
sudo umount -v /dev/xxx
或sudo umount -v /mnt/xxx
进行卸载
开机自动挂载
至少完成直接挂载,确保不存在挂载本身问题
通过
sudo blkid /dev/xxx
查询硬盘本身UUID修改
/etc/fstab
文件,在末尾添加:UUID=************ /mnt/xxx ext4 defaults 0 2
第一个数字:0表示开机不检查磁盘,1表示开机检查磁盘;
第二个数字:0表示交换分区,1代表启动分区(Linux),2表示普通分区
environment building
Conda(服务器端root账号下一次安装,全部用户可使用)
下载anaconda安装脚本,可通过清华镜像下载,linux下可使用wget,如:
wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-2021.11-Linux-x86_64.sh
切换到root账户或者使用具有sudo权限账号运行脚本,如:
sh Anaconda3-2021.11-Linux-x86_64.sh -p /opt/anaconda3 -b
其中 -p 指定安装位置,-b 无需人工干预。这里选择
/opt/anaconda3
安装是因为该位置每个账户均可以访问该位置,也可以使用/usr/local/anaconda3
等待安装结束后用用户账户运行
/opt/anaconda3/bin/conda init bash
之后重新打开终端即可激活conda环境。
这种方法安装的conda环境存在互相干扰的可能性,建议用户不要在base环境中进行任何修改,使用conda create -n <name>
创建自己anaconda虚拟环境后再修改
该情况存在共用缓存文件夹导致的权限问题,目前能想到的解决方案是在每次安装后使用sudo chmod +777 -R /opt/anaconda3/pkgs/
将缓存文件夹中所有文件更改为777
FSL
下载fsl安装脚本
wget https://fsl.fmrib.ox.ac.uk/fsldownloads/fslinstaller.py
下载python2用于运行脚本
sudo apt install python
安装fsl
sudo python2 fslinstaller.py -d /usr/local/fsl
在任何需要使用fsl的用户账户终端输入以下命令添加环境变量:
sed -i '$a FSLDIR=/usr/local/fsl\n. ${FSLDIR}/etc/fslconf/fsl.sh\nPATH=${FSLDIR}/bin:${PATH}\nexport FSLDIR PATH' ~/.bashrc source ~/.bashrc
参考环境变量配置指南编写,效果是在用户环境变量文件末尾添加所需内容并刷新之。如需对所有用户都进行环境变量配置,可将写入与更新路径改为
/etc/bash.bashrc
(非常见)安装完成后出现
error while loading shared libraries: libquadmath.so.0: cannot open shared object file: No such file or directory
错误,可能是安装依赖不完全导致,sudo apt install libquadmath0
安装对应库即可解决问题
ANTs
.h5 file as pytorch dataset
使用h5文件用作数据集储存的优点
见stackoverflow question
- 存储数据尺寸无限制
- 存储时间与空间效率较mat文件高
- 自定义压缩方式
- 支持以切片方式读取矩阵中的部分内容,而无需读取整个矩阵
Beyond the things listed above, there’s another big advantage to a “chunked”* on-disk data format such as HDF5: Reading an arbitrary slice (emphasis on arbitrary) will typically be much faster, as the on-disk data is more contiguous on average.
- matlab也支持
使用h5文件作为pytorch dataset时多线程读取报错
见Github issue
- 不要在dataset的
__init__
中打开h5文件中的dataset,但可以读取dataset的其他信息 - 在第一次调用
__getitem__
时打开h5文件中的dataset
Example:
Hexo-Post操作
创建新post
$ hexo new [layout] <title>
layout可为post, page, draft等,其中draft可将编辑内容保存为草稿,具体用法可见 hexo-draft
title有空格带引号,无空格可不带
hexo new (post)
命令生成md文件于/source/_posts/
文件夹下
Details in Writing
置顶post
不需要更换插件,参考hexo-generator-index 插件 issue
在要置顶的post中加入sticky字段即可,如sticky: 10
Hexo基本操作
Check documentation for more info.
Run server
$ hexo server
More info: Server
Generate static files
$ hexo generate
More info: Generating