nvidia


Compiling ffmpeg with NVIDIA GPU Hardware Acceleration on Ubuntu 20.04LTS

Please note that the following commands were executed on a system that already had CUDA support so we might be missing a step or two to enable NVIDIA CUDA support.

Install necessary packages

sudo apt-get install build-essential yasm cmake libtool libc6 libc6-dev unzip wget libnuma1 libnuma-dev nvidia-cuda-toolkit;

Clone and install ffnvcodec

git clone https://git.videolan.org/git/ffmpeg/nv-codec-headers.git;
cd nv-codec-headers;
sudo make install;
cd -;

Clone and compile FFmpeg’s public GIT repository with NVIDIA GPU hardware acceleration

git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg/;
cd ffmpeg;
./configure --enable-nonfree --enable-cuda-nvcc --enable-libnpp --extra-cflags=-I/usr/local/cuda/include --extra-ldflags=-L/usr/local/cuda/lib64 --disable-static --enable-shared;
make -j 8;
sudo make install;

SUCCESS!

After performing the above steps, we were able to process media using ffmpeg without stressing our CPU! The workload was transferred to the GPU!


Rough notes on how to install CUDA on an Ubuntu 20.04LTS 1

To anyone coming across this post, please note that Canonical does not officially support CUDA. Not being supported formally means that you could face problems that we did not while setting up our machine.

Recently we wanted to use our GPU to execute various TensorFlow projects. We had to use version 1, specifically version 1.15 of TensorFlow, on one of our attempts. That setup was causing many problems even after version 2 was working perfectly. There must be something different with version 1, and it is not supported correctly anymore. We recommend avoiding using it unless needed.

Finding out what graphics card we have

Before getting started, we executed the following command that gave us the model of our graphics card:

lspci | grep -i nvidia;
$ lspci | grep -i nvidia
01:00.0 VGA compatible controller: NVIDIA Corporation TU104 [GeForce RTX 2080 Rev. A] (rev a1)
01:00.1 Audio device: NVIDIA Corporation TU104 HD Audio Controller (rev a1)
01:00.2 USB controller: NVIDIA Corporation TU104 USB 3.1 Host Controller (rev a1)
01:00.3 Serial bus controller [0c80]: NVIDIA Corporation TU104 USB Type-C UCSI Controller (rev a1)

Installing dependencies and NVidia repositories

Then we proceeded to install the headers of our Linux kernel, the repositories of NVidia, and finally install CUDA using apt-get.

sudo apt-get install linux-headers-$(uname -r);
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-ubuntu2004.pin;
sudo mv cuda-ubuntu2004.pin /etc/apt/preferences.d/cuda-repository-pin-600;
sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/7fa2af80.pub;
sudo add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/ /";
sudo apt-get update;
sudo apt-get -y install cuda;
sudo apt-get install nvidia-gds;

After this step, we rebooted the computer to load the NVidia graphics driver.


Quick note on setting up our programming environment for Coursera.org “DeepLearning.AI TensorFlow Developer Professional Certificate” on Ubuntu 18.04LTS

Recently we were working on some local Jupyter notebooks for the “DeepLearning.AI TensorFlow Developer Professional Certificate“.

To prepare for the setup with GPU, we followed the instructions at https://www.tensorflow.org/install/gpu. But as we were going through the notebooks we noticed the following error at the terminal:

W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'libcublas.so.10'; dlerror: libcublas.so.10: cannot open shared object file: No such file or directory

Even though libcublas.so.10 was installed it was not loading. Using find was saw that it was installed and available at the folder /usr/local/cuda-10.2/targets/x86_64-linux/lib/ but it was ignored.

To fix this, we added a new entry in ~/.profile as follows:

if [ -d "/usr/local/cuda-10.2/targets/x86_64-linux/lib/" ]; then
    export LD_LIBRARY_PATH=/usr/local/cuda-10.2/targets/x86_64-linux/lib/:${LD_LIBRARY_PATH}
fi

And then executed source ~/.profile from the terminal which we would start the jupyter-notebook command.

After this, library was loaded as expected.


Qubes 4.0: Installation crashes when installing qubes-mgmt-salt-base-topd.noarch 5

Solution

  1. Disable Secure Boot from BIOS
  2. On boot order, select Legacy Devices first, again from BIOS
  3. At the first screen of the installer (like the image below), press the e button to edit the boot arguments, disabling the graphics card driver. For us what worked is the following:
    mboot.c32 xen.gz console=none --- vmlinuz inst.stage2=hd:LABEL=Qubes-R4.0-x86_64 i915.alpha_support=1 mapbs=1 noexitboot=1 modprobe.blacklist=nouveau rd.driver.blacklist=nouveau -- initrd.img
  4. Enjoy!

Back Story

Recently, we were trying to install Qubes GNU/Linux version 4.0 on a Lenovo Legion Y520 that has NVIDIA® GeForce® GTX 1050 Ti installed. After disabling secure boot from the BIOS and then setting the default boot to be on Legacy Devices, we were able to boot the anaconda installer.

We proceeded into configuring the installation (set the timezone, the keyboard layout, created the administrator user and selected the disk for the installation) and we waited for the system to install. After some serious amount of time, we realized that the installer had crashed completely while installing qubes-mgmt-salt-base-topd.noarch. We restarted the process and tried again, this time the installed did not crash but it would get stuck at the same step. Following, we gave it a few more tries just in case it would work but unfortunately it would always result either crashing or getting infinitely stuck.

Following the guide at https://www.qubes-os.org/doc/uefi-troubleshooting/ and https://www.qubes-os.org/doc/nvidia-troubleshooting/ we modified the boot parameters of the installer to add mabps and noexitboot, then disable the nouveau driver for the graphics card and it worked like a charm.