Category: knowledgebase

Knowledgebase articles, how-tos, and news.

  • Understanding the Modern GPU – Engine of Parallel Processing

    Understanding the Modern GPU – Engine of Parallel Processing

    While nearly every computer has one, the Graphics Processing Unit (GPU) has evolved far beyond its original purpose. Today, it’s a powerhouse driving revolutions in artificial intelligence, scientific discovery, and immersive experiences. But what fundamentally is a GPU, and how does it differ from the Central Processing Unit (CPU) that serves as the traditional brain of a computer?

    The Core Difference: Specialized Parallelism

    The key lies in their architectural design philosophy:

    CPU (Central Processing Unit)

    Designed as a “jack-of-all-trades.” A typical modern CPU has a relatively small number of powerful, complex cores (e.g., 4, 8, 16, 32). These cores excel at handling diverse, sequential tasks quickly – running operating systems, applications, logic, and complex decision-making where tasks often depend on the results of previous ones (sequential processing). CPUs prioritize low latency, meaning getting a single task done as fast as possible (Intel, 2023; AMD, 2023).

    GPU (Graphics Processing Unit)

    Designed as a “master of many similar tasks.” A GPU contains thousands of smaller, simpler, and highly efficient cores optimized for a specific type of workload: massively parallel processing. Rendering complex graphics involves performing the same mathematical operations (like calculating lighting, color, and position) simultaneously on millions of pixels or vertices. A GPU’s architecture is built to tackle vast numbers of these simple, repetitive calculations concurrently (NVIDIA, 2023).

    Anatomy of a GPU: Built for Throughput

    This parallel focus shapes the GPU’s physical and logical structure:

    • Thousands of Cores: Modern GPUs pack thousands of processing cores (e.g., NVIDIA’s Ada Lovelace architecture boasts tens of thousands of CUDA Cores). While individually less powerful than a CPU core, their sheer number allows for immense throughput – processing massive datasets simultaneously (NVIDIA, 2023).
    • Wide Memory Interface: To feed data to all these cores without bottlenecks, GPUs connect to specialized, high-speed Video RAM (VRAM) like GDDR6 or HBM2e via a very wide memory bus (e.g., 384-bit, 512-bit). This provides significantly higher memory bandwidth than typical CPU RAM (JEDEC, 2023).
    • Specialized Hardware: Beyond generic cores, modern GPUs include dedicated hardware units:
      • RT Cores (Ray Tracing): Accelerate complex calculations for realistic lighting and shadows in real-time rendering (NVIDIA, 2023).
      • Tensor Cores: Specifically designed for the matrix multiplication operations that are fundamental to deep learning and AI workloads (NVIDIA, 2023; AMD, 2023 – referencing their Matrix Cores).
    • Software Ecosystem: APIs like CUDA (NVIDIA), ROCm (AMD), and OpenCL allow programmers to harness the GPU’s parallel power for non-graphics tasks, known as General-Purpose computing on GPU (GPGPU) (Khronos Group, 2023; NVIDIA, 2023).

    Beyond Pixels: The Rise of GPGPU

    The realization that the GPU’s parallel architecture was incredibly efficient for certain non-graphics tasks sparked the GPGPU revolution. Any application that can be broken down into many smaller, independent tasks can potentially run much faster on a GPU:

    • Artificial Intelligence & Deep Learning: Training complex neural networks involves performing billions of matrix multiplications across massive datasets – a task perfectly suited for the parallel nature and tensor cores of modern GPUs. This is the engine behind breakthroughs in image recognition, natural language processing, and more (IEEE Spectrum, 2021).
    • High-Performance Computing (HPC): Scientific simulations (climate modeling, molecular dynamics, fluid dynamics) involve solving complex equations across vast grids or particle systems, inherently parallel problems where GPUs offer massive speedups over CPUs alone (Top500.org, 2023).
    • Data Science & Analytics: Processing and analyzing massive datasets for trends, patterns, and insights benefits greatly from GPU acceleration in tasks like data filtering, transformation, and complex statistical modeling (TechTarget, 2022).
    • Content Creation: Video editing (especially effects rendering and encoding), 3D animation rendering, and complex image processing leverage GPU power for significantly faster workflows (Adobe, 2023; Blender Foundation, 2023).
    • Advanced Graphics: Of course, rendering increasingly realistic and complex scenes in games, virtual reality (VR), and augmented reality (AR) remains a core function, continuously pushing GPU technology forward.

    Conclusion: The Parallel Workhorse

    A GPU is no longer just a graphics card. It is a highly specialized parallel processor engineered for raw computational throughput on tasks that can be executed simultaneously. While the CPU remains essential for general system management and complex sequential logic, the GPU has become indispensable for accelerating the massively parallel workloads that define modern computing frontiers: AI, scientific discovery, large-scale data analysis, and ever-more immersive visual experiences. Its evolution from a graphics renderer to a general-purpose computational powerhouse underscores its critical role in our technological landscape.

    Citations

  • How to add custom code to WordPress header and footer in functions.php

    How to add custom code to WordPress header and footer in functions.php

    Overview

    If you want to install chat widget on your wordpress website or want to add HotJar, Google Analytics, or other third party app script, it can be done easily by adding a code in the functions.php in wordpress instead of installing a wordpress plugin. Adding a wordpress header and footer code insertion plugin may very likely will slow your website.

    With the latest WordPress external link updates, header.php and footer.php are not available to edit in Tools -> The File Editor, so the best option is to put the code in functions.php.

    Steps

    Add code to WordPress header

    Use the wp_head hook to add content dynamically to header.php. Add the following code to functions.php in Child theme. If you do not have a Child theme than add it in your main theme functions.php by going to Tools -> The File Editor -> functions.php.

    add_action('wp_head', 'your_function_name');
    function your_function_name(){
    echo '<script> your custom code pasted here </script>';
    }

    Add code to WordPress footer

    Use the wp_head hook to add content dynamically to footer.php. Add the following code to functions.php in Child theme. If you do not have a Child theme than add in your main theme functions.php by going to Tools -> The File Editor -> functions.php.

    add_action('wp_footer', 'your_function_name');
    function your_function_name(){
    echo '<script>  your custom code pasted here </script>';
    }

    Make sure you change your_function_name at two places in the above codes and add your app script in place of ‘your custom code pasted here’. You can any code in this place.

    If you are not using child theme, this code added in functions.php may be overwriiten after a theme update. So, you may need to add this code again after a theme update if you are not using child theme.

  • SUDO allow normal user to run command as root

    SUDO allow normal user to run command as root

    Overview

    sudo enables users to execute root commands on a Linux dedicated server as a normal user. Unlike the su command, sudo offers greater flexibility and enhanced security.

    A key benefit of sudo is its ability to log usage, with log entries typically stored in the /var/log/secure file. The sudo program relies on the /etc/sudoers configuration file to define the rules that determine whether a command can be executed.

    Steps

    It is advisable to use the visudo utility, included with the sudo package, for editing the /etc/sudoers file. For instance, if we want a user named user to execute commands as root, we can start by using sudo to run a command that requires elevated permission.

    $ sudo /sbin/service sendmail restart
    Password:
    normaluser is not in the sudoers file.  This incident will be reported.

    The sudo command has logged the attempt to the log file /var/log/secure as shown below.

    # tail /var/log/secure
    ...
    Aug  2 14:37:49 somehost sudo:  user : user NOT in sudoers ;
    TTY=pts/2 ; PWD=/home/user ; USER=root ;
    COMMAND=/sbin/service sendmail restart

    On all Linux servers, there is a specific group called ‘wheel’ that is commonly associated with privileged operations. To include a user in the supplementary ‘wheel’ group, run the following command as the root user.

    # usermod -aG wheel user

    Verify that the user is now a member of the ‘wheel’ group.

    # groups user
    user : user wheel

    Edit the file /etc/sudoers using the visudo command as follows.

    # sudoers file.
    #
    # This file MUST be edited with the 'visudo' command as root.
    #
    # See the sudoers man page for the details on how to write a sudoers file.
    #
    
    # Host alias specification
    
    # User alias specification
    
    # Cmnd alias specification
    
    # Defaults specification
    
    # User privilege specification
    root    ALL=(ALL) ALL
    
    # Uncomment to allow people in group wheel to run all commands
    # %wheel ALL=(ALL)       ALL
    
    # Same thing without a password
    # %wheel        ALL=(ALL)       NOPASSWD: ALL
    
    # Samples
    # %users  ALL=/sbin/mount /cdrom,/sbin/umount /cdrom
    # %users  localhost=/sbin/shutdown -h now

    Take note that the /etc/sudoers file features examples and comments. To grant members of the ‘wheel’ group the ability to execute commands as root with sudo, you should uncomment the specified line.

    ...
    # Uncomment to allow people in group wheel to run all commands
    %wheel ALL=(ALL)       ALL
    ...

    The visudo utility utilizes key bindings and commands derived from the vi editor. To edit the visudo file, press ‘i’ to enter Insert mode. Use the cursor keys to position the cursor correctly, and press ‘Delete’ to remove the ‘#’ character. To save your modifications, hit the escape key, then type ‘:write’, and finally ‘:quit’ to exit.

    ...
    # Uncomment to allow people in group wheel to run all commands
    %wheel ALL=(ALL)       ALL
    
    #Same thing without a password
    # %wheel        ALL=(ALL)       NOPASSWD: ALL
    
    # Samples
    # %users  ALL=/sbin/mount /cdrom,/sbin/umount /cdrom
    # %users  localhost=/sbin/shutdown -h now
    
    # ALL     ALL = NOPASSWD: /usr/bin/mindspring

    Now run the privileged commands again as normal user.

    $ sudo /sbin/service sendmail restart
    Password:
    Shutting down sendmail:                                    [  OK  ]
    Shutting down sm-client:                                   [  OK  ]
    Starting sendmail:                                         [  OK  ]
    Starting sm-client:                                        [  OK  ]

    The successful execution of sudo will also be logged in the /var/log/secure file.

    # tail /var/log/secure
    ...
    Aug  2 15:05:49 somehost sudo:  user : TTY=pts/2 ;
    PWD=/home/user ; USER=root ;
    COMMAND=/sbin/service sendmail restart