April 10, 2021

[Note] convert, memory allocation failed, attempt to perform an operation not allowed

Trying to convert multiple image files to a PDF file:

$ convert *.gif output.pdf

Then I got bunch of errors such as:

convert-im6.q16: memory allocation failed `302.gif' @ error/gif.c/ReadGIFImage/1303.

This is due to insufficient memory, and can be fixed in ImageMagick policy file.

First, find where the policy file is by running this command:

$ identify -list policy | more

Mine is in /etc/ImageMatick-6/policy.xml

$ identify -list policy | more

Path: /etc/ImageMagick-6/policy.xml
  Policy: Resource
    name: disk
 

Edit the file and allocate more memory:

$ sudo vi /etc/ImageMagick-6/policy.xml

Find this line and change its value.  I have 64GB memory, allocated 32GB:

<policy domain="resource" name="memory" value="32GiB"/>


I ran, but encountered another error:

$ convert *.gif output.pdf
convert-im6.q16: attempt to perform an operation not allowed by the security policy `PDF' @ error/constitute.c/IsCoderAuthorized/408.

Again, this is due to the policy.  Edit the file again and remove or comment out these lines:

<!-- 
<policy domain="coder" rights="none" pattern="PS" />
<policy domain="coder" rights="none" pattern="PS2" />
<policy domain="coder" rights="none" pattern="PS3" />
<policy domain="coder" rights="none" pattern="EPS" />
<policy domain="coder" rights="none" pattern="PDF" />
<policy domain="coder" rights="none" pattern="XPS" />
-->

Then it worked fine.

 

Resources

 

April 2, 2021

Learning Quantum Computing, Qiskit


Quantum Computing courses

The Introduction to Quantum Computing
https://www.coursera.org/learn/quantum-computing-algorithms/home/welcome

Physical Basics of Quantum Computing
https://www.coursera.org/learn/physical-basis-quantum-computing/home/welcome

Quantum Computing. Less Formulas - More Understanding
https://www.coursera.org/learn/quantum-computing-lfmu/home/welcome

 

 

Qiskit

https://qiskit.org/textbook/preface.html

https://www.youtube.com/c/qiskit/playlists



[Old Tech] Alpine mail client, Spreadsheet Calculator

Terminal Email Client

Long time ago, when I used Solaris -- I used mail, then elm, then pine.  I really liked elm for its simplicity, lightweight.  

I couldn't find elm for Linux or its clone, but found Alpine which is Apache License Pine.

 There are plenty of web sites showing how to set up Alpine for Gmail, so won't put another step here.  Just visit this page, for example - https://www.xmodulo.com/gmail-command-line-linux-alpine.html

https://www.lifewire.com/thmb/iOr37RW3BwE85A_HuWRIhA-CA3s=/964x640/filters:no_upscale():max_bytes(150000):strip_icc()/alpinemail-5bda0015c9e77c005242c909.jpg


Terminal Spreadsheet

There is a terminal version of spreadsheet -- feels like VisiCalc or Lotus 1-2-3.  It's called Spreadsheet Calculator (SC), https://en.wikipedia.org/wiki/Sc_(spreadsheet_calculator)

It's pretty useful sometimes when you are stuck in terminal, or want to do quick calculation.  

See these pages for usage, 

 https://www.maketecheasier.com/assets/uploads/2014/06/sc-working-sheet-800px.jpg


March 20, 2021

[Note] Run Flash in year 2021

All latest browsers and Flash player itself stopped supporting Flash sites by end of 2020.

This note is to enable Flash (at your own risk) for special circumstances.  For my case, it's to run Oracle 18XE EM.

 

GOAL

Run Flash site in year 2021.

Environment

Ubuntu 20.04, 64 bit

Why?

Oracle 18XE EM still uses Flash.  I prefer GUI over console to do occasional Oracle DB admin tasks.

Note

Overview

  1. Get an older version of Chrome and install
  2. Get Flash Player and install
  3. Install some Ubuntu packages
  4. Configure flash/chrome/Ubuntu
  5. Run chrome and set up for Flash site within the browser

