RISC-V public beta platform released· Configuring Jupiter+Octave scientific computing environment on SG2042

Introduction

JupyterHub is an open source shared computing platform that manages a separate Jupyter environment for each user and can be used for student classes, enterprise data science groups, or scientific research groups. It is a multi-user hub that can spawn, manage and proxy multiple instances of single-user Jupyter notebook servers.

GNU Octave is a software primarily for numerical analysis in a high-level programming language. Octave facilitates numerically solving linear and nonlinear problems and performing other numerical experiments using a MATLAB-compatible language. It is also available as a batch-oriented language. Because it is part of the GNU Project, it is free software under the terms of the GNU General Public License.

In this issue, we will try Jupyter and Octave to form a multi-user scientific computing platform.

Experimental Materials:

Python 3 (if not, please install python3 first)

pip (if not installed, please install python3-pip first)

Octave source code

One HS-2 server

server configuration:

CPU: SG2042 (64 cores)

RAM:32GB

Hard drive capacity: 1TB

Operating system: Ubuntu 22.10 (GNU/Linux 6.1.31 riscv64)

Experimental steps:

First install JupyterHub, JupyterLab and Jupyter Notebook via pip:

pip3 install jupyterhub jupyterlab notebook

Generate the configuration file (the configuration file can be modified according to the actual situation):

jupyterhub --generate-config

Then start jupyterhub:

jupyterhub

Or run in the background:

nohup jupyterhub &

Just access [server address]:8000 with your browser. After visiting, we found that although we saw JupyerHub running, it only had Python3 and no Octave option.

picture

Therefore, we also need to install Octave and related components.

There are two ways to install Octave: compile installation and apt installation.

Method 1: Install directly using apt

sudo apt install octave

Method 2: Compile and install

Download Octave source code package

wget 

https://mirror2.sandyriver.net/pub/software/gnu/octave/octave-8.3.0.tar.gz

(If the download speed is slow, you can download it on your computer in advance, and then transfer the file to the server)

Unzip the Octave source package

tar -xzvf octave-8.3.0.tar.gz

Enter the Octave source code folder

cd octave-8.3.0/

picture

 Configuration:

./configure

Compile:

make -j64(线程数根据实际情况来设置)

Install:

sudo make install

Run octave shell. If the version number and prompt appear, it means the installation is successful!

picture

Install octave-kernel

pip3 install octave-kernel

Install gnuplot

sudo apt-get install gnuplot

Then restart jupyterhub (if it is running in the background, please ensure that all jupyterhub-related processes have been killed before restarting):

jupyterhub

or:

nohup jupyterhub &(后台运行)

Then open the browser again and visit [server address]:8000 to see the Octave notes.

picture

 We choose Octave to create a new note.

Draw a graph of a sine function:

graphics_toolkit("gnuplot");
gnuplot_binary('/usr/bin/gnuplot'); % 设置gnuplot二进制文件的路径,具体路径可能不同
% 生成一组 x 值(从 0 到 2π,间隔为 0.01)
x = 0:0.01:2*pi;
% 计算对应的正弦值
y = sin(x);
% 绘制正弦函数图
plot(x, y);
title("Sin Function"); % 添加标题
xlabel("x"); % 添加 x 轴标签
ylabel("sin(x)"); % 添加 y 轴标签
grid on; % 添加网格线

Effect:

picture

Draw a heart shape:

picture

In fact, Octave can not only draw pictures, but can even calculate the Fibonacci sequence.

picture

 Even calculating pi:

picture

The result indicates that the library is missing. Therefore we need to install the symbolic package.

Thanks to Octave's support for installing expansion packs, we can use some expansion packs to achieve more functions and make Octave more powerful.

picture

After entering Octave Shell, first update the expansion package source, then download and install the symbolic package:

pkg update
pkg install -forge symbolic

 Just try running again:

picture

​​​​​Then test 10, 100, 1000, 10000 and 100000 bits respectively:

10位:1.1531 秒
100位:1.155 秒
1000位:1.1567 秒
10000位:1.2044 秒
100000位:3.2812 秒

 

