MICrONS数据库Jupyter

部署运行你感兴趣的模型镜像

获取data的操作来源于:microns-nda-access-lauch-jupyter-environment

准备工作:

  1. 在服务器root中安装docker,要下载有docker-compose插件版本的,配置docker的镜像网络(服务器没有vpn,无法连接外网);
  2. 在root中添加group组,将个人用户(需要使用docker的用户)添加到docker group内;
  3. 确认服务器安装了git,运行git --version不会出现not command这种报错;
  4. 如果服务器上没有梯子无法连接外网,需要提前将一些会用到github的仓库转存到gitee上(一个镜像工作站,可以从GitHub导入仓库)

上述过程的参考链接:

满满干货!Docker最新安装教程(公众号)

Docker 安装 (完整详细版)-优快云博客

创建docker用户组group(知乎专栏)

GitHub仓库快速导入Gitee及同步更新 - Gitee.com

ps:保证vscode可以在本地顺利ssh连接服务器

Database Setup

这里会有两种方式可以完成数据库的建立:

  1. Docker container environment with the database and all data pre-ingested
  2. Download a data dump for manual ingestion into an existing MySQL database

因为我们服务器本来也没有MySQL,本人也不熟悉MySQL的语法,所以选择了docker container。

那么第一步就是下载container image tar file:
  • 先建立一个空的文件夹存放,也可以直接放到第二步里要下载的仓库文件夹内;
  • 在文件夹内运行⬇️:但是会出现一些问题,比如,1. 服务器本身没有aws这个操作命令,2. 运行时间过长,你的终端被占用,无法关闭;
aws s3 cp s3://bossdb-open-data/iarpa_microns/minnie/functional_data/two_photon_processed_data_and_metadata/database_v8/functional_data_database_container_image_v8.tar . --no-sign-request

解决aws问题第一种方法,如果是非root用户,可以直接在自己的账号下安装aws,参考:Linux安装非root用户安装aws-优快云博客

第二种方法,在网页microns-nda-access-lauch-jupyter-environment中直接点击下载链接:

然后通过scp或者sftp上传至服务器刚刚建立好的文件夹内;

解决终端被占用过长时间的问题:可以开一个screen,执行screen -R windowname(其中windowname是你screen窗口的名字),这样在screen运行命令后,可以通过ctrl+A+D返回终端主窗口

第二步(同时)把microns-nda-access仓库下载下来:

内部有.env, Dockerfile, docker-compose.yml等等配置文件,下载后将仓库上传到服务器上,之后所有的配置都是在这个文件夹路径内执行的

等待第一步结束后,load下载的tar文件
docker load --input functional_data_database_container_image_v8.tar

在第一步的路径内执行上述load,完成docker加载镜像数据

docker compose

1. 回到第二步的仓库路径内,执行
docker compose up -d database

docker版本更新后,原来的docker-compose命令更换为docker compose,但是github上的教程都还是docker-compose,运行时需要手动更改。

这一步正常执行后是直接进入Running的状态,会把数据加载进docker的容器内,应该会在docker内出现一个database的container;

2. 然后需要配置jupyter,目的是能通过jupyter notebook在docker环境内运行datajoint,获取可视化数据。
docker compose up -d notebook

这一步需要的时间比较久,而且问题比较多,如果你的服务器能够顺利连到外网github以及docker内的网络配置也没有问题的话,那应该很顺利,但是因为我们的服务器没有办法连到github,所以要将Dockerfile里所有要RUN的git clone后的链接转到gitee上

问题又出现了,就算我用了gitee的网址,服务器能够顺利git clone http://gitee,但是docker内无法连接gitee,要么被拒绝,要么超时。fine,只能先将所有需要用到的git clone的仓库都先clone到服务器本地路径内,然后在Dockerfile里用COPY命令复制到docker容器内。因为microns_phase3_nda文件夹内的requirements.txt在RUN pip3 install -e microns_phase3_nda/的时候会被setup.py执行,因此我要把requirements.txt内的git也去掉。

最终需要通过git更改的文件有

microns_phase3_nda/requirements.txt

microns-nda-access/Dockerfile 如下(后半部分Set up work environment保持不变)

FROM python:3.8-buster

# Base packages

RUN apt-get update&& \
    apt-get install -y git openssh-client&& \
    apt-get -y install graphviz build-essential python-dev ffmpeg fish
    
