Friday, September 24, 2021

Gnome Terminal failed to run after upgrading default Python 3 interpreter to Python 3.7 in Ubuntu 18.04

Ubuntu 18.04 comes with Python 3.6 by default. You might be inclined to do a sid-by-side installation with Python 3.7 as explained at: Then you might try to switch the default Python3 interpreter from Python 3.6 to Python 3.7 by using $ sudo update-alternatives --config python3 . However, this could result in unwanted side effect which made Gnome Terminal failed to open/run. 

You can fix this issue by editing this file: /usr/bin/gnome-terminal. This file by default uses /usr/bin/python3 as the python interpreter. You need to change the gnome-terminal script to use /usr/bin/python3.6 as its python interpreter, as explained over at:, i.e. change the #!/usr/bin/python3 line to #!/usr/bin/python3.6 and you should be OK afterward.

Sunday, September 12, 2021

Installing TensorRT 7.2.1, cuDNN 8.0.4 and Cuda 11.0 update 1 in Ubuntu 18.04 (x86_64)

  1. Make sure you have up-to-date Nvidia display driver. You need v4.50.x or newer for Cuda 11 to work (I'm using v4.70.x). You can update it using standard Ubuntu repository or via Nvidia Ubuntu ppa if it's not yet up-to-date, as explained over at: In my case, I'm using standard Ubuntu repository without any problem. Make sure to follow the driver installation steps correctly if your machine is using UEFI secure boot and Nvidia PPA driver. Especially in the step that asks for password; make sure you remember the password that you entered because you will be asked the same password once you restart your machine to complete the driver installation.   
  2. Follow Cuda 11 update 1 installation guide at:
  3. Follow cuDNN 8.0.4 installation guide at:
  4. Follow TensorRT 7.2.1 installation guide at up-to the "sudo apt-get update" step (before the "sudo apt-get install tensorrt" step). Then, disable nvidia compute deb sources (*) from your ubuntu sources list file(s), except the ones in the tensorrt deb sources file. The tensorrt deb source file is usually named: /etc/apt/sources.list.d/nv-tensorrt-cudaXX.x*.list. You can disable the deb sources by commenting the line(s), i.e. adding a "#" (without the quotes) to the beginning of each line in the deb sources file (/etc/apt/sources.list.d/cuda.list, etc.) that points to* URL.  Then, install tensorrt along with its components normally ("sudo apt-get install tensorrt", etc.). Once tensorrt installation finished, make sure to enable nvidia compute deb sources as before, i.e. by deleting the comments (#) that you add in the beginning of the line(s) of the deb sources file that points to*. This TensorRT 7.2.1 installation fix is explained over at:


Bonus Fix 1: Python onnx library error

You might encounter onnx data type error shown below after your tensorrt is successfully installed in python:

TypeError: 1.0 has type numpy.float32, but expected one of: int, long, float

The error very probably caused by old protobuf version. You need to update it with pip3 via this command: pip3 install protobuf -U. For more details, see:


Bonus Fix 2: Cuda 11.0 missing

You might encounter this error in tensorflow 2.4+ application:

Could not load dynamic library ''
It says you have missing Well, actually the library is non-existent 
in Cuda 11 and the solution is to create symbolic link to which is 
 named in your Cuda 11 installation. It should work, as explained 
over at: . 
As for where you could find, it depends on the Cuda 11.0 version 
installed in your machine. 
In Cuda 11.0 update 1, is located at /usr/local/cuda-11.4/lib64
The directory is referred to indirectly by /usr/local/cuda and /usr/local/cuda-11 
symbolic links. It's a bit hairy and you need to create the 
symbolic link at /usr/local/cuda-11.4/lib64 that points to 

Sunday, September 5, 2021

Fixing Failure to Load Video in OpenCV-Python on Linux

The failure to load video in OpenCV-Python usually happened with older Linux distributions. In my case, it happened in Ubuntu 18.04. The failure in video loading can be detected in python code similar to this:

import cv2


cap = cv2.VideoCapture(video_file_path)

if cap.isOpened():

    print("Video file loaded successfully")


    print("Failed to load video!") 



The failure to load the video very possibly is caused by erratic OpenCV-Python installation. In my case it was caused by very old pip version. Old pip version will trigger unexpected problems, in my case the old pip version (pip version 9.x) forces OpenCV recompilation when installing OpenCV-python. The old pip version installed the result of the recompilation at the end of pip's execution. Due to erratic pip behaviour, the resulting opencv-python is not working properly. Anyway, as a sidenote: I'm using python 3 venv virtual environment when I encountered this problem. 


The fix is quite simple:

  1. Uninstall your current (unworkable) OpenCV-python. In my case, simply invoking "pip unistall opencv-python" works. I carried-out this command inside the virtual environment that has the erratic OpenCV-python. 
  2. Upgrade your pip version into more up-to-date version with "pip install --upgrade pip" command. Don't be afraid to carry-out this step if you're using python virtual environment because it won't affect your machine in any way. 
  3. Re-install OpenCV-python with pip with the following command: "pip install opencv-python" or if you want to specify the specific OpenCV-python version you can do that as well, as in (installing opencv-python version "pip install opencv-python==" 
This isssue is explained in more detail here: (point 2 in the Installation section). It took me an hour to figure out the problem because I've never encountered the issue before. Hopefully this helps you out if you have similar problem.

Fixing "RTL8822CE wireless adapter doesn't work" on Ubuntu 18.04

 RTL8822CE wifi adapter doesn't work out of the box in Ubuntu 18.04 due to missing firmware, not because the driver is not included in Ubuntu 18.04. The fix requires you to be able to download the required firmware from and copying the firmware to your Ubuntu 18.04 firmware directory.  To do that, first, you have to make sure the machine have an internet connection before you do the steps below, either via the machine ethernet connector or some other means, in my case I have a spare USB WiFi adapter that works out of the box in Ubuntu 18.04 to do this. Then, configure the Wifi firmware like this:

sudo apt install git
git clone git://
sudo cp linux-firmware/rtw88/rtw8822c_wow_fw.bin /lib/firmware/rtw88 
Another approach would be to copy the file manually via USB thumbdrive, if you can't connect the connect the machine to the internet via some other means. 
This fix is elaborated over at: