Update History

2024-05-22

  • Added “Adding the user who executes Docker commands to the docker group.”

Overview

mdx is a data platform for industry-academia-government collaboration co-created by universities and research institutions.

https://mdx.jp/

This time, we will use an mdx virtual machine to run NDL Classical Japanese OCR.

https://github.com/ndl-lab/ndlkotenocr_cli

Project Application

This time, I selected “Trial” as the project type.

With “Trial,” one GPU pack was allocated.

Creating a Virtual Machine

Deploy

This time, I selected “01_Ubuntu-2204-server-gpu (Recommended).”

On the pre-deployment screen, the settings were configured as follows. The pack type was set to “GPU Pack” with a pack count of 1.

For the public key, I created it on my local PC as follows.

csdsh~-/k.esysghe/nmdx

Then I pasted the contents of the generated id_rsa.pub.

After that, wait for the virtual machine deployment to complete.

Network Settings for SSH Connection

I was able to proceed by referencing the following video.

https://youtu.be/p7OqcnXBQt8?si=E5JtC-xnrc5ZQYo_

First, note the IPv4 address of Service Network 1 for the started virtual machine.

Next, I added “DNAT” from the network tag. The “Source Global IPv4 Address” was auto-filled, and I entered the Service Network IPv4 address noted earlier as the “Destination Private IP Address.”

Next, I added an “ACL.” Following the video, I configured it as follows.

To allow access only from a specific IP address, I configured it as follows.

On the other hand, while there is a security risk in allowing unrestricted access from any address, configuring it as follows appears to allow SSH connections from any address.

Testing the Connection

Use the Source Global IPv4 Address added in DNAT. After the initial login, you will be prompted to change the password, so change it.

sshmdxuser@<SourceGlobalIPv4AddressaddedinDNAT>-i~/.ssh/mdx/id_rsa

Connecting with VS Code

Subsequent operations are optional, but I used the “Remote Explorer” extension for VS Code.

Work Inside the Virtual Machine

Checking GPU

sruo==doNGF=NP=otVPa=/rG=N@IUn=0AoP=osuD=cU=ubI=e=ruANT=Ns=un-ae=V2s=ntSmm=I5eGI=nuMep=DCsID=i-I=I:=n2=A=g25==03P=ACI=p45e=1PID=r:.r=00=o/8f=0=ch6=-=eo.=S=sm1=X=se0=M=e/=4=sm=-=d=4P=fx=0I=ou=GD=us=B=nePP==drew==#rr=T=s:=4y=niU=5p=vss=We=ita==deg=/=iDne==arc/=4P=-ieC=O0r=sv-a=n0o=meMp=Wc=ir=e=s=V=s=eB=0=ru=0n=ss=0a=i-=0m=oI=0e=nd=04=:=0M==0i=5M=:B=3e=0=5m=3/=.o=:=8r=04=6y=00=.D-=.9=1iU=06=0ss=0=pa=OM=.g=fi=Ae=fB===C=U==DVG==AoP==lU==Va-==etU==rit=0=sli=%=iel==o==nU==:nC=GU=co=Ps=1om=DUa=2rp=Dig=.ruM=esMe=2.tI=fae=eG=abm=E=ulo=CMM=ler=C..=0tdy===

Installing Docker

I installed Docker following the steps on the following page.

https://docs.docker.com/engine/install/ubuntu/

fssscsesssouuuuucuuurdddrdh""sdddooolood$uooope(dkaai-cb.oaadgppnfhppottssm[/tttci--tSoaee--knggaLdrteggeeelcceerdttlhah/ttot+=ercui-tr"stuiukpnmp$-cpnnedss/(r/dsrat0:edeaath.ta7/tplptaeiel5/cketellol5dga/llassodc-wpeod-oadnt-uowc-lp&rcokc/kr&ckreeeaeieelrrtdynesrd-tc.rtc.-didi-hlcofaonaoiecipcgrsctksc"tdda/e/h$.ootkrdiVdccee.otE/kksycceRdeerokcSorrcimetIc--un/ruOkccrgl.rNeeolsige_r-mnp)C.cpgug"OllonxDiisu/sEsepuiNtcgbgAopunM>noneEtdtd"/amu-)dia/b"enngyve-p=s/rdg/tndoeau.c|tblikclloes/erua"ddpocot|co/kngketperagy-irbniue-nirdgldesda/xrrd-umopnoclcrku;egrid.nog/pdsegout]cdcko/heatrapt-ptpct/so-k:mge/pey/otrdsioernw-egnpmsllo/ouvdageodic.n$kdpeokrcg.k;geprdg.ocnoem/linux/ubuntu\

If Hello from Docker! is displayed, the installation was successful.

NVIDIA Docker Runtime

(There may be better methods, but) I installed the NVIDIA Docker Runtime. I executed the following.

#dccssiuuuuAsrrdddtlloodri--astbsspyhutset---tiLLgepoemanhhtcc=tttk$ttula(pppg.ssdre::ae//tsre/etetnnapcv&ro/ii&tsoddisiisdt-aauoor..dcreggokiliieeettarsahhpsuutebb-;..geiiecoth/nnivvn$iisIddtDiia$aalV--lEddRoo-SccyIkkOeenNrrv_//iIg$dDpdi)giaks-etcyroin|btuastiuindoeonr/-antpvotio-dlkikeaiy-tdaodcdke-r.list|sudotee/etc/apt/sources.list.d/nvidia-docker.list

Adding the User Who Executes Docker Commands to the docker Group

Add the user to the Docker group

sudousermod-aGdocker$USER

System restart

sudoreboot

Installing NDL Classical Japanese OCR

From here, we proceed with the NDL Classical Japanese OCR setup.

The following takes some time.

gcsidhtncd/lldokonocetkeehnrto/tcdpros_c:ck/le/irgbiutihludb..schom/ndl-lab/ndlkotenocr_cli

Next, when starting the container, modify it to mount the host machine’s directory.

dockerrun-gpusall-d/home/mdxuser/tmpdir:/root/tmpdir-rm-namekotenocr_cli_runner-ikotenocr-cli-py37:latest

Then, execute the following.

sh/docker/run_docker.sh

Enter the container.

sshmdxuser@<SourceGlobalIPv4AddressaddedinDNAT>-i~/.ssh/mdx/id_rsa

0

Running Inference

Downloading Images

Create a directory and download “The Tale of Genji” (held by the National Diet Library).

sshmdxuser@<SourceGlobalIPv4AddressaddedinDNAT>-i~/.ssh/mdx/id_rsa

1

Running OCR

Execute OCR on the downloaded images.

First, create an output folder.

sshmdxuser@<SourceGlobalIPv4AddressaddedinDNAT>-i~/.ssh/mdx/id_rsa

2

Execute.

sshmdxuser@<SourceGlobalIPv4AddressaddedinDNAT>-i~/.ssh/mdx/id_rsa

3

As a result, the recognition results are stored in the /home/mdxuser/tmpdir/output folder on the host machine.

Other

Stopping the Container

sshmdxuser@<SourceGlobalIPv4AddressaddedinDNAT>-i~/.ssh/mdx/id_rsa

4

Shutting Down the Virtual Machine

sshmdxuser@<SourceGlobalIPv4AddressaddedinDNAT>-i~/.ssh/mdx/id_rsa

5

Summary

Thanks to mdx and the NDL Lab, I felt that an environment conducive to research using machine learning is well established. I would like to express my gratitude to those involved.