How to find version of CUDA

Users of CUDA usually know its major.minor version.

If you want to know the full major.minor.patch version of CUDA you are using:

$ cat /usr/local/cuda/version.txt

For example, when I tried on my CUDA 9.2 installation:

$ cat /usr/local/cuda-9.2/version.txt                                                                                                                                                                        
CUDA Version 9.2.148

Cannot import name main


I got this error when I tried running pip:

    from pip import main
ImportError: cannot import name 'main'


I had installed pip from Ubuntu repositories using this command:

$ sudo apt install python-pip

However, I had previously used a pip from Anaconda on this computer. Though I had uninstalled it, it looked like it had left some files that were affecting how the Ubuntu pip worked.

I found the ~/.local/bin and ~/.local/lib directories that Anaconda pip had created and deleted those directories. Ubuntu pip worked fine after that.

Tried with: Ubuntu 16.04

Apt update stuck waiting for headers


I tried to update the apt cache on a machine that had not been updated in a long time:

$ sudo apt-get update

But that got stuck at one of the repositories Waiting for headers. No matter how many times I tried the command, it would get stuck at this.


The problem went away once I cleared the cache using these steps as explained here:

$ sudo apt-get clean
$ cd /var/lib/apt
$ sudo mv lists lists.old
$ sudo mkdir -p lists/partial
$ sudo apt-get clean
$ sudo apt-get update 

Tried with: Ubuntu 16.04

How to exclude files from Explorer in VSCode

Visual Studio Code displays the files of the currently open workspace or folder in an Explorer on the left. Sometimes, you may want VSCode to exclude certain files from the Explorer.

To do that:

  • Go to File → Preferences → Settings.
  • If you want to exclude for all projects, open the User Settings. If you want to exclude only for the current project, open the Workspace Settings.
  • Add a files.exclude entry like this:
"files.exclude" : {
    "Makefile": true,
    "*.html": true,
    "build/*": true

As shown above, filenames and globbing are allowed.

Tried with: Visual Studio Code 1.25.1 and Windows 10

How to create or delete user in Linux

  • To create a new user named joe:
$ sudo useradd joe

The above command does not create a home directory for the new user.

  • To create a new user named joe and create a home directory for him:
$ sudo useradd -m joe
  • To delete a user named joe:
$ sudo userdel joe

The above command does not remove the files owned by the user.

  • To delete a user named joe and remove all the files owned by him:
$ sudo userdel -r joe

Tried with: Ubuntu 16.04

Microsoft Outlook 2016 for Dummies

For most of my life, email was managed in either one of the free email providers (Yahoo and later Gmail) or POP/IMAP that I pulled into a simple email client. So, when I had to work with Microsoft Outlook recently, I was completely lost. Outlook when combined with Exchange is a powerful tool that handles email, calendars, meetings, tasks and notes for individuals and organizations. Quite frankly I was lost in the complex GUI of Outlook and all its features.

To get a quick idea of what is possible in Outlook and how to use it I turned to a familiar friend: Microsoft Outlook 2016 for Dummies. People like to ridicule the Dummies series of books, but Dan Gookin and his kind made software accessible to a lot of people like me. Dummies books, especially by veteran Dummies authors, are funny and fun to read. Bill Dyszel thankfully is no different, having been the author of all editions of the Outlook Dummies books.

This book covered all the important applications of Outlook 2016, only missing out on the notes feature. Earlier chapters cover the basics of using a email client, which can be skipped. Later chapters got into what I was looking for: Outlook specific features, scheduling, tasks and features related to Exchange. On the way I learnt a lot of tips and tricks which I probably would not have discovered otherwise. The only gripe I have about this book are that there are no cartoons by Rich Tennant. This is an easy and fun read full of screenshots.

Rating: 4
ISBN: 9781119076889

Some of the Outlook features I learnt from this book:

  • You can drag and drop anything to anywhere in the UI. For example, drag an email into the calendar icon at the bottom-right to create a calendar event.
  • Clean Up feature on email conversations and email folders can be used to move out emails that repeat in conversations to a specific folder. Reduces the number of emails you need to read.
  • Quick Steps are actions that you can create and add to the ribbon or right-click menu. For example, move to a certain folder is a builtin Quick Step.
  • Quick Parts can be used to reinsert repeatedly used text into emails.
  • You can create your own groups in contacts.
  • Appointments and events are different when it comes to calendars.
  • You can add holidays calendar for any country into your calendar.
  • Regenerating task is a type of task that recur after a task is completed.
  • Items of any tabular view of data can be grouped by one of the fields. Right-click on the column header and choose Group by.
  • Default categories in emails have colors and color names. These color names can be renamed to something more meaningful.
  • Merge to email can be used to create email mailers addressed to the receiver.
  • Scheduling assistant can be used to compare schedules of attendees. Suggested times at the bottom-right shows open timeslots.
  • When responding to a meeting request, you can propose a new time.
  • Voting feature is similar to meeting request, but to take count from a group of people.
  • Use Tracking to check responses from folks on meeting requests and votes.
  • You can assign task to someone else.
  • Out of office message can be set for your vacations with a start and end date. You can have different message for folks inside and outside your organization.
  • MailTips shows by colors and tooltips if any of the folks being addressed in email are on vacation.
  • Quick Access toobar can be customized by adding any function you want.

How to build and use GDB

Ubuntu uses quite an old version of GDB. When I need to use an updated version of GDB, here is what I do:

  • Obtain the newer version of GDB by downloading its .tar.gz from here. Unzip it.
  • Configure and build it:
$ ./configure
$ make
  • The newly built GDB executable can be found at gdb/gdb in your current directory. You can copy it or invoke it directly to use it.

Tried with: GDB 8.1 and Ubuntu 16.04

How to skip stepping into files in GDB

Visual Studio C++ debugger has a feature called Just My Code which helps you to step over external code, like that in STL, and only step through the code of your own project. GDB does not have this feature at the time of this writing.

However, GDB has a skip -gfile feature that can be used in a similar way. You pass this command a glob pattern of files to ignore during stepping.

For example, to skip stepping into the source files of STL implementations on my system I use:

skip -gfile /usr/include/c++/5/bits/*

This works because the STL implementation files on my system are located at the above path.

Note that this feature requires GDB 7.12 or later.

Reference: GDB Skipping over files and functions

Tried with: GDB 8.1 and Ubuntu 16.04

makeinfo not found error


I was trying to build a tool from source. When I ran ./configure, it complained with this error:

makeinfo: not found


The confusing part here is that this makeinfo has nothing to do with make. I found that it belongs to the package texinfo. The error went away after I installed that package:

$ sudo apt install texinfo

Tried with: Ubuntu 16.04

How to create and use multiple P4 workspaces

It is sometimes useful to have more than one workspace in Perforce. I have found that this gives me more freedom to work on multiple bugs or features at the same time for the same branch.

  • To create a new workspace, we create a new P4 client. To do this, you need to provide a new client name:
$ p4 client my_client_2

This opens the configuration of a new client named my_client_2 in your favorite editor. Here you can provide the root directory for this client and mappings as your normally would. Save and exit the editor.

  • Create the root directory path you specified in the new client config:
$ mkdir -p /home/joe/p4_workspaces/my_workspace_2
  • You need to set this client name as the current client to inform P4 that its commands apply to this client. You do this by setting the P4CLIENT environment variable:
$ export P4CLIENT=my_client_2

Now you can run commands such as sync and they should work in this new workspace.

  • Switching between two or more P4 workspaces gets onerous if you need to set the above environment variable every time. One solution to overcome this is to create a P4 config file in the root directory of every workspace with the environment variables you want applied for that workspace.

Create a file named .p4config in the root directory of the new workspace, /home/joe/p4_workspaces/my_workspace_2 in this example, with the environment variables and their values you want to set:


Now when you are at any child directory of the new workspace, P4 will know that it has to use the above client config for its commands. You need to place such config files at the roots of all your workspaces to have a pleasant working experience when moving between workspaces.