RUN pip install --upgrade pip

# Install jupyter notebook
RUN pip3 install jupyter jupyterlab

# Install viz dependencies
RUN pip3 install matplotlib ipyvolume seaborn

# Lock to datajoint 0.12.9
RUN pip3 install datajoint==0.12.9

# Install the outside packages
WORKDIR /src
COPY README.md /microns-nda-access/.
COPY Dockerfile /microns-nda-access/.
COPY docker-compose.yml /microns-nda-access/.

COPY microns_phase3_nda/ /src/microns_phase3_nda/
COPY microns_phase3_nda/requirements.txt /src/microns_phase3_nda/requirements.txt
RUN pip3 install torch==1.9.0+cpu torchvision==0.10.0+cpu torchaudio==0.9.0 -f https://download.pytorch.org/whl/torch_stable.html

COPY em_coregistration/ /src/em_coregistration/
RUN pip3 install -e /src/em_coregistration/
RUN pip3 install --no-deps -e microns_phase3_nda/
RUN pip3 install numpy==1.24.3 scipy==1.10.1 pandas==2.0.2 scikit-video==1.1.11 datajoint==0.12.9 matplotlib==3.7.1 nglui==2.14.2 caveclient==5.7.0 torch==1.9.0

最后还可能因为docker-compose.yml文件里的网络端口有一些奇怪的问题访问不了,GPT更改一下好了。如果没问题就会出现皆大欢喜的如下界面:

最后进入docker内运行jupyter notebook:

先检查docker容器在运行:

docker ps | grep notebook
1. 网页版jupyter notebook

因为我的docker在服务器上,所以我如果想用自己电脑的jupyter网页版访问docker,先在终端连接到服务器的端口,这个端口在docker-compose.yml文件里的notebook部分有:

ssh -L 8889:localhost:8889 username@your_server

然后在本地浏览器访问 http://localhost:8889,就可以连到docker内看到ipynb文件了

2. vscode jupyter notebook插件

除了在vscode里下载Jupyter系列插件外,还要下载Docker插件和Dev Container插件,第一个可以看到docker内的容器运行情况,第二个可以进入Docker内的可视化界面,通过:

show and run commands >

Dev containers: attach to running container

就能进入到容器内了!

您可能感兴趣的与本文相关的镜像

Python3.10

Python3.10

Conda
Python

Python 是一种高级、解释型、通用的编程语言,以其简洁易读的语法而闻名,适用于广泛的应用,包括Web开发、数据分析、人工智能和自动化脚本

def radiance(absoluteTemperature, emissivity, dx=0.01, response=None): """ title:: radiance description:: Calculates radiance and integrated radiance over a bandpass of 8 to 14 microns, given temperature and emissivity, using Planck's Law. inputs:: absoluteTemperature temperture of object in [K] either a single temperature or a numpy array of temperatures, of shape (temperatures.shape[0], 1) emissivity average emissivity (number between 0 and 1 representing the efficiency with which it emits radiation; if 1, it is an ideal blackbody) of object over the bandpass either a single emissivity or a numpy array of emissivities, of shape (emissivities.shape[0], 1) dx discrete spacing between the wavelengths for evaluation of radiance and integration [default is 0.1] response optional response of the camera over the bandpass of 8 to 14 microns [default is None, for no response provided] returns:: radiance discrete spectrum of radiance over bandpass integratedRadiance integration of radiance spectrum over bandpass (to simulate the readout from a sensor) author:: Elizabeth Bondi """ wavelength = numpy.arange(8,14,dx) c1 = 1.19104e8 # (2 * 6.62607*10^-34 [Js] * # (2.99792458 * 10^14 [micron/s])^2 * 10^12 to convert # denominator from microns^3 to microns * m^2) c2 = 1.43879e4 # (hc/k) [micron * K] if response is not None: radiance = response * emissivity * (c1 / ((wavelength**5) * \ (numpy.exp(c2 / (wavelength * absoluteTemperature )) - 1))) else: radiance = emissivity * (c1 / ((wavelength**5) * (numpy.exp(c2 / \ (wavelength * absoluteTemperature )) - 1))) if absoluteTemperature.ndim > 1: return radiance, numpy.trapz(radiance, dx=dx, axis=1) else: return radiance, numpy.trapz(radiance, dx=dx) 把上面python代码翻译成c语言代码
10-20
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值