The next step is to try multi-user. Although Jupyterhub can be managed by a single notebook with multiple users, if you need to achieve multi-user management, you need a root account.

First switch to the root account:

su

After entering the password, log in as the root user, and then return to the home directory:

cd

Install related packages:

pip3 install jupyterhub jupyterlab notebook

Create a new jupyerhub folder:

mkdir jupyterhub

Copy the previous configuration file (you can modify it appropriately according to your own situation)

cp jupyterhub_config.py jupyterhub

Or create a new configuration file

jupyterhub --generate-config

Start JupyterHub

jupyterhub

Start JupyterHub in background

nohup jupyterhub &

But there is no Octave in other user interfaces, so I installed octave-kernel directly under the root user.

pip3 install octave-kernel

Start three users at the same time, calculate Pi, and observe the time taken to ensure that the Octave of the three users is in the Busy state.

The results are as follows (accurate to 100,000 decimal points):

perfxlab01:6.762秒
python01:6.6159秒
python02:6.9564秒

 After testing, the difference is only a few tenths of a second, but it takes longer than calculating pi for a single user.

Not only can you use Octave notes, you can also use the Octave command symbol (Shift+Enter to send commands).

picture

picture

 

Tips:

When performing configuration or compilation, if you are prompted that required dependencies are missing, please install the required dependencies first and then perform configuration or compilation again.

When running the code, if you are prompted that required dependencies are missing, you can first log in as root and install the required dependencies, and then restart the Jupyter server of each user (or directly restart the entire JupyterHub).

Experiment summary:

With the blessing of JupyterHub, the HS-2 server can now become an excellent scientific computing platform. Coupled with Octave, you can not only use Python to run scientific computing on JupyterHub, but you can also use Octave to complete scientific computing tasks, and even more Users use the same JupyterHub server.

References:

JupyterHub page

https://jupyter.org/hub

Octave official website

https://octave.org/

Octave Packages

https://gnu-octave.github.io/packages/

Configuration Reference — JupyterHub documentation

https://jupyterhub.readthedocs.io/en/stable/reference/config-reference.html

End of text


  • About HS-2

The HS-2 RISC-V universal motherboard is a standard mATX motherboard designed for developers jointly developed by Pengfeng Technology and its partners. It is pre-installed with a software package customized and developed by Pengfeng Technology for RISC-V high-performance servers. Including various standard benchmarks, GCC compiler that supports V extension, computing library, middleware and a variety of typical server applications.

The HS-2 RISC-V general-purpose motherboard is equipped with a domestic RISC-V 64-core processor (SG2042). SG2042 is the highest-performance RISC-V processor currently in mass production. It is mainly designed for the needs of high-performance computing and is suitable for large computing power application scenarios such as scientific computing, engineering computing, AI computing, and fusion computing.

picture

picture

 About the RISC-V public test platform

picture

 RISC-V high-performance processor public test cloud platform · Quick start guide, download link: https://www.kdocs.cn/l/cmnYcyFIlVRx

  • RISC-V public test cloud platform series of articles

  1.  RISC-V public beta platform released·Stream bandwidth complete test

  2.  RISC-V public beta platform released · Minecraft MohistMC

  3.  RISC-V public beta platform released·The first WEB Server "Hello RISC-V world!"

  4.  RISC-V public beta platform released·How to play k3s on SG2042

  5. "RISC-V Growth Diary" blog released, the first blog running on RISC-V server?

  6. RISC-V public beta platform released: How to play OpenMPI on SG2042

  7. RISC-V public beta platform released: Compiling The Fedora Linux Kernel Natively on RISC-V

  8.  RISC-V public beta platform released·Unix Bench complete test

  9. RISC-V public beta platform released·Using YCSB to test MySQL performance on SG2042

  10. RISC-V public beta platform released · 7-zip test

  11. RISC-V public beta platform released · CoreMark test report

  12. RISC-V public beta platform released · Evaluation of database adaptation on RISC-V server

  13. RISC-V public beta platform released · Configuring Jupiter+Octave scientific computing environment on SG2042 (this article)

Guess you like

Origin blog.csdn.net/weixin_45571628/article/details/132453095