ubuntu中fcitx5中文输入无法在edge和chrome中使用

解决方案来源:https://github.com/fcitx/fcitx5/issues/384#issuecomment-1532428129

问题描述:
ubuntu安装fcitx5-pinyin后,可以在terminal等应用中使用,但是无法在edge浏览器等其他应用中激活输入法

解决方法
编辑文件~/.config/environment.d/profile.conf,添加输入法相关设置

GTK_IM_MODULE=fcitx
QT_IM_MODULE=fcitx
XMODIFIERS="@im=fcitx"
发表在 积少成多 | 留下评论

在开启secure boot的ubuntu上安装virtualbox

在开启了secure boot的ubuntu电脑上安装virtualbox无法直接使用,原因是virtualbox新安装的module需要签名才能加载。否则会报错

Kernel driver not installed (rc=-1908)

ask ubuntu的帖子给出的方法可以解决这个问题,具体方法摘录如下

  1. 对文件签名并生成新的kernel
    #生成MOK.der和MOK.priv文件
    sudo /sbin/vboxconfig 
    #安装签名工具
    sudo apt-get install mokutil
    #生成签名文件
    openssl req -new -x509 -newkey rsa:2048 -keyout MOK.priv -outform DER -out MOK.der -nodes -days 36500 -subj "/CN=VirtualBox/"
    # 将签名文件添加到kernel
    sudo /usr/src/linux-headers-$(uname -r)/scripts/sign-file sha256 ./MOK.priv ./MOK.der $(modinfo -n vboxdrv)
    # 将新的kernel注册到secure boot
    sudo mokutil --import MOK.der

    在上述步骤的最后一步需要设定一个密码,需要记住这个密码(重启电脑后要用)

重启电脑,会进入Perform MOK mangement为标题的蓝色界面 -> 选择Enroll MOK,一路继续到输入刚刚设定的密码 -> 重启电脑。

再次重启电脑后,virtual box就应该可以使用了.

By the way, put virtual machines on SSD will provide much better performance than on HDD.

发表在 积少成多 | 留下评论

apt使用系统代理

使用ubuntu的一些第三方源的时候apt update有可能遇到Could not connect to 错误,如果这是因为apt没有使用系统代理,则可以用如下解决方法

sudo visudo

在打开的文本编辑器中添加设置条目

Defaults env_keep = "http_proxy https_proxy ftp_proxy DISPLAY XAUTHORITY"

reference:

发表在 积少成多 | 留下评论

把主机作为git服务器

把主机当做git服务器使用非常容易

  1. remote主机创建git服务的用户,这里假设叫gituser
    sudo useradd -m gituser
  2. remote主机设置ssh公钥
    su gituser
    cd ~
    mkdir .ssh
    vim .ssh/authorized_keys # 复制公钥内容
    chmod 700 .ssh
    chmod 600 .ssh/authorized_keys
  3. remote主机初始化空想要同步的repo(使用--bare flag)
    mkdir -p ~/path_to/some_test_repo.git
    cd ~/path_to/some_test_repo.git
    git init --bare
  4. 本地电脑添加remote信息并push
    cd some_local/repo_path
    git remote add origin gituser@remote-server-url:/path_to/some_test_repo.git
    git push

参考材料:

发表在 积少成多 | 留下评论

获取python module的路径

每个module都会有__file__属性记录它的路径,以numpy为例

import numpy as np
import os
path = os.path.abspath(np.__file__)

Reference:
https://stackoverflow.com/questions/247770/how-to-retrieve-a-modules-path

发表在 积少成多 | 留下评论

MPI跨节点跑多GPU任务

需要确保资源正确分配,mpirun可以用如下命令,$ngpu$ 是跨节点的总GPU数,$ngpu_per_node是每个节点的GPU数量

mpirun -np $ngpu -npernode $ngpu_per_node \
    --map-by slot:pe=1 \
    --rank-by slot \
    --bind-to core \
    --report-bindings \
    <commond to run>

作业脚本为了跨节点GPU申请也需要使用额外的设置,这里以slurm为例,应该写成

#!/bin/bash
#SBATCH -N 4 # 节点数
#SBATCH --gres=gpu:8 # 每个节点的GPU个数,对应$ngpu_per_nod
#SBATCH --qos=<gpu资源名称> # 这部分需要参考服务器的说明
发表在 积少成多 | 留下评论

[Linux]指定程序运行的cpu id

在HPC上跑计算时,有时需要指定程序运行的CPU id以便获得更好的性能,下列linux命令可以达到这个目的:

taskset -c 0-5 <command> [arguments for command]

Reference:https://unix.stackexchange.com/a/635992

发表在 积少成多 | [Linux]指定程序运行的cpu id已关闭评论

macOS Quantum espresso编译hdf5支持

使用macports直接编译QE,会找不到macports的hdf5库,尝试各种flag设置无果后,改用手工编译HDF5解决

编译安装hdf5

./configure --prefix=$HOME/opt/hdf5 --enable-fortran --enable-parallel  --enable-hl 
make && make install

注意configure时需要添加fortran支持等flag

编译安装QE

configure

F90=gfortran CC=gcc \
BLAS_LIBS="-L/opt/local/lib -lopenblas" \
LAPACK_LIBS="-L/opt/local/lib -lopenblas" \
./configure --enable-openmp --disable-parallel --enable-debug \
            --with-hdf5=$HOME/opt/hdf5

删除不支持的编译flag

生成的makefile会包含一个不支持的flag,-lrt,需要从make.inc中删除

make and test

make pw # only pw.x and related modules
cd test-suite
make run-tests-pw
发表在 笔记 | 留下评论