Chrome - download and install

  1. Go to https://www.slimjet.com/chrome/google-chrome-old-version.php
  2. I downloaded 79.0.3945.88 version:
    https://www.slimjet.com/chrome/download-chrome.php?file=files%2F79.0.3945.88%2Fgoogle-chrome-stable_current_amd64.deb
  3. It will save as google-chrome-stable_current_amd64.deb
  4. Install:
    $ sudo apt install ./google-chrome-stable_current_amd64.deb
    This will install the program in /opt/google/chrome/

Older Chromium may work, but I didn't try.  You can get it from here:
https://www.ubuntuupdates.org/pm/google-chrome-stable

Flash - download and install

  1. Go to https://archive.org/details/adobe-flash-player-32.0.0.465-retail-debug
  2. Download GZIP ->  flash_player_ppapi_linux.x86_64.tar.gz (9.3M) 
  3. Uncompress it and put the files to a folder in /usr/lib/adobe-flashplugin/

[email protected]:/usr/lib/adobe-flashplugin
(2016) $ ll
total 21816
drwxrwxr-x   3 kkim kkim     4096 Mar 17 23:16 ./
drwxr-xr-x 217 root root    20480 Mar 17 23:18 ../
drwxrwxr-x   2 kkim kkim     4096 Nov 24 18:22 LGPL/
-rw-rw-r--   1 kkim kkim 19509216 Nov 24 18:22 libpepflashplayer.so
-rw-rw-r--   1 kkim kkim  2792147 Nov 24 18:22 license.pdf
-rw-rw-r--   1 kkim kkim     2223 Nov 24 18:22 manifest.json
-rw-rw-r--   1 kkim kkim     2662 Nov 24 18:22 readme.txt


Reference

Configure Chrome

This is to use the flash player.

  1. $ vi /usr/share/applications/google-chrome.desktop
  2. Change Exec= entry like this:
    Exec=/usr/bin/google-chrome-stable -ppapi-flash-path="/usr/lib/adobe-flashplugin/libpepflashplayer.so" --ppapi-flash-version=32.0.0.465 %U

Reference, https://support.google.com/chrome/thread/12367064?hl=en
 

Install Ubuntu Package

We need supporting packages.

$ apt install adobe-flashplugin browser-plugin-freshplayer-pepperflash

Reference

Configure Chrome+Flash to run Flash site

Create two mms.cfg files in two different locations:

$ vi /etc/adobe/mms.cfg
$ vi ~/.config/google-chrome/Default/Pepper Data/Shockwave Flash/System/mms.cfg

Add content like this:

$ more /etc/adobe/mms.cfg
# Disable Automatic Updates
AutoUpdateDisable=1
SilentAutoUpdateEnable=0
 
# Disable prompts to uninstall Flash Player
EOLUninstallDisable = 1
 
# duplicate actionscript console output
# in browser's console for javascript
TraceOutputEcho=1
 
# Enable the AllowList feature
EnableAllowList=1
 
# Normally, the allow list blocks URL requests
# unless the url matches a pattern in the list.
# In preview mode, all requests go unblocked,
# but console output is written for each request
# indicating which pattern it matched or that
# no match was found.
AllowListPreview=0
 
# Pattern to enable Your OEM:
AllowListUrlPattern=https://localhost:55500/
AllowListUrlPattern=https://localhost:55500/em
AllowListUrlPattern=https://helpx.adobe.com/


Reference,

Allow Flash for a site in browser

  1. Run Chrome
  2. Open these two sites as configured in mms.cfg
  3. Pass security warning and proceed to the page (if EM page)
  4. Click on padlock icon and change Flash to Allow.

Do not update Flash or Chrome browser.

Reference, https://www.stephenwagner.com/2021/01/13/enable-adobe-flash-chrome-after-end-of-life/

Closing

  • Was it worth it?  It was fun to find a solution, and now I can use Oracle EM.
  • Better way?  Upgrade Oracle to a higher version that EM doesn't use Flash.  Or, use command line instead.

Misc 




February 15, 2021

[Note] Windows 10 auto login

