OpenMythosのサンプルプログラムを動かしました

1.概要 前回、OpenMythosの環境構築まで実現したので、GitHubにあるサンプルプログラム(Usage)を動かしてみました。一部エラーが発生しましたが、結果出力部分なので修正をしました。その内容を記述します。 2.詳細 Usageに記載されているPythonプログラムをopenmythos_usage.pyとして作成します。 $ source ~/mypy/bin/activate (mypy) $ pythoh3 openmythos_usage.py 下記エラーとなります [MLA] Parameters: 1,538,626 [MLA] Logits shape: torch.Size([2, 16, 1000]) [MLA] Generated shape: torch.Size([2, 24]) Traceback (most recent call last):   File "/home/nakasima/openmythos/openmythos_usage.py", line 48, in <module>     rho = torch.linalg.eigvals(A).abs().max().item()           ^^^^^^^^^^^^^^^^^^^^^^^ RuntimeError: linalg.eig: The input tensor A must have at least 2 dimensions. コードの下記部分を修正します #rho = torch.linalg.eigvals(A).abs().max().item() rho = A.abs().max().item() $ source ~/mypy/bin/activate (mypy) $ pythoh3 openmythos_usage.py [MLA] Parameters: 1,538,626 [MLA] Logits shape: torch.Size([2, 16, 1000]) [MLA] Generated shape: torch.Size([2, 24]) [MLA] Spectral radius ρ(A) = 0.3679 (mus...

PCクラスタを利用したHPCの試験構築

 1.概要

PCクラスタを利用したHPC(high-performance computing)がどのようなものであるかを調べているとOpen MPIを見つけました。Open MPIはHPCのライブラリで具体的な構築方法を探していると大学のWebサイトでMPIを利用し、Ubuntu Serverをベースとした環境構築資料を見つけました。

試験的な構築をするため、Ubuntu DesktopのKVMを利用して、VMのUbuntu serverでhpcの仕組みを調べてみました。その内容を記述します。

2.詳細

(1) 導入手順

(a) kvm install
(b) ubuntu-20.04 server install
(c) ip-address変更(vmは192.168.122.10, 192.168.122.20に設定)
(d) ubuntu update
(e) vm clone(vm ubuntu serverを2台構築)
(f) hostname変更
(g) master node(ubuntu desktop)にnfs-server構築
(h) worker node(vm ubuntu server)にnfs-client構築
(i) open MPIをmaster node, worker nodeに導入
(j) sshの追加設定
(k) sample programのmaster nodeでbuild
(l) maser nodeでsample program実行
(m) worker nodeでsample program実行

(2) 詳細

(a)〜(f)までは、本ブログのkubernates in kvm(2022-09-02を参照願います)

(g) master node(ubuntu desktop)にnfs-server構築
$ sudo apt install nfs-kernel-server

nfs server設定
$ mkdir /home/username/share

/etc/exportsに下記1行を追加
/home/username/share 192.168.122.0/24(rw,async,no_root_squash)

(h) worker node(vm ubuntu server)にnfs-client構築
$ sudo apt install nfs-common

/etc/fstabに下記1行を追加
192.168.122.1:/home/username/share  /home/username/share  nfs defaults 0 0

(i) open MPIをmaster node, worker nodeに導入
$ sudo apt install gcc g++ gfortran
$ sudo apt install openmpi-bin libopenmpi-dev

(j) sshの追加設定
master nodeでssh-keygen実行
$ ssh-keygen -t rsa -b 4096
$ cp .ssh/id_rsa.pub share

worker nodeでssh設定変更

$ cp share/id_rsa.pub .ssh/authorized_keys

Public-keyでの認証でssh-loginできるかmaster nodeで確認
/etc/ssh/sshd_configの下記箇所を修正
PubkeyAuthentication yes
PasswordAuthentication no
PermitEmptyPasswords no

(k) sample programのmaster nodeでbuild
参考資料にサンプルがあります。利用しました。
master nodeの/home/username/shareにhello.cで作成

#include <stdio.h>
#include "mpi.h"
     
int main( int argc, char *argv[] )
{
    int     rank, size, len;
    char    name[MPI_MAX_PROCESSOR_NAME];
     
    MPI_Init( &argc, &argv );
    MPI_Comm_rank( MPI_COMM_WORLD, &rank );
    MPI_Comm_size( MPI_COMM_WORLD, &size );
    MPI_Get_processor_name( name, &len );
    name[len] = '\0';
     
    printf( "Hello world: rank %d of %d running on %s\n", rank, size, name );
     
    MPI_Finalize();
    return 0;
}

buildします
$ mpicc -o hello hello.c

(l) maser nodeでsample program実行
$ mpirun -n 4 ./hello

(m) worker nodeでsample program実行
master nodeの/home/username/shareにhostを下記内容で作成

192.168.122.20 slots=4
192.168.122.30 slots=4

worker nodeを利用した実行
$ mpirun -hostfile host -np 8 ./hello

参考
[外部サイト参照]
Open MPI: Open Source High Performance Computing
自作クラスタ計算機 • mpiによる並列計算

コメント

このブログの人気の投稿

miniPCのBMAXでWindows11のsecure boot設定漏れでトラブル発生

LinuxMint-22.3にWine 11.6をサクッと入れてみました

LinuxMint 21.3にWinBoat導入を試してみました