fluidity: 基于有限元的编译器
主页:http://fluidityproject.github.io/
support/manual https://doi.org/10.6084/m9.figshare.1387713
github:https://github.com/FluidityProject/fluidity
出现的问题:fluidity无法安装在ubuntu22,(我还没升级到24)当前最高支持到20
解决方案:通过docker构建ubuntu20环境
注:以前跑项目只考虑隔离python等环境版本,用的是conda的虚拟环境,但虚拟环境无法隔离操作系统;加之当前电脑的显卡驱动是好不容易配好的,不想重新刷系统到20。所以选择docker构建容器并可持续使用的镜像,用以运行fluidity。同时有虚拟环境配合后期读取数据,模型训练,出图。
- 先准备工作目录
mkdir -p ~/docker_fluidity #-p:递归创建目录(连带创建父目录)+若已存在不报错
#docker_fluidity:宿主机工作目录名字
2.创建并进入容器
sudo docker run -it --name fluidity20 \ #fluidity20 容器名字
--user $(id -u):$(id -g) \ #指定容器内进程用哪个用户身份运行,这里是通过普通用户(非root)进入容器,防止写出来的文件有root锁
-v ~/docker_fluidity:/work \#把宿主机目录docker_fluidity挂在到容器/work
-w /work \
ubuntu:20.04 \
bash#进入交互shell
- 出现提示符“I have no name”:
exit#退出先
sudo docker pa -a#查看容器状态
出现fluidity20 Exited(0)说明容器存在且为停止状态,而后通过root进入
sudo docker start fluidity20 #启动容器
sudo docker exec -it -u 0 fluidity20 bash #通过root进入
成功后看到:root@xxxxx:/work#执行以下代码
apt-get update
apt-get install -y passwd
echo "user:x:$(id -u):$(id -g)::/work:/bin/bash" >> /etc/passwd
或者
groupadd -g 1000 hostgrp || true
useradd -m -u 1000 -g 1000 -s /bin/bash hostuser || true
chown -R 1000:1000 /work
而后输入exit推出
exit
- 通过root进入fluidity20安装软件
新容器初始化,包含基础工具链+仓库管理+下载/编译工具,过程中需要选择地区和城市
apt-get update
apt-get install -y --no-install-recommends \
software-properties-common ca-certificates gnupg curl wget \
build-essential git
安装fluidity
add-apt-repository -y ppa:fluidity-core/ppa
apt-get update
apt-get install -y fluidity
- 正常情况下进入容器交互模式:
sudo docker start -ai fluidity20