I have Windows 10 running on VirtualBox for testing, and want to enable auto-login.  MS removed this feature from settings, and registry change is required.


  1. Run regedit
  2. Go to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon
  3. Set AutoAdminLogon to 1
  4. Set DefaultUserName to your user anem
  5. Create DefaultPassword string entry and enter your password


References


January 29, 2021

[Note] add Anaconda to Win10 Terminal

From: https://dev.to/azure/easily-add-anaconda-prompt-in-windows-terminal-to-make-life-better-3p6j

Open settings from Terminal and add following:

    {
        "guid""{0caa0dad-35be-5f56-a8ff-afceee452369}",
        "name""Anaconda",
        "icon""%USERPROFILE%\\Anaconda3\\Menu\\anaconda-navigator.ico",
        "commandline""cmd.exe /K C:\\Users\\kkim\\Anaconda3\\Scripts\\activate.bat",
        "hidden"false
      }

Just change the user name (e.g "kkim") with yours.




January 24, 2021

Fira Code





Download

https://github.com/tonsky/FiraCode/releases/download/5.2/Fira_Code_v5.2.zip

Check the latest on https://github.com/tonsky/FiraCode


Install

Windows 10

Settings -> Font -> drop the font files


Ubuntu

$ sudo apt install fonts-firacode


VSC (Visual Studio Code)

Open settings.json and add/update:

"editor.fontFamily": "'Fira Code'",
"editor.fontLigatures" : true,
"editor.fontSize": 15,


(was: "editor.fontFamily": "'Droid Sans Mono', 'monospace', monospace, 'Droid Sans Fallback'",


Preview Font

Programming Fonts Test Drive, https://www.programmingfonts.org/


References

January 12, 2021

[Note] GNOME shell gets slower

System: Ubuntu 20.04

GNOME gets slower as I leave the computer on for more than a few days and keep using it -- drop down menu gets affected especially slow.  Seems like some menus are ok though.  And overall computer performance gets slower also.

Login out-back in makes little better, but not so much.  Eventually GUI becomes unusable and have to restart.

I did some googling and seems it is a known issue but happens to others in different situations.

There is no fix for this yet.  

If that happens, the remedy is restarting gnome-shell.  

ALT-F2 and then type "r".

 

 

Reference

https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/62

 

[Note] Set CPU to max for Ubuntu 20.04

Objetive: Set CPU speed to max

Issue:

Setting CPU performance is not working properly in Ubuntu 20.04 for old Xeon (max 3GHz).  Trying to set it to MAX all the time.

 

Checking current setting:

$ more /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
::::::::::::::
/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
::::::::::::::
ondemand
::::::::::::::
/sys/devices/system/cpu/cpu1/cpufreq/scaling_governor
::::::::::::::
ondemand
::::::::::::::
/sys/devices/system/cpu/cpu2/cpufreq/scaling_governor
::::::::::::::
ondemand
::::::::::::::
/sys/devices/system/cpu/cpu3/cpufreq/scaling_governor
::::::::::::::
ondemand

 

Changing setting manually:

$ sudo -i
$ echo "performance" | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor

However, this setting will revert after reboot.


Step 1. Changing in BIOS

For my PC (Dell workstation), SpeedStep can be disabled in BIOS.

After reboot, the CPU speed still fluctuate.

Step 2. change boot option in grub

$ sudo vi /etc/default/grub

GRUB_CMDLINE_LINUX_DEFAULT="intel_idle.max_cstate=0 processor.max_cstate=1 pcie_aspm=off quiet splash"

Step 3. disable 'ondemand'

$ systemctl is-enabled ondemand
$ systemctl disable ondemand

and reboot.


References


January 11, 2021

[Note] sonatype-nexus in Docker

Docker

1. Create data folder

$ mkdir /data/docker.data/nexus && chown -R 200 /data/docker.data/nexus

2. Map the data folder and create container

$ docker run -d -p 8088:8081 --name nexus -v /data/docker.data/nexus:/nexus-data sonatype/nexus3

Wait about 3 min.  

 

Set up Nexus

1. admin password is in <data folder>/nexus/admin.password

$ more /data/docker.data/nexus/admin.password 

2. Open http://localhost:8088, ID=admin and PW=from previous step

3. Update password, create user, create repository.


Test

Set up .m2/settings.xml:

<settings>
  <servers>
    <server>
      <id>test</id>
      <username>kkim</username>
      <password>*USER PASSOWRD SET IN NEXUS*</password>
    </server>
  </servers>
</settings>


Deploy JAR.  "repositoryId=" must match with server id from above settings.xml:

$ mvn deploy:deploy-file \
    -DgroupId=com.keithkim.test \
    -DartifactId=test-module \
    -Dversion=1.0.0 \
    -DgeneratePom=true \
    -Dpackaging=jar \
    -DrepositoryId=test \
    -Durl=http://localhost:8088/repository/keithkim/jars \
    -Dfile=/opt/jars/sqlite-jdbc-3.23.1.jar

If you get build failure like this:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.163 s
[INFO] Finished at: 2021-01-11T01:53:52-05:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy-file (default-cli) on project standalone-pom: Failed to deploy metadata: Could not transfer metadata com.keithkim.test:test-module/maven-metadata.xml from/to test (http://localhost:8088/repository/keithkim/jars): Transfer failed for http://localhost:8088/repository/keithkim/jars/com/keithkim/test/test-module/maven-metadata.xml 400 Bad Request -> [Help 1]

Edit this file, <DATA DIR>/etc/nexus.properties

$ vi /data/docker.data/nexus/etc/nexus.properties

Add this line:

nexus.maven.metadata.validation.enabled=false

Restart the container and try again.


January 7, 2021

[Note] CUDA reinstall with Ubuntu 20.04 and Nvidia driver 455.45.01

After upgrading Nvidia driver to 455, tensorflow-gpu stopped working and this is a note on reinstallling all the necessary s/w.

Environment

  • Xeon CPU with AVX, no BMI2
  • Ubuntu 20.04
  • Nvidia Driver 455
  • Quadro P2000 (compute capabilities=5.2)

 

What didn't work

I thought this may be an opportunity to upgrade CUDA, tenssrflow and everything else but learned it's not that simple for my PC.

Tried CUDA 11.1 + Tensorflow 2.4 = This requires CPU supporting BMI2 instructions.  Otherwise need to compile TF2.4 myself.

Downgrading the driver to 450, 440 with CUDA 10.2 (or 10.1) + TF 2.2.0 = after reboot, driver is back to 455.  Not working.


What worked 

Driver v455 + CUDA 10.2 + TF 2.2.0

And the installation was pretty simple:

1. Install v455 driver

2. Install CUDA, $ sudo apt-get install nvidia-cuda-toolkit

$ conda create -n tf python=3.7.9
$ conda activate tf
$ conda install tensorflow-gpu=1.5.0 keras

Or,

$ conda create -n tf2 python=3.7.9
$ conda activate tf2
$ conda install tensorflow-gpu=2.2.0 keras

Step #2 will install CUDA 10.2.


Jupyter

Install Jupyter

$ conda install
$ conda install -c conda-forge jupyter_nbextensions_configurator jupyter_contrib_nbextensions

$ jupyter nbextensions_configurator enable --user


When run Jupyter, noticed a lot of error messages like this:

Config option `template_path` not recognized by `ExporterCollapsibleHeadings`.  Did you mean one of: `extra_template_paths, template_name, template_paths`?

This can be fixed by downgrading nbconvert from 6.0.7 to 5.6.1:

$ conda install nbconvert=5.6.1

But Jupyter extension is still broken.  Nbextentions tab does not appear.  File->Edit-> nbextensions, I get this error:

404 GET /static/notebook/js/mathjaxutils.js?v=2021010720231

To fix this,

1. Go to conda envs directory.  e.g. $ cd ~/anaconda3/envs/tf

2. $ vi ./lib/python3.7/site-packages/jupyter_nbextensions_configurator/static/nbextensions_configurator/render/render.js

3. change 'notebook/js/mathjaxutils' to 'base/js/mathjaxutils'


Reference, 

https://discourse.jupyter.org/t/the-static-notebook-js-mathjaxutils-js-is-missing/7303/2



Helpful Commands

$ lscpu | grep -i bmi2

$ sudo lshw -C display

$ sudo ubuntu-drivers devices